tinygl: fix struct ZBuffer, clean code

git-svn-id: svn://kolibrios.org@8174 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA
2020-11-11 20:32:44 +00:00
parent 5a440ca960
commit f5228c717f
7 changed files with 382 additions and 365 deletions

View File

@@ -1,5 +1,5 @@
use32
org 0x0
org 0
db 'MENUET01'
dd 1,start,i_end,mem,stacktop,0,cur_dir_path
@@ -8,6 +8,7 @@ include '../../../../../macros.inc'
include '../../../../../KOSfuncs.inc'
include '../../../../../load_img.inc'
include '../opengl_const.inc'
include '../zbuffer.inc'
include '../../../../../develop/info3ds/info_fun_float.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
@@ -16,7 +17,11 @@ align 4
image_data_toolbar dd 0
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
offs_zbuf_pbuf equ 24 ;const. from 'zbuffer.inc'
;Макрос для параметров типа double (8 байт)
macro glpush GLDoubleVar {
push dword[GLDoubleVar+4]
push dword[GLDoubleVar]
}
align 4
start:
@@ -38,7 +43,7 @@ load_libraries l_libs_start,l_libs_end
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
stdcall [glEnable], GL_DEPTH_TEST
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
stdcall [gluNewQuadric]
call [gluNewQuadric]
mov [qObj],eax
stdcall [glClearColor], 0.25,0.25,0.25,0.0
@@ -46,7 +51,7 @@ load_libraries l_libs_start,l_libs_end
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
mov eax,[eax] ;eax -> ZBuffer
mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf
mov eax,[eax+ZBuffer.pbuf]
mov dword[buf_ogl],eax
load_image_file 'font8x9.bmp', image_data_toolbar, buf_1.w,buf_1.h
@@ -96,7 +101,7 @@ draw_window:
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,(125 shl 16)+5 ;масштаб -
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
mcall SF_REDRAW,SSF_END_DRAW
popad
ret
@@ -130,7 +135,8 @@ key:
mov byte[txt_angle_y.v],0
stdcall str_cat, txt_angle_y.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
jmp still
@@:
cmp ah,177 ;Down
jne @f
@@ -144,7 +150,8 @@ key:
mov byte[txt_angle_y.v],0
stdcall str_cat, txt_angle_y.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
jmp still
@@:
cmp ah,176 ;Left
jne @f
@@ -158,7 +165,8 @@ key:
mov byte[txt_angle_z.v],0
stdcall str_cat, txt_angle_z.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
jmp still
@@:
cmp ah,179 ;Right
jne @f
@@ -172,7 +180,8 @@ key:
mov byte[txt_angle_z.v],0
stdcall str_cat, txt_angle_z.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
;jmp still
@@:
jmp still
@@ -216,21 +225,21 @@ align 4
but_st_point:
stdcall [gluQuadricDrawStyle], [qObj],GLU_POINT
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
but_st_line:
stdcall [gluQuadricDrawStyle], [qObj],GLU_LINE
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
but_st_face:
stdcall [gluQuadricDrawStyle], [qObj],GLU_FILL
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
@@ -253,7 +262,7 @@ but_zoom_p:
mov byte[txt_scale.v],0
stdcall str_cat, txt_scale.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
@@ -276,16 +285,14 @@ but_zoom_m:
mov byte[txt_scale.v],0
stdcall str_cat, txt_scale.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
caption db 'Test gluCylinder, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
align 4
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
align 4
rad1 dq 1.0
rad2 dq 0.55
rad3 dq 0.15
@@ -296,7 +303,7 @@ align 4
draw_3d:
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
stdcall [glPushMatrix]
call [glPushMatrix]
call SetLight
stdcall [glTranslatef], 0.0,0.0,0.5
@@ -316,7 +323,7 @@ stdcall [glPushMatrix]
stdcall [glColor3f], 0.0, 0.0, 1.0
stdcall [glTranslatef], 3.2,0.0,0.0
stdcall [gluCylinder], [qObj], rad2,rad3,hei2, 16,8
stdcall [glPopMatrix]
call [glPopMatrix]
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
@@ -341,8 +348,6 @@ SetLight:
stdcall [glEnable],GL_LIGHT0
ret
qObj dd 0
scale dd 0.4 ;начальный масштаб
sc_delt dd 0.05 ;изменение масштаба при нажатии
sc_min dd 0.1 ;минимальный масштаб
@@ -432,49 +437,51 @@ import_buf2d:
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_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_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
; 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
; img_convert dd aimg_convert
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_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_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
; 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
; aimg_convert db 'img_convert',0
;--------------------------------------------------
system_dir_0 db '/sys/lib/'
@@ -483,14 +490,14 @@ 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
err_msg_found_lib_0 db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
err_msg_found_lib_1 db 'Sorry I cannot load library ',39,'buf2d.obj',39,'" -tE',0
err_msg_found_lib_2 db 'Sorry I cannot load library ',39,'libimg.obj',39,'" -tE',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
head_f_l db '"System error',0
err_msg_import_0 db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
err_msg_import_1 db 'Error on load import library ',39,'buf2d.obj',39,'" -tE',0
err_msg_import_2 db 'Error on load import library ',39,'libimg.obj',39,'" -tE',0
;--------------------------------------------------
txt_scale:
@@ -538,6 +545,8 @@ l_libs_end:
align 4
i_end:
ctx1 rb 28 ;sizeof.TinyGLContext = 28
qObj dd 0
run_file_70 FileInfoBlock
sc system_colors
align 16

View File

@@ -1,5 +1,5 @@
use32
org 0x0
org 0
db 'MENUET01'
dd 1,start,i_end,mem,stacktop,0,cur_dir_path
@@ -8,6 +8,7 @@ include '../../../../../macros.inc'
include '../../../../../KOSfuncs.inc'
include '../../../../../load_img.inc'
include '../opengl_const.inc'
include '../zbuffer.inc'
include '../../../../../develop/info3ds/info_fun_float.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
@@ -16,7 +17,11 @@ align 4
image_data_toolbar dd 0
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
offs_zbuf_pbuf equ 24 ;const. from 'zbuffer.inc'
;Макрос для параметров типа double (8 байт)
macro glpush GLDoubleVar {
push dword[GLDoubleVar+4]
push dword[GLDoubleVar]
}
align 4
start:
@@ -38,7 +43,7 @@ load_libraries l_libs_start,l_libs_end
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
stdcall [glEnable], GL_DEPTH_TEST
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
stdcall [gluNewQuadric]
call [gluNewQuadric]
mov [qObj],eax
stdcall [glClearColor], 0.25,0.25,0.25,0.0
@@ -46,7 +51,7 @@ load_libraries l_libs_start,l_libs_end
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
mov eax,[eax] ;eax -> ZBuffer
mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf
mov eax,[eax+ZBuffer.pbuf]
mov dword[buf_ogl],eax
load_image_file 'font8x9.bmp', image_data_toolbar, buf_1.w,buf_1.h
@@ -96,7 +101,7 @@ draw_window:
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,(125 shl 16)+5 ;масштаб -
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
mcall SF_REDRAW,SSF_END_DRAW
popad
ret
@@ -130,7 +135,8 @@ key:
mov byte[txt_angle_y.v],0
stdcall str_cat, txt_angle_y.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
jmp still
@@:
cmp ah,177 ;Down
jne @f
@@ -144,7 +150,8 @@ key:
mov byte[txt_angle_y.v],0
stdcall str_cat, txt_angle_y.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
jmp still
@@:
cmp ah,176 ;Left
jne @f
@@ -158,7 +165,8 @@ key:
mov byte[txt_angle_z.v],0
stdcall str_cat, txt_angle_z.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
jmp still
@@:
cmp ah,179 ;Right
jne @f
@@ -172,7 +180,8 @@ key:
mov byte[txt_angle_z.v],0
stdcall str_cat, txt_angle_z.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
;jmp still
@@:
jmp still
@@ -216,21 +225,21 @@ align 4
but_st_point:
stdcall [gluQuadricDrawStyle], [qObj],GLU_POINT
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
but_st_line:
stdcall [gluQuadricDrawStyle], [qObj],GLU_LINE
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
but_st_face:
stdcall [gluQuadricDrawStyle], [qObj],GLU_FILL
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
@@ -253,7 +262,7 @@ but_zoom_p:
mov byte[txt_scale.v],0
stdcall str_cat, txt_scale.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
@@ -276,21 +285,18 @@ but_zoom_m:
mov byte[txt_scale.v],0
stdcall str_cat, txt_scale.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
caption db 'Test gluSphere, [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]
call [glPushMatrix]
call SetLight
stdcall [glTranslatef], 0.0,0.0,0.5
@@ -308,7 +314,7 @@ stdcall [glPushMatrix]
stdcall [glColor3f], 0.0, 0.0, 1.0
stdcall [glTranslatef], 3.2,0.0,0.0
stdcall [gluSphere], [qObj], 0.55, 16,16
stdcall [glPopMatrix]
call [glPopMatrix]
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
@@ -333,8 +339,6 @@ SetLight:
stdcall [glEnable],GL_LIGHT0
ret
qObj dd 0
scale dd 0.4 ;начальный масштаб
sc_delt dd 0.05 ;изменение масштаба при нажатии
sc_min dd 0.1 ;минимальный масштаб
@@ -424,49 +428,51 @@ import_buf2d:
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_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_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
; 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
; img_convert dd aimg_convert
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_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_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
; 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
; aimg_convert db 'img_convert',0
;--------------------------------------------------
system_dir_0 db '/sys/lib/'
@@ -475,14 +481,14 @@ 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
err_msg_found_lib_0 db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
err_msg_found_lib_1 db 'Sorry I cannot load library ',39,'buf2d.obj',39,'" -tE',0
err_msg_found_lib_2 db 'Sorry I cannot load library ',39,'libimg.obj',39,'" -tE',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
head_f_l db '"System error',0
err_msg_import_0 db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
err_msg_import_1 db 'Error on load import library ',39,'buf2d.obj',39,'" -tE',0
err_msg_import_2 db 'Error on load import library ',39,'libimg.obj',39,'" -tE',0
;--------------------------------------------------
txt_scale:
@@ -530,6 +536,8 @@ l_libs_end:
align 4
i_end:
ctx1 rb 28 ;sizeof.TinyGLContext = 28
qObj dd 0
run_file_70 FileInfoBlock
sc system_colors
align 16

View File

@@ -8,16 +8,21 @@ include '../../../../../macros.inc'
include '../../../../../KOSfuncs.inc'
include '../../../../../load_img.inc'
include '../opengl_const.inc'
include '../zbuffer.inc'
include '../../../../../develop/info3ds/info_fun_float.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
;Макрос для параметров типа double (8 байт)
macro glpush GLDoubleVar {
push dword[GLDoubleVar+4]
push dword[GLDoubleVar]
}
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_libraries l_libs_start,l_libs_end
@@ -38,7 +43,7 @@ load_libraries l_libs_start,l_libs_end
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
stdcall [glEnable], GL_DEPTH_TEST
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
stdcall [gluNewQuadric]
call [gluNewQuadric]
mov [qObj],eax
stdcall [gluQuadricTexture], eax,GL_TRUE
@@ -47,7 +52,7 @@ load_libraries l_libs_start,l_libs_end
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
mov eax,[eax] ;eax -> ZBuffer
mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf
mov eax,[eax+ZBuffer.pbuf]
mov dword[buf_ogl],eax
load_image_file 'font8x9.bmp', image_data_toolbar, buf_1.w,buf_1.h
@@ -290,7 +295,7 @@ align 4
draw_3d:
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
stdcall [glPushMatrix]
call [glPushMatrix]
stdcall [glTranslatef], 0.0,0.0,0.5
stdcall [glScalef], [scale], [scale], [scale]
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
@@ -375,9 +380,9 @@ jne @f
stdcall [glTexCoord2f], 0.0f, 1.0f
stdcall [glVertex3f], -1.0f, 1.0f, -1.0f ; Верх лево
stdcall [glEnd]
call [glEnd]
@@:
stdcall [glPopMatrix]
call [glPopMatrix]
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
@@ -473,49 +478,51 @@ import_buf2d:
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_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_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
; 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
; img_convert dd aimg_convert
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_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_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
; 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
; aimg_convert db 'img_convert',0
;--------------------------------------------------
system_dir_0 db '/sys/lib/'
@@ -579,8 +586,7 @@ l_libs_end:
align 4
i_end:
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
ctx1 rb 28 ;sizeof.TinyGLContext = 28
dr_figure dd 0
qObj dd 0
TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.)

View File

@@ -8,16 +8,21 @@ include '../../../../../macros.inc'
include '../../../../../KOSfuncs.inc'
include '../../../../../load_img.inc'
include '../opengl_const.inc'
include '../zbuffer.inc'
include '../../../../../develop/info3ds/info_fun_float.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
;Макрос для параметров типа double (8 байт)
macro glpush GLDoubleVar {
push dword[GLDoubleVar+4]
push dword[GLDoubleVar]
}
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_libraries l_libs_start,l_libs_end
@@ -38,7 +43,7 @@ load_libraries l_libs_start,l_libs_end
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
stdcall [glEnable], GL_DEPTH_TEST
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
stdcall [gluNewQuadric]
call [gluNewQuadric]
mov [qObj],eax
stdcall [gluQuadricTexture], eax,GL_TRUE
@@ -47,7 +52,7 @@ load_libraries l_libs_start,l_libs_end
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
mov eax,[eax] ;eax -> ZBuffer
mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf
mov eax,[eax+ZBuffer.pbuf]
mov dword[buf_ogl],eax
load_image_file 'font8x9.bmp', image_data_toolbar, buf_1.w,buf_1.h
@@ -292,7 +297,7 @@ align 4
draw_3d:
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
stdcall [glPushMatrix]
call [glPushMatrix]
stdcall [glTranslatef], 0.0,0.0,0.5
stdcall [glScalef], [scale], [scale], [scale]
stdcall [glScalef], 1.0, 1.0, 0.1 ;прижимаем сферу, что-бы сразу не вылазила при увеличении
@@ -314,7 +319,7 @@ jne @f
stdcall [gluQuadricDrawStyle], [qObj],GLU_FILL
stdcall [gluSphere], [qObj], 1.0, 64,64
@@:
stdcall [glPopMatrix]
call [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
@@ -403,49 +408,51 @@ import_buf2d:
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_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_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
; 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
; img_convert dd aimg_convert
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_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_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
; 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
; aimg_convert db 'img_convert',0
;--------------------------------------------------
system_dir_0 db '/sys/lib/'
@@ -515,8 +522,7 @@ l_libs_end:
align 4
i_end:
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
ctx1 rb 28 ;sizeof.TinyGLContext = 28
dr_figure dd 0
qObj dd 0
TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.)

View File

@@ -1,5 +1,5 @@
use32
org 0x0
org 0
db 'MENUET01'
dd 1,start,i_end,mem,stacktop,0,cur_dir_path
@@ -8,16 +8,21 @@ include '../../../../../macros.inc'
include '../../../../../KOSfuncs.inc'
include '../../../../../load_img.inc'
include '../opengl_const.inc'
include '../zbuffer.inc'
include '../../../../../develop/info3ds/info_fun_float.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
;Макрос для параметров типа double (8 байт)
macro glpush GLDoubleVar {
push dword[GLDoubleVar+4]
push dword[GLDoubleVar]
}
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_libraries l_libs_start,l_libs_end
@@ -38,7 +43,7 @@ load_libraries l_libs_start,l_libs_end
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
stdcall [glEnable], GL_DEPTH_TEST
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
stdcall [gluNewQuadric]
call [gluNewQuadric]
mov [qObj],eax
stdcall [gluQuadricDrawStyle], eax,GLU_FILL
stdcall [gluQuadricTexture], eax,GL_TRUE
@@ -48,7 +53,7 @@ load_libraries l_libs_start,l_libs_end
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
mov eax,[eax] ;eax -> ZBuffer
mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf
mov eax,[eax+ZBuffer.pbuf]
mov dword[buf_ogl],eax
load_image_file 'font8x9.bmp', image_data_toolbar, buf_1.w,buf_1.h
@@ -109,7 +114,7 @@ draw_window:
add ebx,IMAGE_TOOLBAR_ICON_SIZE
mcall ,,,(35 shl 16)+5 ;масштаб -
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
mcall SF_REDRAW,SSF_END_DRAW
popad
ret
@@ -143,7 +148,7 @@ key:
mov byte[txt_angle_y.v],0
stdcall str_cat, txt_angle_y.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
@@:
cmp ah,179 ;Right
jne @f
@@ -157,7 +162,7 @@ key:
mov byte[txt_angle_y.v],0
stdcall str_cat, txt_angle_y.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
@@:
cmp ah,178 ;Up
jne @f
@@ -171,7 +176,7 @@ key:
mov byte[txt_angle_x.v],0
stdcall str_cat, txt_angle_x.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
@@:
cmp ah,177 ;Down
jne @f
@@ -185,7 +190,7 @@ key:
mov byte[txt_angle_x.v],0
stdcall str_cat, txt_angle_x.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
@@:
jmp still
@@ -230,7 +235,7 @@ but_zoom_p:
mov byte[txt_scale.v],0
stdcall str_cat, txt_scale.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [kosglSwapBuffers]
ret
align 4
@@ -253,21 +258,17 @@ but_zoom_m:
mov byte[txt_scale.v],0
stdcall str_cat, txt_scale.v,Data_String
call draw_3d
stdcall [kosglSwapBuffers]
call [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]
call [glPushMatrix]
stdcall [glScalef], [scale], [scale], [scale]
stdcall [glScalef], 1.0, 1.0, 0.1 ;прижимаем сферу, что-бы сразу не вылазила при увеличении
stdcall [glRotatef], [angle_y],0.0,1.0,0.0
@@ -275,19 +276,13 @@ stdcall [glPushMatrix]
; рисование панорамы
stdcall [gluSphere], [qObj], 1.0, 64,64
stdcall [glPopMatrix]
call [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
qObj dd 0
TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.)
texture dd 0 ;указатель на память с текстурой
text_w dd 0
text_h dd 0
scale dd 1.5 ;начальный масштаб
sc_delt dd 0.05 ;изменение масштаба при нажатии
sc_min dd 0.95 ;минимальный масштаб
@@ -370,49 +365,51 @@ import_buf2d:
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_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_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
; 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
; img_convert dd aimg_convert
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_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_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
; 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
; aimg_convert db 'img_convert',0
;--------------------------------------------------
system_dir_0 db '/sys/lib/'
@@ -421,14 +418,14 @@ 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
err_msg_found_lib_0 db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
err_msg_found_lib_1 db 'Sorry I cannot load library ',39,'buf2d.obj',39,'" -tE',0
err_msg_found_lib_2 db 'Sorry I cannot load library ',39,'libimg.obj',39,'" -tE',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
head_f_l db '"System error',0
err_msg_import_0 db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
err_msg_import_1 db 'Error on load import library ',39,'buf2d.obj',39,'" -tE',0
err_msg_import_2 db 'Error on load import library ',39,'libimg.obj',39,'" -tE',0
;--------------------------------------------------
txt_scale:
@@ -482,6 +479,12 @@ l_libs_end:
align 4
i_end:
ctx1 rb 28 ;sizeof.TinyGLContext = 28
qObj dd 0
TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.)
texture dd 0 ;указатель на память с текстурой
text_w dd 0
text_h dd 0
run_file_70 FileInfoBlock
sc system_colors
align 16

View File

@@ -63,7 +63,6 @@ struct ZBuffer
xsize dd ? ;int
ysize dd ? ;int
linesize dd ? ;int ;line size, in bytes
dd ? ;fix old error offset
mode dd ? ;int
zbuf dd ? ;*unsigned short