From ce8c06cf273b99c2eba1a47efafb47d5af29a859 Mon Sep 17 00:00:00 2001 From: IgorA Date: Tue, 23 Feb 2016 17:19:45 +0000 Subject: [PATCH] add function gluCylinder git-svn-id: svn://kolibrios.org@6286 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../TinyGL/asm_fork/examples/Tupfile.lua | 2 + .../TinyGL/asm_fork/examples/test_glu1.asm | 441 +++++++++++++++--- .../libraries/TinyGL/asm_fork/export.inc | 157 +++---- .../develop/libraries/TinyGL/asm_fork/glu.asm | 437 ++++++++++++++++- 4 files changed, 894 insertions(+), 143 deletions(-) create mode 100644 programs/develop/libraries/TinyGL/asm_fork/examples/Tupfile.lua diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/Tupfile.lua b/programs/develop/libraries/TinyGL/asm_fork/examples/Tupfile.lua new file mode 100644 index 0000000000..b34ba0b9da --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/Tupfile.lua @@ -0,0 +1,2 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +tup.foreach_rule("*.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "%B") diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu1.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu1.asm index 32ad46fc4f..85b45894c3 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu1.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu1.asm @@ -1,39 +1,62 @@ use32 org 0x0 db 'MENUET01' - dd 0x1 - dd start - dd i_end - dd mem,stacktop - dd 0,cur_dir_path + dd 1,start,i_end,mem,stacktop,0,cur_dir_path include '../../../../../proc32.inc' include '../../../../../macros.inc' -include '../../../../../develop/libraries/box_lib/load_lib.mac' -include '../../../../../dll.inc' +include '../../../../../KOSfuncs.inc' +include '../../../../../load_img.inc' include '../opengl_const.inc' +include '../../../../../develop/info3ds/info_fun_float.inc' -@use_library +@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load + +align 4 +image_data_toolbar dd 0 +IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3 + +offs_zbuf_pbuf equ 24 ;const. from 'zbuffer.inc' align 4 start: - load_library name_tgl, cur_dir_path, library_path, system_path, \ - err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i - cmp eax,-1 - jz button.exit +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 40,0x27 + mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors + mcall SF_SET_EVENTS_MASK,0x27 -stdcall [kosglMakeCurrent], 10,10,400,350,ctx1 -stdcall [glEnable], GL_DEPTH_TEST -stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов -stdcall [gluNewQuadric] -mov [qObj],eax + 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 [glClearColor], 0.25,0.25,0.25,0.0 -stdcall [glShadeModel], GL_SMOOTH + stdcall [glClearColor], 0.25,0.25,0.25,0.0 + stdcall [glShadeModel], GL_SMOOTH -call draw_3d + 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, buf_1.w,buf_1.h + 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 + call draw_3d align 4 red_win: @@ -41,7 +64,7 @@ red_win: align 4 still: - mcall 10 + mcall SF_WAIT_EVENT cmp al,1 jz red_win cmp al,2 @@ -53,68 +76,101 @@ still: align 4 draw_window: pushad - mcall 12,1 + 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 ;вершины вкл. + mcall ,(36 shl 16)+19,,4+0x40000000 ;каркасные грани вкл. + mcall ,(66 shl 16)+19,,5+0x40000000 ;сплошные грани вкл. + mcall ,(96 shl 16)+19,,6+0x40000000 ;масштаб + + mcall ,(126 shl 16)+19,,7+0x40000000 ;масштаб - + + mcall SF_PUT_IMAGE,[image_data_toolbar],(21 shl 16)+21,(5 shl 16)+5 ;вершины вкл. + add ebx,IMAGE_TOOLBAR_ICON_SIZE + mcall ,,,(35 shl 16)+5 ;каркасные грани вкл. + add ebx,IMAGE_TOOLBAR_ICON_SIZE + mcall ,,,(65 shl 16)+5 ;сплошные грани вкл. + add ebx,IMAGE_TOOLBAR_ICON_SIZE + mcall ,,,(95 shl 16)+5 ;масштаб + + add ebx,IMAGE_TOOLBAR_ICON_SIZE + mcall ,,,(125 shl 16)+5 ;масштаб - - mov edx,0x33ffffff ;0x73ffffff - mcall 0,(50 shl 16)+430,(30 shl 16)+400,,,caption stdcall [kosglSwapBuffers] - - mcall 12,2 + mcall SF_REDRAW,SSF_END_DRAW popad ret align 4 key: - mcall 2 + mcall SF_GET_KEY cmp ah,27 ;Esc je button.exit cmp ah,61 ;+ jne @f - fld dword[scale] - fadd dword[delt_sc] - fstp dword[scale] - call draw_3d - stdcall [kosglSwapBuffers] + call but_zoom_p + jmp still @@: cmp ah,45 ;- jne @f - fld dword[scale] - fsub dword[delt_sc] - fstp dword[scale] - call draw_3d - stdcall [kosglSwapBuffers] + call but_zoom_m + jmp still @@: cmp ah,178 ;Up jne @f + finit fld dword[angle_y] fadd dword[delt_size] - fstp dword[angle_y] + 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,177 ;Down jne @f + finit fld dword[angle_y] fsub dword[delt_size] - fstp dword[angle_y] + 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,176 ;Left jne @f + finit fld dword[angle_z] fadd dword[delt_size] - fstp dword[angle_z] + fst dword[angle_z] + mov word[NumberSymbolsAD],2 + fstp qword[Data_Double] + call DoubleFloat_to_String + mov byte[txt_angle_z.v],0 + stdcall str_cat, txt_angle_z.v,Data_String call draw_3d stdcall [kosglSwapBuffers] @@: cmp ah,179 ;Right jne @f + finit fld dword[angle_z] fsub dword[delt_size] - fstp dword[angle_z] + fst dword[angle_z] + mov word[NumberSymbolsAD],2 + fstp qword[Data_Double] + call DoubleFloat_to_String + mov byte[txt_angle_z.v],0 + stdcall str_cat, txt_angle_z.v,Data_String call draw_3d stdcall [kosglSwapBuffers] @@: @@ -123,20 +179,119 @@ key: align 4 button: - mcall 17 + mcall SF_GET_BUTTON + cmp ah,3 + jne @f + call but_st_point + jmp still + @@: + cmp ah,4 + jne @f + call but_st_line + jmp still + @@: + cmp ah,5 + jne @f + call but_st_face + jmp still + @@: + cmp ah,6 + jne @f + call but_zoom_p + jmp still + @@: + cmp ah,7 + jne @f + call but_zoom_m + jmp still + @@: cmp ah,1 jne still .exit: stdcall [gluDeleteQuadric], [qObj] - mcall -1 + stdcall mem.Free,[image_data_toolbar] + mcall SF_TERMINATE_PROCESS + +align 4 +but_st_point: + stdcall [gluQuadricDrawStyle], [qObj],GLU_POINT + call draw_3d + stdcall [kosglSwapBuffers] + ret + +align 4 +but_st_line: + stdcall [gluQuadricDrawStyle], [qObj],GLU_LINE + call draw_3d + stdcall [kosglSwapBuffers] + ret + +align 4 +but_st_face: + stdcall [gluQuadricDrawStyle], [qObj],GLU_FILL + call draw_3d + stdcall [kosglSwapBuffers] + ret + +align 4 +but_zoom_p: + finit + fld dword[scale] + fadd dword[sc_delt] + fcom dword[sc_max] + fstsw ax + sahf + jbe @f + ffree st0 + fincstp + fld dword[sc_max] + @@: + 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] + ret + +align 4 +but_zoom_m: + finit + fld dword[scale] + fsub dword[sc_delt] + fcom dword[sc_min] + fstsw ax + sahf + ja @f + ffree st0 + fincstp + fld dword[sc_min] + @@: + 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] + ret align 4 -caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0 +caption db 'Test gluCylinder, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0 align 4 ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext ;sizeof.TinyGLContext = 28 +rad1 dq 1.0 +rad2 dq 0.55 +rad3 dq 0.15 +hei1 dq 2.0 ;высота цилиндра +hei2 dq 1.25 + align 4 draw_3d: stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины @@ -146,21 +301,27 @@ stdcall [glPushMatrix] stdcall [glTranslatef], 0.0,0.0,0.5 stdcall [glScalef], [scale], [scale], [scale] + stdcall [glScalef], 1.0, 1.0, 0.5 stdcall [glColor3f], 1.0, 1.0, 0.0 stdcall [glRotatef], [angle_z],0.0,0.0,1.0 stdcall [glRotatef], [angle_y],0.0,1.0,0.0 - stdcall [gluSphere], [qObj], 1.0, 32,32 + stdcall [glTranslatef], 0.0,0.0,-1.0 ;опускаем цилинды вниз + stdcall [gluCylinder], [qObj], rad1,rad1,hei1, 32,8 stdcall [glColor3f], 1.0, 0.0, 0.0 stdcall [glTranslatef], -1.6,0.0,0.0 - stdcall [gluSphere], [qObj], 0.55, 16,16 + stdcall [gluCylinder], [qObj], rad2,rad3,hei2, 16,8 stdcall [glColor3f], 0.0, 0.0, 1.0 stdcall [glTranslatef], 3.2,0.0,0.0 - stdcall [gluSphere], [qObj], 0.55, 16,16 + stdcall [gluCylinder], [qObj], rad2,rad3,hei2, 16,8 stdcall [glPopMatrix] -ret + + stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_scale,5,5,0xffff00 + stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_z,5,15,0xffff00 + stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_y,5,25,0xffff00 + ret align 4 SetLight: @@ -182,10 +343,12 @@ ret qObj dd 0 -scale dd 0.4 -delt_sc dd 0.05 -angle_z dd 0.0 -angle_y dd 0.0 +scale dd 0.4 ;начальный масштаб +sc_delt dd 0.05 ;изменение масштаба при нажатии +sc_min dd 0.1 ;минимальный масштаб +sc_max dd 1.1 ;максимальный масштаб +angle_z dd -45.0 +angle_y dd -150.0 delt_size dd 3.0 light_position dd 3.0, 2.0, -10.0, 1.0 ; Расположение источника [0][1][2] @@ -212,20 +375,174 @@ macro E_LIB n } 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_path db '/sys/lib/' -name_tgl db 'tinygl.obj',0 -err_message_found_lib db 'Sorry I cannot load library tinygl.obj',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_message_import db 'Error on load import library tinygl.obj',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_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 ;указатель на буфер изображения + dd 0 ;+4 left,top +.w: dd 0 +.h: dd 0,0,24 ;+16 color,bit in pixel + +align 4 +l_libs_start: + lib_0 l_libs lib_name_0, cur_dir_path, file_name, 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, file_name, 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: - rb 1024 + run_file_70 FileInfoBlock + sc system_colors +align 16 + rb 4096 stacktop: -cur_dir_path: - rb 4096 -library_path: - rb 4096 + cur_dir_path rb 4096 + file_name rb 4096 mem: diff --git a/programs/develop/libraries/TinyGL/asm_fork/export.inc b/programs/develop/libraries/TinyGL/asm_fork/export.inc index 2fede80849..0e01ffd52c 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/export.inc +++ b/programs/develop/libraries/TinyGL/asm_fork/export.inc @@ -1,13 +1,13 @@ ; -; Export functions (103) +; Export functions (115) ; -E_LIB glEnable ;(int code) -E_LIB glDisable ;(int code) +E_LIB glEnable ;(int) +E_LIB glDisable ;(int) -E_LIB glShadeModel ;(int mode) -E_LIB glCullFace ;(int mode) -E_LIB glPolygonMode ;(int face,int mode) +E_LIB glShadeModel ;(int) +E_LIB glCullFace ;(int) +E_LIB glPolygonMode ;(int, int) E_LIB glBegin ;(int type) E_LIB glEnd ;(void) @@ -20,8 +20,8 @@ E_LIB glVertex3f ;(float ,float ,float) E_LIB glVertex3d ;(double ,double ,double) E_LIB glVertex3fv ;(float *) E_LIB glVertex3dv ;(double *) -E_LIB glVertex4f ;(float ,float ,float, float ) -E_LIB glVertex4d ;(double ,double ,double, double ) +E_LIB glVertex4f ;(float ,float ,float, float) +E_LIB glVertex4d ;(double ,double ,double, double) E_LIB glVertex4fv ;(float *) E_LIB glVertex4dv ;(double *) @@ -30,13 +30,13 @@ E_LIB glColor3d ;(double ,double ,double) E_LIB glColor3fv ;(float *) E_LIB glColor3dv ;(double *) E_LIB glColor3ub -E_LIB glColor4f ;(float ,float ,float, float ) -E_LIB glColor4d ;(double ,double ,double, double ) +E_LIB glColor4f ;(float ,float ,float, float) +E_LIB glColor4d ;(double ,double ,double, double) E_LIB glColor4fv ;(float *) E_LIB glColor4dv ;(double *) -E_LIB glNormal3f ;(float ,float ,float) -E_LIB glNormal3d ;(double ,double ,double) +E_LIB glNormal3f ;(float, float, float) +E_LIB glNormal3d ;(double, double, double) E_LIB glNormal3fv ;(float *) E_LIB glNormal3dv ;(double *) @@ -44,16 +44,16 @@ E_LIB glTexCoord1f ;(float) E_LIB glTexCoord1d ;(double) E_LIB glTexCoord1fv ;(float *) E_LIB glTexCoord1dv ;(double *) -E_LIB glTexCoord2f ;(float ,float) -E_LIB glTexCoord2d ;(double ,double) +E_LIB glTexCoord2f ;(float, float) +E_LIB glTexCoord2d ;(double, double) E_LIB glTexCoord2fv ;(float *) E_LIB glTexCoord2dv ;(double *) -E_LIB glTexCoord3f ;(float ,float ,float) -E_LIB glTexCoord3d ;(double ,double ,double) +E_LIB glTexCoord3f ;(float, float, float) +E_LIB glTexCoord3d ;(double, double, double) E_LIB glTexCoord3fv ;(float *) E_LIB glTexCoord3dv ;(double *) -E_LIB glTexCoord4f ;(float ,float ,float, float ) -E_LIB glTexCoord4d ;(double ,double ,double, double ) +E_LIB glTexCoord4f ;(float, float, float, float) +E_LIB glTexCoord4d ;(double, double, double, double) E_LIB glTexCoord4fv ;(float *) E_LIB glTexCoord4dv ;(double *) @@ -66,95 +66,95 @@ E_LIB glLoadIdentity ;(void) E_LIB glMultMatrixf ;(const float *m) E_LIB glPushMatrix ;(void) E_LIB glPopMatrix ;(void) -E_LIB glRotatef ;(float angle,float x,float y,float z) -E_LIB glTranslatef ;(float x,float y,float z) -E_LIB glScalef ;(float x,float y,float z) +E_LIB glRotatef ;(float, float, float, float) +E_LIB glTranslatef ;(float, float, float) +E_LIB glScalef ;(float, float, float) -E_LIB glViewport ;(int x,int y,int width,int height) -E_LIB glFrustum ;(double left,double right,double bottom,double top, double near_,double far_); +E_LIB glViewport ;(int, int, int, int) +E_LIB glFrustum ;(double, double, double, double, double, double) ; lists -E_LIB glGenLists ;(int range) -E_LIB glIsList ;(unsigned int list) -E_LIB glNewList ;(unsigned int list,int mode) +E_LIB glGenLists ;(int) +E_LIB glIsList ;(unsigned int) +E_LIB glNewList ;(unsigned int, int) E_LIB glEndList ;(void) -E_LIB glCallList ;(unsigned int list) +E_LIB glCallList ;(unsigned int) ; clear -E_LIB glClear ;(int mask) -E_LIB glClearColor ;(float r,float g,float b,float a) -E_LIB glClearDepth ;(double depth) +E_LIB glClear ;(int) +E_LIB glClearColor ;(float, float, float, float) +E_LIB glClearDepth ;(double) ; selection -E_LIB glRenderMode ;(int mode) -E_LIB glSelectBuffer ;(int size,unsigned int *buf) +E_LIB glRenderMode ;(int) +E_LIB glSelectBuffer ;(int, unsigned int *) E_LIB glInitNames ;(void) -E_LIB glPushName ;(unsigned int name) +E_LIB glPushName ;(unsigned int) E_LIB glPopName ;(void) -E_LIB glLoadName ;(unsigned int name) +E_LIB glLoadName ;(unsigned int) ; textures -E_LIB glGenTextures ;(int n, unsigned int *textures) -E_LIB glDeleteTextures ;(int n, const unsigned int *textures) -E_LIB glBindTexture ;(int target,int texture) -E_LIB glTexImage2D ;( int target, int level, int components, int width, int height, int border, int format, int type, void *pixels) -E_LIB glTexEnvi ;(int target,int pname,int param) -E_LIB glTexParameteri ;(int target,int pname,int param) -E_LIB glPixelStorei ;(int pname,int param) +E_LIB glGenTextures ;(int, unsigned int *) +E_LIB glDeleteTextures ;(int, const unsigned int *) +E_LIB glBindTexture ;(int, int) +E_LIB glTexImage2D ;(int, int, int, int, int, int, int, int, void *) +E_LIB glTexEnvi ;(int, int, int) +E_LIB glTexParameteri ;(int, int, int) +E_LIB glPixelStorei ;(int, int) ; lighting -E_LIB glMaterialfv ;(int mode,int type,float *v) -E_LIB glMaterialf ;(int mode,int type,float v) -E_LIB glColorMaterial ;(int mode,int type) +E_LIB glMaterialfv ;(int, int, float *) +E_LIB glMaterialf ;(int, int, float) +E_LIB glColorMaterial ;(int, int) -E_LIB glLightfv ;(int light,int type,float *v) -E_LIB glLightf ;(int light,int type,float v) -E_LIB glLightModeli ;(int pname,int param) -E_LIB glLightModelfv ;(int pname,float *param) +E_LIB glLightfv ;(int, int, float *) +E_LIB glLightf ;(int, int, float) +E_LIB glLightModeli ;(int, int) +E_LIB glLightModelfv ;(int, float *) ; misc E_LIB glFlush ;(void) -E_LIB glHint ;(int target,int mode) -E_LIB glGetIntegerv ;(int pname,int *params) -E_LIB glGetFloatv ;(int pname, float *v) -E_LIB glFrontFace ;(int mode) +E_LIB glHint ;(int, int) +E_LIB glGetIntegerv ;(int, int *) +E_LIB glGetFloatv ;(int, float *) +E_LIB glFrontFace ;(int) ; opengl 1.2 arrays E_LIB glEnableClientState ;(GLenum array) E_LIB glDisableClientState ;(GLenum array) -E_LIB glArrayElement ;(GLint i) -E_LIB glDrawArrays ;(mode, first, count) -E_LIB glDrawElements ;(mode, count, type, indices) -E_LIB glVertexPointer ;(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) -E_LIB glColorPointer ;(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) -E_LIB glNormalPointer ;(GLenum type, GLsizei stride, const GLvoid *pointer) -E_LIB glTexCoordPointer ;(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +E_LIB glArrayElement ;(int) +E_LIB glDrawArrays ;(GLenum, int, GLsizei) +E_LIB glDrawElements ;(GLenum, GLsizei, GLenum, const GLvoid *) +E_LIB glVertexPointer ;(int, GLenum, GLsizei, const void *) +E_LIB glColorPointer ;(int, GLenum, GLsizei, const GLvoid *) +E_LIB glNormalPointer ;(GLenum, GLsizei, const GLvoid *) +E_LIB glTexCoordPointer ;(int, GLenum, GLsizei, const GLvoid *) ; opengl 1.2 polygon offset -E_LIB glPolygonOffset ;(GLfloat factor, GLfloat units) +E_LIB glPolygonOffset ;(float, float) ; not implemented, just added to compile -;inline void glPointSize(float) {} -;inline void glLineWidth(float) {} -;inline void glDeleteLists(int, int) {} -;inline void glDepthFunc(int) {} -;inline void glBlendFunc(int, int) {} -;inline void glTexEnvf(int, int, int) {} -;inline void glOrtho(float,float,float,float,float,float){} -;inline void glVertex2i(int,int) {} -;inline void glDepthMask(int) {} -;inline void glFogi(int, int) {} -;inline void glFogfv(int, const float*) {} -;inline void glFogf(int, float) {} -;inline void glRasterPos2f(float, float) {} -;inline void glPolygonStipple(void*) {} -;inline void glTexParameterf(int, int, int) {}; +;E_LIB glPointSize(float) +;E_LIB glLineWidth(float) +;E_LIB glDeleteLists(int, int) +;E_LIB glDepthFunc(int) +;E_LIB glBlendFunc(int, int) +;E_LIB glTexEnvf(int, int, int) +;E_LIB glOrtho(float, float, float, float, float, float) +;E_LIB glVertex2i(int, int) +;E_LIB glDepthMask(int) +;E_LIB glFogi(int, int) +;E_LIB glFogfv(int, const float*) +;E_LIB glFogf(int, float) +;E_LIB glRasterPos2f(float, float) +;E_LIB glPolygonStipple(void*) +;E_LIB glTexParameterf(int, int, int) ; non compatible functions -E_LIB glDebug ;(int mode) +E_LIB glDebug ;(int) -E_LIB glInit ;(void *zbuffer) +E_LIB glInit ;(void *) E_LIB glClose ;(void) ; @@ -166,7 +166,8 @@ E_LIB gluDeleteQuadric E_LIB gluQuadricDrawStyle E_LIB gluQuadricOrientation E_LIB gluQuadricTexture -E_LIB gluSphere +E_LIB gluCylinder ;(GLUquadricObj, double, double, double, int, int) +E_LIB gluSphere ;(GLUquadricObj, float, int, int) ; ; Kolibri OS functions diff --git a/programs/develop/libraries/TinyGL/asm_fork/glu.asm b/programs/develop/libraries/TinyGL/asm_fork/glu.asm index 82521f3e9e..0f4ff83f63 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/glu.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/glu.asm @@ -127,9 +127,440 @@ align 4 ret endp -;void gluCylinder(GLUquadricObj *qobj, GLdouble baseRadius, GLdouble topRadius, GLdouble height, GLint slices, GLint stacks ) -;{ -;} +align 16 +proc gluCylinder qobj:dword, baseRadius:dword, topRadius:dword, height:dword,\ + slices:dword, stacks:dword +locals + da dq ? ;double + r dq ? ;double + dr dq ? ;double + dz dq ? ;double + x dd ? ;float + y dd ? ;float + z dd ? ;float + nz dd ? ;float + nsign dd ? ;float + i dd ? ;GLint + j dd ? ;GLint + du dd ? ;float + dv dd ? ;float + tcx dd ? ;float + tcy dd ? ;float + x2 dd ? ;float + y2 dd ? ;float +endl +pushad + mov edx,[qobj] + fld1 + cmp dword[edx+offs_qobj_Orientation],GLU_INSIDE + jne @f + fchs + @@: + fstp dword[nsign] + + fldpi + fadd st0,st0 + fidiv dword[slices] + fstp qword[da] ;da = 2.0*M_PI / slices + mov ebx,[topRadius] + fld qword[ebx] + mov ecx,[baseRadius] + fsub qword[ecx] + fld st0 ;copy: topRadius-baseRadius + fidiv dword[stacks] + fstp qword[dr] ;dr = (topRadius-baseRadius) / stacks + mov eax,[height] + fld qword[eax] + fidiv dword[stacks] + fstp qword[dz] ;dz = height / stacks + fchs + fdiv qword[eax] + fstp dword[nz] ;nz = (baseRadius-topRadius) / height ; Z component of normal vectors + + cmp dword[edx+offs_qobj_DrawStyle],GLU_POINT + jne .else0 + stdcall glBegin,GL_POINTS + mov ebx,[slices] + mov dword[i],0 +align 4 + .cycle_0: ;for (i=0;i0.0) + fld st0 + fmul dword[nz] + fstp dword[esp-4] + fld st0 + fmul dword[y] + fstp dword[esp-8] + fmul dword[x] + fstp dword[esp-12] + sub esp,12 + call glNormal3f ;x1*nsign, y1*nsign, nz*nsign + cmp dword[edx+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag) + je @f + stdcall glTexCoord2f, [tcx],[tcy] + @@: + mov eax,[z] + mov [esp-4],eax + fld qword[r] + fld st0 + fmul dword[y] + fstp dword[esp-8] + fmul dword[x] + fstp dword[esp-12] + sub esp,12 + call glVertex3f ;x1*r, y1*r, z + fld dword[nsign] + fld st0 + fmul dword[nz] + fstp dword[esp-4] + fld st0 + fmul dword[y2] + fstp dword[esp-8] + fmul dword[x2] + fstp dword[esp-12] + sub esp,12 + call glNormal3f ;x2*nsign, y2*nsign, nz*nsign + cmp dword[edx+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag) + je @f + push dword[tcy] + fld dword[tcx] + fadd dword[du] + fstp dword[esp-4] + sub esp,4 + call glTexCoord2f ;tcx+du, tcy + @@: + mov eax,[z] + mov [esp-4],eax + fld qword[r] + fld st0 + fmul dword[y2] + fstp dword[esp-8] + fmul dword[x2] + fstp dword[esp-12] + sub esp,12 + call glVertex3f ;x2*r, y2*r, z + jmp .else3_end + .else3: + fld st0 + fmul dword[nz] + fstp dword[esp-4] + fld st0 + fmul dword[y2] + fstp dword[esp-8] + fmul dword[x2] + fstp dword[esp-12] + sub esp,12 + call glNormal3f ;x2*nsign, y2*nsign, nz*nsign + cmp dword[edx+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag) + je @f + stdcall glTexCoord2f, [tcx],[tcy] + @@: + mov eax,[z] + mov [esp-4],eax + fld qword[r] + fld st0 + fmul dword[y2] + fstp dword[esp-8] + fmul dword[x2] + fstp dword[esp-12] + sub esp,12 + call glVertex3f ;x2*r, y2*r, z + fld dword[nsign] + fld st0 + fmul dword[nz] + fstp dword[esp-4] + fld st0 + fmul dword[y] + fstp dword[esp-8] + fmul dword[x] + fstp dword[esp-12] + sub esp,12 + call glNormal3f ;x1*nsign, y1*nsign, nz*nsign + cmp dword[edx+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag) + je @f + push dword[tcy] + fld dword[tcx] + fadd dword[du] + fstp dword[esp-4] + sub esp,4 + call glTexCoord2f ;tcx+du, tcy + @@: + mov eax,[z] + mov [esp-4],eax + fld qword[r] + fld st0 + fmul dword[y] + fstp dword[esp-8] + fmul dword[x] + fstp dword[esp-12] + sub esp,12 + call glVertex3f ;x1*r, y1*r, z + .else3_end: + fld dword[z] + fadd qword[dz] + fstp dword[z] ;z += dz + fld qword[r] + fadd qword[dr] + fstp qword[r] ;r += dr + fld dword[tcy] + fadd dword[dv] + fstp dword[tcy] ;tcy += dv + dec ecx + jnz .cycle_8 + call glEnd + fld dword[tcx] + fadd dword[du] + fstp dword[tcx] ;tcx += du + jmp .cycle_7 +align 4 + .cycle_7_end: + .end_f: +popad + ret +endp ; Disk (adapted from Mesa)