mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-28 17:29:41 +03:00
fix in 'gluSphere', new textures example
git-svn-id: svn://kolibrios.org@6143 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
98b9eb4616
commit
3a7404eddd
@ -1,5 +1,6 @@
|
||||
if not exist bin mkdir bin
|
||||
if not exist bin\text_1.png @copy text_1.png bin\text_1.png
|
||||
if not exist bin\text_2.png @copy text_2.png bin\text_2.png
|
||||
if not exist bin\toolb_1.png @copy toolb_1.png bin\toolb_1.png
|
||||
if not exist bin\font8x9.bmp @copy ..\..\..\..\..\fs\kfar\trunk\font8x9.bmp bin\font8x9.bmp
|
||||
if not exist bin\tinygl.obj @fasm.exe -m 16384 ..\tinygl.asm bin\tinygl.obj
|
||||
@ -18,6 +19,7 @@ if not exist bin\tinygl.obj @fasm.exe -m 16384 ..\tinygl.asm bin\tinygl.obj
|
||||
|
||||
@fasm.exe -m 16384 gears.asm bin\gears.kex
|
||||
@fasm.exe -m 16384 textures0.asm bin\textures0.kex
|
||||
@fasm.exe -m 16384 textures1.asm bin\textures1.kex
|
||||
|
||||
|
||||
@kpack bin\test0.kex
|
||||
@ -34,5 +36,6 @@ if not exist bin\tinygl.obj @fasm.exe -m 16384 ..\tinygl.asm bin\tinygl.obj
|
||||
|
||||
@kpack bin\gears.kex
|
||||
@kpack bin\textures0.kex
|
||||
@kpack bin\textures1.kex
|
||||
|
||||
pause
|
BIN
programs/develop/libraries/TinyGL/asm_fork/examples/text_2.png
Normal file
BIN
programs/develop/libraries/TinyGL/asm_fork/examples/text_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
@ -0,0 +1,532 @@
|
||||
use32
|
||||
org 0x0
|
||||
db 'MENUET01'
|
||||
dd 1,start,i_end
|
||||
dd mem,stacktop
|
||||
dd 0,cur_dir_path
|
||||
|
||||
include '../../../../../proc32.inc'
|
||||
include '../../../../../macros.inc'
|
||||
include '../../../../../KOSfuncs.inc'
|
||||
include '../../../../../develop/libraries/box_lib/load_lib.mac'
|
||||
include '../../../../../dll.inc'
|
||||
include '../opengl_const.inc'
|
||||
include '../../../../../develop/info3ds/info_fun_float.inc'
|
||||
|
||||
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
|
||||
struct FileInfoBlock
|
||||
Function dd ?
|
||||
Position dd ?
|
||||
Flags dd ?
|
||||
Count dd ?
|
||||
Buffer dd ?
|
||||
db ?
|
||||
FileName dd ?
|
||||
ends
|
||||
|
||||
image_data dd 0 ;указатель на временную память, нужен для преобразования изображения
|
||||
image_data_toolbar dd 0
|
||||
IMAGE_FILE1_SIZE equ 128*144*3+54 ;размер файла с изображением
|
||||
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
|
||||
IMAGE_TOOLBAR_SIZE equ IMAGE_TOOLBAR_ICON_SIZE*3+54
|
||||
|
||||
macro load_image_file path,buf,size { ;макрос для загрузки изображений
|
||||
;path - может быть переменной или строковым параметром
|
||||
if path eqtype '' ;проверяем задан ли строкой параметр path
|
||||
jmp @f
|
||||
local .path_str
|
||||
.path_str db path ;формируем локальную переменную
|
||||
db 0
|
||||
@@:
|
||||
;32 - стандартный адрес по которому должен быть буфер с системным путем
|
||||
copy_path .path_str,[32],file_name,0
|
||||
else
|
||||
copy_path path,[32],file_name,0 ;формируем полный путь к файлу изображения, подразумеваем что он в одной папке с программой
|
||||
end if
|
||||
stdcall mem.Alloc, dword size ;выделяем память для изображения
|
||||
mov [buf],eax
|
||||
mov [run_file_70.Function], SSF_READ_FILE
|
||||
mov [run_file_70.Position], 0
|
||||
mov [run_file_70.Flags], 0
|
||||
mov [run_file_70.Count], dword size
|
||||
mov [run_file_70.Buffer], eax
|
||||
mov byte[run_file_70+20], 0
|
||||
mov [run_file_70.FileName], file_name
|
||||
mcall SF_FILE,run_file_70 ;загружаем файл изображения
|
||||
cmp ebx,0xffffffff
|
||||
je @f
|
||||
;определяем вид изображения и переводим его во временный буфер image_data
|
||||
stdcall dword[img_decode], dword[buf],ebx,0
|
||||
mov dword[image_data],eax
|
||||
;преобразуем изображение к формату rgb
|
||||
stdcall dword[img_to_rgb2], dword[image_data],dword[buf]
|
||||
;удаляем временный буфер image_data
|
||||
stdcall dword[img_destroy], dword[image_data]
|
||||
@@:
|
||||
}
|
||||
|
||||
offs_zbuf_pbuf equ 24 ;const. from 'zbuffer.inc'
|
||||
|
||||
align 4
|
||||
start:
|
||||
load_libraries l_libs_start,l_libs_end
|
||||
;проверка на сколько удачно загузились библиотеки
|
||||
mov ebp,lib_0
|
||||
.test_lib_open:
|
||||
cmp dword [ebp+ll_struc_size-4],0
|
||||
jz @f
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
@@:
|
||||
add ebp,ll_struc_size
|
||||
cmp ebp,l_libs_end
|
||||
jl .test_lib_open
|
||||
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.sys_colors_new
|
||||
mcall SF_SET_EVENTS_MASK,0x27
|
||||
|
||||
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [glEnable], GL_DEPTH_TEST
|
||||
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
||||
stdcall [gluNewQuadric]
|
||||
mov [qObj],eax
|
||||
stdcall [gluQuadricTexture], eax,GL_TRUE
|
||||
|
||||
stdcall [glClearColor], 0.0,0.0,0.0,0.0
|
||||
stdcall [glShadeModel], GL_SMOOTH
|
||||
|
||||
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
|
||||
mov eax,[eax] ;eax -> ZBuffer
|
||||
mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf
|
||||
mov dword[buf_ogl],eax
|
||||
|
||||
load_image_file 'font8x9.bmp', image_data_toolbar,IMAGE_FILE1_SIZE
|
||||
stdcall [buf2d_create_f_img], buf_1,[image_data_toolbar] ;создаем буфер
|
||||
stdcall mem.Free,[image_data_toolbar] ;освобождаем память
|
||||
stdcall [buf2d_conv_24_to_8], buf_1,1 ;делаем буфер прозрачности 8 бит
|
||||
stdcall [buf2d_convert_text_matrix], buf_1
|
||||
|
||||
load_image_file 'toolb_1.png', image_data_toolbar,IMAGE_TOOLBAR_SIZE
|
||||
|
||||
load_image_file 'text_2.png', texture, (256*256*3+54) ;открытие файла текстуры
|
||||
|
||||
;* Setup texturing *
|
||||
stdcall [glTexEnvi], GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL
|
||||
|
||||
;* generate texture object IDs *
|
||||
stdcall [glGenTextures], 1, TexObj
|
||||
stdcall [glBindTexture], GL_TEXTURE_2D, [TexObj]
|
||||
stdcall [glTexImage2D], GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, [texture]
|
||||
|
||||
stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST
|
||||
stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST
|
||||
stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT
|
||||
stdcall [glTexParameteri], GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT
|
||||
stdcall [glBindTexture], GL_TEXTURE_2D, [TexObj]
|
||||
stdcall [glEnable], GL_TEXTURE_2D
|
||||
|
||||
call draw_3d
|
||||
|
||||
align 4
|
||||
red_win:
|
||||
call draw_window
|
||||
|
||||
align 4
|
||||
still:
|
||||
mcall SF_WAIT_EVENT
|
||||
cmp al,1
|
||||
jz red_win
|
||||
cmp al,2
|
||||
jz key
|
||||
cmp al,3
|
||||
jz button
|
||||
jmp still
|
||||
|
||||
align 4
|
||||
draw_window:
|
||||
pushad
|
||||
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||
mcall SF_CREATE_WINDOW,(50 shl 16)+420,(30 shl 16)+410,0x33ffffff,,caption
|
||||
|
||||
mov esi,[sc.work_button]
|
||||
mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;земля 1
|
||||
mcall ,(36 shl 16)+19,,4+0x40000000 ;земля 2
|
||||
|
||||
mcall SF_PUT_IMAGE,[image_data_toolbar],(21 shl 16)+21,(5 shl 16)+5 ;земля 1
|
||||
;add ebx,2*IMAGE_TOOLBAR_ICON_SIZE
|
||||
mcall ,,,(35 shl 16)+5 ;земля 2
|
||||
|
||||
stdcall [kosglSwapBuffers]
|
||||
mcall SF_REDRAW,SSF_END_DRAW
|
||||
popad
|
||||
ret
|
||||
|
||||
align 4
|
||||
key:
|
||||
mcall SF_GET_KEY
|
||||
|
||||
cmp ah,27 ;Esc
|
||||
je button.exit
|
||||
|
||||
cmp ah,61 ;+
|
||||
jne @f
|
||||
finit
|
||||
fld dword[scale]
|
||||
fadd dword[delt_sc]
|
||||
fst dword[scale]
|
||||
mov word[NumberSymbolsAD],3
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov byte[txt_scale.v],0
|
||||
stdcall str_cat, txt_scale.v,Data_String
|
||||
call draw_3d
|
||||
stdcall [kosglSwapBuffers]
|
||||
@@:
|
||||
cmp ah,45 ;-
|
||||
jne @f
|
||||
finit
|
||||
fld dword[scale]
|
||||
fsub dword[delt_sc]
|
||||
fst dword[scale]
|
||||
mov word[NumberSymbolsAD],3
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov byte[txt_scale.v],0
|
||||
stdcall str_cat, txt_scale.v,Data_String
|
||||
call draw_3d
|
||||
stdcall [kosglSwapBuffers]
|
||||
@@:
|
||||
cmp ah,176 ;Left
|
||||
jne @f
|
||||
finit
|
||||
fld dword[angle_y]
|
||||
fadd dword[delt_size]
|
||||
fst dword[angle_y]
|
||||
mov word[NumberSymbolsAD],2
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov byte[txt_angle_y.v],0
|
||||
stdcall str_cat, txt_angle_y.v,Data_String
|
||||
call draw_3d
|
||||
stdcall [kosglSwapBuffers]
|
||||
@@:
|
||||
cmp ah,179 ;Right
|
||||
jne @f
|
||||
finit
|
||||
fld dword[angle_y]
|
||||
fsub dword[delt_size]
|
||||
fst dword[angle_y]
|
||||
mov word[NumberSymbolsAD],2
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov byte[txt_angle_y.v],0
|
||||
stdcall str_cat, txt_angle_y.v,Data_String
|
||||
call draw_3d
|
||||
stdcall [kosglSwapBuffers]
|
||||
@@:
|
||||
cmp ah,178 ;Up
|
||||
jne @f
|
||||
finit
|
||||
fld dword[angle_x]
|
||||
fadd dword[delt_size]
|
||||
fst dword[angle_x]
|
||||
mov word[NumberSymbolsAD],2
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov byte[txt_angle_x.v],0
|
||||
stdcall str_cat, txt_angle_x.v,Data_String
|
||||
call draw_3d
|
||||
stdcall [kosglSwapBuffers]
|
||||
@@:
|
||||
cmp ah,177 ;Down
|
||||
jne @f
|
||||
finit
|
||||
fld dword[angle_x]
|
||||
fsub dword[delt_size]
|
||||
fst dword[angle_x]
|
||||
mov word[NumberSymbolsAD],2
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov byte[txt_angle_x.v],0
|
||||
stdcall str_cat, txt_angle_x.v,Data_String
|
||||
call draw_3d
|
||||
stdcall [kosglSwapBuffers]
|
||||
@@:
|
||||
|
||||
jmp still
|
||||
|
||||
align 4
|
||||
button:
|
||||
mcall SF_GET_BUTTON
|
||||
cmp ah,3
|
||||
jne @f
|
||||
call but_dr_0
|
||||
jmp still
|
||||
@@:
|
||||
cmp ah,4
|
||||
jne @f
|
||||
call but_dr_1
|
||||
jmp still
|
||||
@@:
|
||||
cmp ah,1
|
||||
jne still
|
||||
.exit:
|
||||
stdcall [gluDeleteQuadric], [qObj]
|
||||
stdcall mem.Free,[image_data_toolbar]
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
align 4
|
||||
but_dr_0:
|
||||
mov dword[dr_figure],0
|
||||
call draw_3d
|
||||
stdcall [kosglSwapBuffers]
|
||||
ret
|
||||
|
||||
align 4
|
||||
but_dr_1:
|
||||
mov dword[dr_figure],1
|
||||
call draw_3d
|
||||
stdcall [kosglSwapBuffers]
|
||||
ret
|
||||
|
||||
align 4
|
||||
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
align 4
|
||||
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
||||
;sizeof.TinyGLContext = 28
|
||||
|
||||
align 4
|
||||
draw_3d:
|
||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||
|
||||
stdcall [glPushMatrix]
|
||||
stdcall [glTranslatef], 0.0,0.0,0.5
|
||||
stdcall [glScalef], [scale], [scale], [scale]
|
||||
;stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
||||
stdcall [glRotatef], [angle_y],0.0,1.0,0.0
|
||||
stdcall [glRotatef], [angle_x],1.0,0.0,0.0
|
||||
|
||||
cmp dword[dr_figure],0
|
||||
jne @f
|
||||
; рисование земли
|
||||
stdcall [gluSphere], [qObj], 1.0, 16,16
|
||||
@@:
|
||||
cmp dword[dr_figure],1
|
||||
jne @f
|
||||
; рисование земли
|
||||
stdcall [gluSphere], [qObj], 1.0, 64,64
|
||||
@@:
|
||||
stdcall [glPopMatrix]
|
||||
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_scale,5,5,0xffff00
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_y,5,15,0xffff00
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_x,5,25,0xffff00
|
||||
ret
|
||||
|
||||
dr_figure dd 0
|
||||
qObj dd 0
|
||||
TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.)
|
||||
texture dd 0 ;указатель на память с текстурой
|
||||
|
||||
scale dd 0.5
|
||||
delt_sc dd 0.05
|
||||
angle_z dd 0.0
|
||||
angle_x dd 90.0
|
||||
angle_y dd 225.0
|
||||
delt_size dd 3.0
|
||||
|
||||
;--------------------------------------------------
|
||||
align 4
|
||||
import_lib_tinygl:
|
||||
|
||||
macro E_LIB n
|
||||
{
|
||||
n dd sz_#n
|
||||
}
|
||||
include '../export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
sz_#n db `n,0
|
||||
}
|
||||
include '../export.inc'
|
||||
|
||||
align 4
|
||||
import_buf2d:
|
||||
dd sz_init0
|
||||
buf2d_create dd sz_buf2d_create
|
||||
buf2d_create_f_img dd sz_buf2d_create_f_img
|
||||
buf2d_clear dd sz_buf2d_clear
|
||||
buf2d_draw dd sz_buf2d_draw
|
||||
buf2d_delete dd sz_buf2d_delete
|
||||
buf2d_resize dd sz_buf2d_resize
|
||||
buf2d_line dd sz_buf2d_line
|
||||
buf2d_rect_by_size dd sz_buf2d_rect_by_size
|
||||
buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
|
||||
buf2d_circle dd sz_buf2d_circle
|
||||
buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
|
||||
buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
|
||||
buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
|
||||
buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
|
||||
buf2d_bit_blt dd sz_buf2d_bit_blt
|
||||
buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
|
||||
buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
|
||||
buf2d_curve_bezier dd sz_buf2d_curve_bezier
|
||||
buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
|
||||
buf2d_draw_text dd sz_buf2d_draw_text
|
||||
buf2d_crop_color dd sz_buf2d_crop_color
|
||||
buf2d_offset_h dd sz_buf2d_offset_h
|
||||
buf2d_flood_fill dd sz_buf2d_flood_fill
|
||||
buf2d_set_pixel dd sz_buf2d_set_pixel
|
||||
dd 0,0
|
||||
sz_init0 db 'lib_init',0
|
||||
sz_buf2d_create db 'buf2d_create',0
|
||||
sz_buf2d_create_f_img db 'buf2d_create_f_img',0
|
||||
sz_buf2d_clear db 'buf2d_clear',0
|
||||
sz_buf2d_draw db 'buf2d_draw',0
|
||||
sz_buf2d_delete db 'buf2d_delete',0
|
||||
sz_buf2d_resize db 'buf2d_resize',0
|
||||
sz_buf2d_line db 'buf2d_line',0
|
||||
sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
|
||||
sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
|
||||
sz_buf2d_circle db 'buf2d_circle',0
|
||||
sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
|
||||
sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
|
||||
sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
|
||||
sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
|
||||
sz_buf2d_bit_blt db 'buf2d_bit_blt',0
|
||||
sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
|
||||
sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
|
||||
sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
|
||||
sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
|
||||
sz_buf2d_draw_text db 'buf2d_draw_text',0
|
||||
sz_buf2d_crop_color db 'buf2d_crop_color',0
|
||||
sz_buf2d_offset_h db 'buf2d_offset_h',0
|
||||
sz_buf2d_flood_fill db 'buf2d_flood_fill',0
|
||||
sz_buf2d_set_pixel db 'buf2d_set_pixel',0
|
||||
|
||||
align 4
|
||||
import_libimg:
|
||||
dd alib_init1
|
||||
img_is_img dd aimg_is_img
|
||||
img_info dd aimg_info
|
||||
img_from_file dd aimg_from_file
|
||||
img_to_file dd aimg_to_file
|
||||
img_from_rgb dd aimg_from_rgb
|
||||
img_to_rgb dd aimg_to_rgb
|
||||
img_to_rgb2 dd aimg_to_rgb2
|
||||
img_decode dd aimg_decode
|
||||
img_encode dd aimg_encode
|
||||
img_create dd aimg_create
|
||||
img_destroy dd aimg_destroy
|
||||
img_destroy_layer dd aimg_destroy_layer
|
||||
img_count dd aimg_count
|
||||
img_lock_bits dd aimg_lock_bits
|
||||
img_unlock_bits dd aimg_unlock_bits
|
||||
img_flip dd aimg_flip
|
||||
img_flip_layer dd aimg_flip_layer
|
||||
img_rotate dd aimg_rotate
|
||||
img_rotate_layer dd aimg_rotate_layer
|
||||
img_draw dd aimg_draw
|
||||
|
||||
dd 0,0
|
||||
alib_init1 db 'lib_init',0
|
||||
aimg_is_img db 'img_is_img',0 ;определяет по данным, может ли библиотека сделать из них изображение
|
||||
aimg_info db 'img_info',0
|
||||
aimg_from_file db 'img_from_file',0
|
||||
aimg_to_file db 'img_to_file',0
|
||||
aimg_from_rgb db 'img_from_rgb',0
|
||||
aimg_to_rgb db 'img_to_rgb',0 ;преобразование изображения в данные RGB
|
||||
aimg_to_rgb2 db 'img_to_rgb2',0
|
||||
aimg_decode db 'img_decode',0 ;автоматически определяет формат графических данных
|
||||
aimg_encode db 'img_encode',0
|
||||
aimg_create db 'img_create',0
|
||||
aimg_destroy db 'img_destroy',0
|
||||
aimg_destroy_layer db 'img_destroy_layer',0
|
||||
aimg_count db 'img_count',0
|
||||
aimg_lock_bits db 'img_lock_bits',0
|
||||
aimg_unlock_bits db 'img_unlock_bits',0
|
||||
aimg_flip db 'img_flip',0
|
||||
aimg_flip_layer db 'img_flip_layer',0
|
||||
aimg_rotate db 'img_rotate',0
|
||||
aimg_rotate_layer db 'img_rotate_layer',0
|
||||
aimg_draw db 'img_draw',0
|
||||
|
||||
;--------------------------------------------------
|
||||
system_dir_0 db '/sys/lib/'
|
||||
lib_name_0 db 'tinygl.obj',0
|
||||
system_dir_1 db '/sys/lib/'
|
||||
lib_name_1 db 'buf2d.obj',0
|
||||
system_dir_2 db '/sys/lib/'
|
||||
lib_name_2 db 'libimg.obj',0
|
||||
err_msg_found_lib_0 db 'Sorry I cannot load library ',39,'tinygl.obj',39,0
|
||||
err_msg_found_lib_1 db 'Sorry I cannot load library ',39,'buf2d.obj',39,0
|
||||
err_msg_found_lib_2 db 'Sorry I cannot load library ',39,'libimg.obj',39,0
|
||||
head_f_i:
|
||||
head_f_l db 'System error',0
|
||||
err_msg_import_0 db 'Error on load import library ',39,'tinygl.obj',39,0
|
||||
err_msg_import_1 db 'Error on load import library ',39,'buf2d.obj',39,0
|
||||
err_msg_import_2 db 'Error on load import library ',39,'libimg.obj',39,0
|
||||
;--------------------------------------------------
|
||||
|
||||
txt_scale:
|
||||
db 'Scale: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
|
||||
txt_angle_z:
|
||||
db 'Rotate z: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
|
||||
txt_angle_x:
|
||||
db 'Rotate x: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
|
||||
txt_angle_y:
|
||||
db 'Rotate y: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
|
||||
align 4
|
||||
buf_ogl:
|
||||
dd 0 ;указатель на буфер изображения
|
||||
dw 10,10 ;+4 left,top
|
||||
.w: dd 400
|
||||
.h: dd 350
|
||||
dd 0,24 ;+16 color,bit in pixel
|
||||
|
||||
align 4
|
||||
buf_1:
|
||||
dd 0 ;указатель на буфер изображения
|
||||
dw 25,25 ;+4 left,top
|
||||
dd 128,144 ;+8 w,h
|
||||
dd 0,24 ;+16 color,bit in pixel
|
||||
|
||||
align 4
|
||||
l_libs_start:
|
||||
lib_0 l_libs lib_name_0, cur_dir_path, library_path, system_dir_0,\
|
||||
err_msg_found_lib_0, head_f_l, import_lib_tinygl,err_msg_import_0,head_f_i
|
||||
lib_1 l_libs lib_name_1, cur_dir_path, library_path, system_dir_1,\
|
||||
err_msg_found_lib_1, head_f_l, import_buf2d, err_msg_import_1,head_f_i
|
||||
lib_2 l_libs lib_name_2, cur_dir_path, file_name, system_dir_2,\
|
||||
err_msg_found_lib_2, head_f_l, import_libimg, err_msg_import_2, head_f_i
|
||||
l_libs_end:
|
||||
|
||||
align 4
|
||||
i_end:
|
||||
run_file_70 FileInfoBlock
|
||||
sc system_colors
|
||||
rb sizeof.sys_colors_new-sizeof.system_colors
|
||||
align 16
|
||||
rb 4096
|
||||
stacktop:
|
||||
cur_dir_path rb 4096
|
||||
library_path rb 4096
|
||||
file_name rb 4096
|
||||
mem:
|
@ -30,7 +30,7 @@ offs_qobj_ErrorFunc equ 16
|
||||
;{
|
||||
;}
|
||||
|
||||
align 4
|
||||
align 16
|
||||
gluNewQuadric:
|
||||
stdcall gl_malloc, sizeof.GLUquadricObj
|
||||
or eax,eax
|
||||
@ -43,7 +43,7 @@ gluNewQuadric:
|
||||
@@:
|
||||
ret
|
||||
|
||||
align 4
|
||||
align 16
|
||||
proc gluDeleteQuadric, state:dword
|
||||
cmp dword[state],0
|
||||
je @f
|
||||
@ -56,7 +56,7 @@ endp
|
||||
; Set the drawing style to be GLU_FILL, GLU_LINE, GLU_SILHOUETTE,
|
||||
; or GLU_POINT.
|
||||
;
|
||||
align 4
|
||||
align 16
|
||||
proc gluQuadricDrawStyle uses eax ebx, qobj:dword, drawStyle:dword
|
||||
mov eax,[qobj]
|
||||
or eax,eax
|
||||
@ -71,9 +71,11 @@ proc gluQuadricDrawStyle uses eax ebx, qobj:dword, drawStyle:dword
|
||||
cmp ebx,GLU_POINT
|
||||
je @f
|
||||
jmp .err_q
|
||||
align 4
|
||||
@@:
|
||||
mov dword[eax+offs_qobj_DrawStyle],ebx
|
||||
jmp @f
|
||||
align 4
|
||||
.err_q:
|
||||
stdcall dbg_print,sz_gluQuadricDrawStyle,err_9
|
||||
@@:
|
||||
@ -83,7 +85,7 @@ endp
|
||||
;
|
||||
; Set the orientation to GLU_INSIDE or GLU_OUTSIDE.
|
||||
;
|
||||
align 4
|
||||
align 16
|
||||
proc gluQuadricOrientation uses eax ebx, qobj:dword, orientation:dword
|
||||
mov eax,[qobj]
|
||||
or eax,eax
|
||||
@ -94,16 +96,18 @@ proc gluQuadricOrientation uses eax ebx, qobj:dword, orientation:dword
|
||||
cmp ebx,GLU_OUTSIDE
|
||||
je @f
|
||||
jmp .err_q
|
||||
align 4
|
||||
@@:
|
||||
mov dword[eax+offs_qobj_Orientation],ebx
|
||||
jmp @f
|
||||
align 4
|
||||
.err_q:
|
||||
stdcall dbg_print,sz_gluQuadricOrientation,err_9
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
align 16
|
||||
proc gluQuadricTexture uses eax ebx, qobj:dword, texture:dword
|
||||
mov eax,[qobj]
|
||||
or eax,eax
|
||||
@ -116,6 +120,7 @@ proc gluQuadricTexture uses eax ebx, qobj:dword, texture:dword
|
||||
@@:
|
||||
mov dword[eax+offs_qobj_TextureFlag],ebx
|
||||
jmp @f
|
||||
align 4
|
||||
.err_q:
|
||||
stdcall dbg_print,sz_gluQuadricTexture,err_9
|
||||
@@:
|
||||
@ -138,7 +143,7 @@ endp
|
||||
|
||||
;input:
|
||||
; float radius, int slices, int stacks
|
||||
align 4
|
||||
align 16
|
||||
proc gluSphere qobj:dword, radius:dword, slices:dword, stacks:dword
|
||||
locals
|
||||
rho dd ? ;float
|
||||
@ -165,6 +170,7 @@ pushad
|
||||
jne .els_0
|
||||
mov dword[normals],GL_FALSE
|
||||
jmp @f
|
||||
align 4
|
||||
.els_0:
|
||||
mov dword[normals],GL_TRUE
|
||||
@@:
|
||||
@ -172,6 +178,7 @@ pushad
|
||||
jne .els_1
|
||||
mov dword[nsign],-1.0
|
||||
jmp @f
|
||||
align 4
|
||||
.els_1:
|
||||
mov dword[nsign],1.0
|
||||
@@:
|
||||
@ -198,7 +205,7 @@ pushad
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
stdcall glTexCoord2f, 0.5,0.0
|
||||
stdcall glTexCoord2f, 0.5,1.0
|
||||
@@:
|
||||
sub esp,4
|
||||
fld dword[nsign]
|
||||
@ -221,6 +228,7 @@ align 4
|
||||
fild dword[j]
|
||||
fmul dword[dtheta]
|
||||
jmp .t0_end
|
||||
align 4
|
||||
@@:
|
||||
fldz
|
||||
.t0_end:
|
||||
@ -262,6 +270,7 @@ align 4
|
||||
call glVertex3f ;x*radius, y*radius, z*radius
|
||||
inc dword[j]
|
||||
jmp .cycle_0
|
||||
align 4
|
||||
.cycle_0_end:
|
||||
call glEnd
|
||||
|
||||
@ -278,6 +287,7 @@ align 4
|
||||
mov dword[i],0
|
||||
mov [imax],ebx
|
||||
jmp @f
|
||||
align 4
|
||||
.els_2:
|
||||
mov dword[i],1
|
||||
dec ebx
|
||||
@ -306,6 +316,7 @@ align 4
|
||||
fild dword[j]
|
||||
fmul dword[dtheta]
|
||||
jmp .t1_end
|
||||
align 4
|
||||
@@:
|
||||
fldz
|
||||
.t1_end:
|
||||
@ -339,11 +350,7 @@ align 4
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
fld1
|
||||
fsub dword[t]
|
||||
fstp dword[esp-4]
|
||||
sub esp,4
|
||||
stdcall glTexCoord2f, [s] ;,1-t
|
||||
stdcall glTexCoord2f, [s],[t]
|
||||
@@:
|
||||
fld dword[radius]
|
||||
fld dword[z]
|
||||
@ -391,12 +398,11 @@ align 4
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
fld1
|
||||
fsub dword[t]
|
||||
fadd dword[d_t]
|
||||
fld dword[t]
|
||||
fsub dword[d_t]
|
||||
fstp dword[esp-4]
|
||||
sub esp,4
|
||||
stdcall glTexCoord2f, [s] ;,1-(t-dt)
|
||||
stdcall glTexCoord2f, [s] ;,t-dt
|
||||
fld dword[s]
|
||||
fadd dword[d_s]
|
||||
fstp dword[s]
|
||||
@ -415,6 +421,7 @@ align 4
|
||||
call glVertex3f ;x*radius, y*radius, z*radius
|
||||
inc dword[j]
|
||||
jmp .cycle_2
|
||||
align 4
|
||||
.cycle_2_end:
|
||||
call glEnd
|
||||
fld dword[t]
|
||||
@ -422,6 +429,7 @@ align 4
|
||||
fstp dword[t]
|
||||
inc dword[i]
|
||||
jmp .cycle_1
|
||||
align 4
|
||||
.cycle_1_end:
|
||||
|
||||
; draw -Z end as a triangle fan
|
||||
@ -432,7 +440,7 @@ align 4
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
stdcall glTexCoord2f, 0.5,1.0
|
||||
stdcall glTexCoord2f, 0.5,0.0
|
||||
mov dword[s],1.0
|
||||
mov ebx,[d_t]
|
||||
mov [t],ebx
|
||||
@ -460,6 +468,7 @@ align 4
|
||||
fild dword[j]
|
||||
fmul dword[dtheta]
|
||||
jmp .t2_end
|
||||
align 4
|
||||
@@:
|
||||
fldz
|
||||
.t2_end:
|
||||
@ -491,11 +500,7 @@ align 4
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
fld1
|
||||
fsub dword[t]
|
||||
fstp dword[esp-4]
|
||||
sub esp,4
|
||||
stdcall glTexCoord2f, [s] ;,1-t
|
||||
stdcall glTexCoord2f, [s],[t]
|
||||
fld dword[s]
|
||||
fsub dword[d_s]
|
||||
fstp dword[s]
|
||||
@ -514,16 +519,19 @@ align 4
|
||||
call glVertex3f ;x*radius, y*radius, z*radius
|
||||
dec dword[j]
|
||||
jmp .cycle_3
|
||||
align 4
|
||||
.cycle_3_end:
|
||||
call glEnd
|
||||
jmp .end_f
|
||||
|
||||
align 4
|
||||
.if_glu_line:
|
||||
cmp dword[eax+offs_qobj_DrawStyle],GLU_LINE ;if (qobj.DrawStyle==GLU_LINE)
|
||||
je @f
|
||||
cmp dword[eax+offs_qobj_DrawStyle],GLU_SILHOUETTE ;if (qobj.DrawStyle==GLU_SILHOUETTE)
|
||||
je @f
|
||||
jmp .if_glu_point
|
||||
align 4
|
||||
@@:
|
||||
|
||||
; draw stack lines
|
||||
@ -590,10 +598,12 @@ align 4
|
||||
call glVertex3f ;x*radius, y*radius, z*radius
|
||||
inc dword[j]
|
||||
jmp .cycle_5
|
||||
align 4
|
||||
.cycle_5_end:
|
||||
call glEnd
|
||||
inc dword[i]
|
||||
jmp .cycle_4
|
||||
align 4
|
||||
.cycle_4_end:
|
||||
|
||||
; draw slice lines
|
||||
@ -655,13 +665,16 @@ align 4
|
||||
call glVertex3f ;x*radius, y*radius, z*radius
|
||||
inc dword[i]
|
||||
jmp .cycle_7
|
||||
align 4
|
||||
.cycle_7_end:
|
||||
call glEnd
|
||||
inc dword[j]
|
||||
jmp .cycle_6
|
||||
align 4
|
||||
.cycle_6_end:
|
||||
jmp .end_f
|
||||
|
||||
align 4
|
||||
.if_glu_point:
|
||||
cmp dword[eax+offs_qobj_DrawStyle],GLU_POINT ;if (qobj.DrawStyle==GLU_POINT)
|
||||
jne .end_f
|
||||
@ -749,9 +762,11 @@ align 4
|
||||
call glVertex3f ;x*radius, y*radius, z*radius
|
||||
inc dword[j]
|
||||
jmp .cycle_9
|
||||
align 4
|
||||
.cycle_9_end:
|
||||
inc dword[i]
|
||||
jmp .cycle_8
|
||||
align 4
|
||||
.cycle_8_end:
|
||||
call glEnd
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user