forked from KolibriOS/kolibrios
TinyGL: Added gluDisk. Fixed args in gluCylinder and gluSphere (#223)
TinyGL: - Fixed setting of `GL_FRONT_AND_BACK` mode; - Fixed setting of `GL_SPOT_DIRECTION` angle; - Optimization of drawing triangles and lines; - Input parameters are adjusted to the OpenGL standard in `gluCylinder` and `gluSphere` functions; - Added `gluDisk` function (the gluDisk function draws a disk-shaped quadric figure); - Optimize function `calc_buf`. Flag: - Added lighting. info3ds, info3ds_u, test_glu0, test_glu1, test_glu2, textures0, textures1, textures2: - Updated programs using `gluCylinder` and `gluSphere`. Reviewed-on: KolibriOS/kolibrios#223 Reviewed-by: Ivan B <dunkaist@noreply.localhost> Reviewed-by: Max Logaev <maxlogaev@proton.me> Co-authored-by: IgorA <aie85playm@gmail.com> Co-committed-by: IgorA <aie85playm@gmail.com>
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
; Test glu0 - gluSphere functionality testing
|
||||
; Copyright (C) 2014-2025 KolibriOS team
|
||||
|
||||
use32
|
||||
org 0
|
||||
db 'MENUET01'
|
||||
@@ -8,6 +12,7 @@ include '../../../../../macros.inc'
|
||||
include '../../../../../KOSfuncs.inc'
|
||||
include '../../../../../load_lib.mac'
|
||||
include '../../../../../dll.inc'
|
||||
include '../kosgl.inc'
|
||||
include '../opengl_const.inc'
|
||||
|
||||
@use_library
|
||||
@@ -131,9 +136,6 @@ button:
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
|
||||
align 4
|
||||
caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
draw_3d:
|
||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||
@@ -145,20 +147,33 @@ call [glPushMatrix]
|
||||
|
||||
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, 16,16
|
||||
push 16
|
||||
push 16
|
||||
glpush rad1
|
||||
stdcall [gluSphere], [qObj]
|
||||
|
||||
stdcall [glColor3f], 1.0, 0.0, 0.0
|
||||
stdcall [glTranslatef], -1.6,0.0,0.0
|
||||
stdcall [gluSphere], [qObj], 0.55, 8,8
|
||||
push 8
|
||||
push 8
|
||||
glpush rad2
|
||||
stdcall [gluSphere], [qObj]
|
||||
|
||||
stdcall [glColor3f], 0.0, 0.0, 1.0
|
||||
stdcall [glTranslatef], 3.2,0.0,0.0
|
||||
stdcall [gluSphere], [qObj], 0.55, 8,8
|
||||
push 8
|
||||
push 8
|
||||
glpush rad2
|
||||
stdcall [gluSphere], [qObj]
|
||||
call [glPopMatrix]
|
||||
ret
|
||||
|
||||
align 4
|
||||
qObj dd 0
|
||||
caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
rad1 dq 1.0
|
||||
rad2 dq 0.55
|
||||
|
||||
scale dd 0.4
|
||||
delt_sc dd 0.05
|
||||
@@ -172,13 +187,17 @@ import_tinygl:
|
||||
|
||||
macro E_LIB n
|
||||
{
|
||||
if defined sz_#n
|
||||
n dd sz_#n
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
if used n
|
||||
sz_#n db `n,0
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
|
||||
@@ -189,7 +208,8 @@ name_tgl db 'tinygl.obj',0
|
||||
|
||||
align 16
|
||||
i_end:
|
||||
ctx1 rb 28 ;sizeof.TinyGLContext = 28
|
||||
ctx1 TinyGLContext
|
||||
qObj dd 0
|
||||
cur_dir_path rb 4096
|
||||
library_path rb 4096
|
||||
rb 2048
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
; Test glu1 - gluCylinder and gluDisk functionality testing
|
||||
; Copyright (C) 2014-2025 KolibriOS team
|
||||
|
||||
use32
|
||||
org 0
|
||||
db 'MENUET01'
|
||||
@@ -8,24 +12,24 @@ include '../../../../../macros.inc'
|
||||
include '../../../../../KOSfuncs.inc'
|
||||
include '../../../../../load_img.inc'
|
||||
include '../../../../../load_lib.mac'
|
||||
include '../kosgl.inc'
|
||||
include '../opengl_const.inc'
|
||||
include '../zbuffer.inc'
|
||||
include '../../../../../develop/info3ds/info_fun_float.inc'
|
||||
|
||||
3d_wnd_l equ 0 ;tinygl buffer left indent
|
||||
3d_wnd_t equ 30 ;tinygl buffer top indent
|
||||
3d_wnd_w equ 500
|
||||
3d_wnd_h equ 400
|
||||
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
|
||||
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
|
||||
|
||||
;Макрос для параметров типа double (8 байт)
|
||||
macro glpush GLDoubleVar {
|
||||
push dword[GLDoubleVar+4]
|
||||
push dword[GLDoubleVar]
|
||||
}
|
||||
|
||||
align 4
|
||||
start:
|
||||
load_libraries l_libs_start,l_libs_end
|
||||
;проверка на сколько удачно загузились библиотеки
|
||||
;checking how successfully the libraries were loaded
|
||||
mov ebp,lib_0
|
||||
.test_lib_open:
|
||||
cmp dword [ebp+ll_struc_size-4],0
|
||||
@@ -39,16 +43,24 @@ load_libraries l_libs_start,l_libs_end
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
|
||||
mcall SF_SET_EVENTS_MASK,0x27
|
||||
|
||||
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
finit
|
||||
fild dword[buf_ogl.w]
|
||||
fdiv dword[fl_180]
|
||||
fstp dword[angle_dzm]
|
||||
fild dword[buf_ogl.h]
|
||||
fdiv dword[fl_180]
|
||||
fstp dword[angle_dym]
|
||||
|
||||
stdcall [kosglMakeCurrent], 3d_wnd_l,3d_wnd_t,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [glEnable], GL_DEPTH_TEST
|
||||
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
||||
stdcall [glEnable], GL_NORMALIZE ;normals of the same size to avoid artifacts
|
||||
call [gluNewQuadric]
|
||||
mov [qObj],eax
|
||||
|
||||
stdcall [glClearColor], 0.25,0.25,0.25,0.0
|
||||
stdcall [glShadeModel], GL_SMOOTH
|
||||
|
||||
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
|
||||
mov eax,[ctx1.gl_context]
|
||||
mov eax,[eax] ;eax -> ZBuffer
|
||||
mov eax,[eax+ZBuffer.pbuf]
|
||||
mov dword[buf_ogl],eax
|
||||
@@ -60,6 +72,14 @@ load_libraries l_libs_start,l_libs_end
|
||||
stdcall [buf2d_convert_text_matrix], buf_1
|
||||
|
||||
load_image_file 'toolb_1.png', image_data_toolbar
|
||||
|
||||
fld dword[scale]
|
||||
stdcall update_number, txt_scale.v
|
||||
fld dword[angle_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
fld dword[angle_z]
|
||||
stdcall update_number, txt_angle_z.v
|
||||
|
||||
call SetLight
|
||||
call draw_3d
|
||||
|
||||
@@ -76,13 +96,24 @@ still:
|
||||
jz key
|
||||
cmp al,EV_BUTTON
|
||||
jz button
|
||||
cmp al,EV_MOUSE
|
||||
jne still
|
||||
call mouse
|
||||
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
|
||||
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
|
||||
mov ebx,[buf_ogl.w]
|
||||
add ebx,(50 shl 16)+9
|
||||
mov ecx,[buf_ogl.h]
|
||||
add ecx,(30 shl 16)+4
|
||||
add ecx,eax
|
||||
add cx,[buf_ogl.t]
|
||||
mcall SF_CREATE_WINDOW,,,0x33ffffff,,caption
|
||||
|
||||
mov esi,[sc.work_button]
|
||||
mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;вершины вкл.
|
||||
@@ -129,11 +160,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
jmp still
|
||||
@@ -144,11 +171,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
jmp still
|
||||
@@ -159,11 +182,7 @@ key:
|
||||
fld dword[angle_z]
|
||||
fadd dword[delt_size]
|
||||
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
|
||||
stdcall update_number, txt_angle_z.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
jmp still
|
||||
@@ -174,11 +193,7 @@ key:
|
||||
fld dword[angle_z]
|
||||
fsub dword[delt_size]
|
||||
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
|
||||
stdcall update_number, txt_angle_z.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
;jmp still
|
||||
@@ -221,6 +236,104 @@ button:
|
||||
stdcall mem.Free,[image_data_toolbar]
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
align 4
|
||||
mouse:
|
||||
push eax ebx
|
||||
mcall SF_MOUSE_GET,SSF_BUTTON_EXT
|
||||
bt eax,0
|
||||
jnc .end_m
|
||||
;mouse l. but. move
|
||||
cmp dword[mouse_drag],1
|
||||
jne .end_m
|
||||
|
||||
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
|
||||
mov ebx,eax
|
||||
sar ebx,16 ;mouse.x
|
||||
cmp ebx,3d_wnd_l
|
||||
jg @f
|
||||
mov ebx,3d_wnd_l
|
||||
@@:
|
||||
sub ebx,3d_wnd_l
|
||||
cmp ebx,3d_wnd_w
|
||||
jle @f
|
||||
mov ebx,3d_wnd_w
|
||||
@@:
|
||||
movsx eax,ax ;mouse.y
|
||||
cmp eax,3d_wnd_t
|
||||
jg @f
|
||||
mov eax,3d_wnd_t
|
||||
@@:
|
||||
sub eax,3d_wnd_t
|
||||
cmp eax,3d_wnd_h
|
||||
jle @f
|
||||
mov eax,3d_wnd_h
|
||||
@@:
|
||||
finit
|
||||
fild dword[mouse_y]
|
||||
mov [mouse_y],eax
|
||||
fisub dword[mouse_y]
|
||||
fdiv dword[angle_dzm] ;if the cursor moves along the y-axis (up or down)
|
||||
fadd dword[angle_z]
|
||||
fst dword[angle_z]
|
||||
stdcall update_number, txt_angle_z.v
|
||||
|
||||
fild dword[mouse_x]
|
||||
mov [mouse_x],ebx
|
||||
fisub dword[mouse_x]
|
||||
fdiv dword[angle_dym] ;if the cursor moves along the z-axis (left or right)
|
||||
fadd dword[angle_y]
|
||||
fst dword[angle_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
jmp .end_d
|
||||
.end_m:
|
||||
bt eax,16
|
||||
jnc @f
|
||||
;mouse l. but. up
|
||||
mov dword[mouse_drag],0
|
||||
jmp .end_d
|
||||
@@:
|
||||
bt eax,8
|
||||
jnc .end_d
|
||||
;mouse l. but. press
|
||||
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
|
||||
mov ebx,eax
|
||||
sar ebx,16 ;mouse.x
|
||||
cmp ebx,3d_wnd_l
|
||||
jl .end_d
|
||||
sub ebx,3d_wnd_l
|
||||
cmp ebx,3d_wnd_w
|
||||
jg .end_d
|
||||
movsx eax,ax ;mouse.y
|
||||
cmp eax,3d_wnd_t
|
||||
jl .end_d
|
||||
sub eax,3d_wnd_t
|
||||
cmp eax,3d_wnd_h
|
||||
jg .end_d
|
||||
mov dword[mouse_drag],1
|
||||
mov dword[mouse_x],ebx
|
||||
mov dword[mouse_y],eax
|
||||
.end_d:
|
||||
|
||||
pop ebx eax
|
||||
ret
|
||||
|
||||
;input:
|
||||
; st0 - number
|
||||
; txt_addr - pointer to text buffer
|
||||
align 4
|
||||
proc update_number uses eax, txt_addr:dword
|
||||
mov word[NumberSymbolsAD],3
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov eax,[txt_addr]
|
||||
mov byte[eax],0
|
||||
stdcall str_cat, eax,Data_String
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
but_st_point:
|
||||
stdcall [gluQuadricDrawStyle], [qObj],GLU_POINT
|
||||
@@ -256,11 +369,7 @@ but_zoom_p:
|
||||
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
|
||||
stdcall update_number, txt_scale.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
ret
|
||||
@@ -279,26 +388,12 @@ but_zoom_m:
|
||||
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
|
||||
stdcall update_number, txt_scale.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
caption db 'Test gluCylinder, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
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 ;очистим буфер цвета и глубины
|
||||
@@ -310,15 +405,37 @@ call [glPushMatrix]
|
||||
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
||||
stdcall [glRotatef], [angle_y],0.0,1.0,0.0
|
||||
stdcall [glTranslatef], 0.0,0.0,-1.0 ;опускаем цилинды вниз
|
||||
stdcall [gluCylinder], [qObj], rad1,rad1,hei1, 32,8
|
||||
push 8
|
||||
push 32
|
||||
glpush hei1
|
||||
glpush rad1
|
||||
glpush rad1
|
||||
stdcall [gluCylinder], [qObj]
|
||||
|
||||
stdcall [glTranslatef], 0.0,0.0,2.0
|
||||
push 4
|
||||
push 32
|
||||
glpush rad1
|
||||
glpush rad3
|
||||
stdcall [gluDisk], [qObj]
|
||||
|
||||
stdcall [glColor3f], 1.0, 0.0, 0.0
|
||||
stdcall [glTranslatef], -1.6,0.0,0.0
|
||||
stdcall [gluCylinder], [qObj], rad2,rad3,hei2, 16,8
|
||||
stdcall [glTranslatef], -1.6,0.0,-2.0
|
||||
push 8
|
||||
push 16
|
||||
glpush hei2
|
||||
glpush rad3
|
||||
glpush rad2
|
||||
stdcall [gluCylinder], [qObj]
|
||||
|
||||
stdcall [glColor3f], 0.0, 0.0, 1.0
|
||||
stdcall [glTranslatef], 3.2,0.0,0.0
|
||||
stdcall [gluCylinder], [qObj], rad2,rad3,hei2, 16,8
|
||||
push 8
|
||||
push 16
|
||||
glpush hei2
|
||||
glpush rad3
|
||||
glpush rad2
|
||||
stdcall [gluCylinder], [qObj]
|
||||
call [glPopMatrix]
|
||||
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_scale,5,5,0xffff00
|
||||
@@ -344,10 +461,22 @@ SetLight:
|
||||
stdcall [glEnable],GL_LIGHT0
|
||||
ret
|
||||
|
||||
scale dd 0.4 ;начальный масштаб
|
||||
sc_delt dd 0.05 ;изменение масштаба при нажатии
|
||||
sc_min dd 0.1 ;минимальный масштаб
|
||||
sc_max dd 1.1 ;максимальный масштаб
|
||||
align 4
|
||||
caption db 'Test gluCylinder and gluDisk, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
rad1 dq 1.0
|
||||
rad2 dq 0.55
|
||||
rad3 dq 0.15
|
||||
hei1 dq 2.0 ;высота цилиндра
|
||||
hei2 dq 1.25
|
||||
|
||||
fl_180 dd 180.0
|
||||
|
||||
scale dd 0.4 ;initial scale
|
||||
sc_delt dd 0.05 ;zoom on click
|
||||
sc_min dd 0.1 ;minimum scale
|
||||
sc_max dd 1.1 ;maximum scale
|
||||
angle_z dd -45.0
|
||||
angle_y dd -150.0
|
||||
delt_size dd 3.0
|
||||
@@ -366,13 +495,17 @@ import_tinygl:
|
||||
|
||||
macro E_LIB n
|
||||
{
|
||||
if defined sz_#n
|
||||
n dd sz_#n
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
if used n
|
||||
sz_#n db `n,0
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
|
||||
@@ -490,28 +623,23 @@ lib_name_2 db 'libimg.obj',0
|
||||
|
||||
txt_scale:
|
||||
db 'Scale: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_z:
|
||||
db 'Rotate z: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_y:
|
||||
db 'Rotate y: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
align 4
|
||||
buf_ogl:
|
||||
dd 0 ;указатель на буфер изображения
|
||||
dw 10,10 ;+4 left,top
|
||||
.w: dd 400
|
||||
.h: dd 350
|
||||
dw 3d_wnd_l ;+4 left
|
||||
.t: dw 3d_wnd_t ;+6 top
|
||||
.w: dd 3d_wnd_w
|
||||
.h: dd 3d_wnd_h
|
||||
dd 0,24 ;+16 color,bit in pixel
|
||||
|
||||
align 4
|
||||
@@ -530,9 +658,14 @@ l_libs_end:
|
||||
|
||||
align 4
|
||||
i_end:
|
||||
ctx1 rb 28 ;sizeof.TinyGLContext = 28
|
||||
ctx1 TinyGLContext
|
||||
image_data_toolbar dd 0
|
||||
qObj dd 0
|
||||
mouse_drag dd 0 ;scene rotation mode based on mouse cursor movement
|
||||
mouse_x dd 0
|
||||
mouse_y dd 0
|
||||
angle_dzm dd 0 ;~ 3d_wnd_w/180 - adding scene rotation angles when rotating the mouse
|
||||
angle_dym dd 0 ;~ 3d_wnd_h/180
|
||||
run_file_70 FileInfoBlock
|
||||
sc system_colors
|
||||
align 16
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
; Test glu2 - gluSphere functionality testing
|
||||
; Copyright (C) 2015-2025 KolibriOS team
|
||||
|
||||
use32
|
||||
org 0
|
||||
db 'MENUET01'
|
||||
@@ -8,24 +12,24 @@ include '../../../../../macros.inc'
|
||||
include '../../../../../KOSfuncs.inc'
|
||||
include '../../../../../load_img.inc'
|
||||
include '../../../../../load_lib.mac'
|
||||
include '../kosgl.inc'
|
||||
include '../opengl_const.inc'
|
||||
include '../zbuffer.inc'
|
||||
include '../../../../../develop/info3ds/info_fun_float.inc'
|
||||
|
||||
3d_wnd_l equ 0 ;tinygl buffer left indent
|
||||
3d_wnd_t equ 30 ;tinygl buffer top indent
|
||||
3d_wnd_w equ 500
|
||||
3d_wnd_h equ 400
|
||||
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
|
||||
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
|
||||
|
||||
;Макрос для параметров типа double (8 байт)
|
||||
macro glpush GLDoubleVar {
|
||||
push dword[GLDoubleVar+4]
|
||||
push dword[GLDoubleVar]
|
||||
}
|
||||
|
||||
align 4
|
||||
start:
|
||||
load_libraries l_libs_start,l_libs_end
|
||||
;проверка на сколько удачно загузились библиотеки
|
||||
;checking how successfully the libraries were loaded
|
||||
mov ebp,lib_0
|
||||
.test_lib_open:
|
||||
cmp dword [ebp+ll_struc_size-4],0
|
||||
@@ -39,16 +43,24 @@ load_libraries l_libs_start,l_libs_end
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
|
||||
mcall SF_SET_EVENTS_MASK,0x27
|
||||
|
||||
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
finit
|
||||
fild dword[buf_ogl.w]
|
||||
fdiv dword[fl_180]
|
||||
fstp dword[angle_dzm]
|
||||
fild dword[buf_ogl.h]
|
||||
fdiv dword[fl_180]
|
||||
fstp dword[angle_dym]
|
||||
|
||||
stdcall [kosglMakeCurrent], 3d_wnd_l,3d_wnd_t,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [glEnable], GL_DEPTH_TEST
|
||||
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
||||
stdcall [glEnable], GL_NORMALIZE ;normals of the same size to avoid artifacts
|
||||
call [gluNewQuadric]
|
||||
mov [qObj],eax
|
||||
|
||||
stdcall [glClearColor], 0.25,0.25,0.25,0.0
|
||||
stdcall [glShadeModel], GL_SMOOTH
|
||||
|
||||
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
|
||||
mov eax,[ctx1.gl_context]
|
||||
mov eax,[eax] ;eax -> ZBuffer
|
||||
mov eax,[eax+ZBuffer.pbuf]
|
||||
mov dword[buf_ogl],eax
|
||||
@@ -60,6 +72,14 @@ load_libraries l_libs_start,l_libs_end
|
||||
stdcall [buf2d_convert_text_matrix], buf_1
|
||||
|
||||
load_image_file 'toolb_1.png', image_data_toolbar
|
||||
|
||||
fld dword[scale]
|
||||
stdcall update_number, txt_scale.v
|
||||
fld dword[angle_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
fld dword[angle_z]
|
||||
stdcall update_number, txt_angle_z.v
|
||||
|
||||
call SetLight
|
||||
call draw_3d
|
||||
|
||||
@@ -76,13 +96,24 @@ still:
|
||||
jz key
|
||||
cmp al,EV_BUTTON
|
||||
jz button
|
||||
cmp al,EV_MOUSE
|
||||
jne still
|
||||
call mouse
|
||||
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
|
||||
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
|
||||
mov ebx,[buf_ogl.w]
|
||||
add ebx,(50 shl 16)+9
|
||||
mov ecx,[buf_ogl.h]
|
||||
add ecx,(30 shl 16)+4
|
||||
add ecx,eax
|
||||
add cx,[buf_ogl.t]
|
||||
mcall SF_CREATE_WINDOW,,,0x33ffffff,,caption
|
||||
|
||||
mov esi,[sc.work_button]
|
||||
mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;вершины вкл.
|
||||
@@ -129,11 +160,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
jmp still
|
||||
@@ -144,11 +171,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
jmp still
|
||||
@@ -159,11 +182,7 @@ key:
|
||||
fld dword[angle_z]
|
||||
fadd dword[delt_size]
|
||||
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
|
||||
stdcall update_number, txt_angle_z.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
jmp still
|
||||
@@ -174,11 +193,7 @@ key:
|
||||
fld dword[angle_z]
|
||||
fsub dword[delt_size]
|
||||
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
|
||||
stdcall update_number, txt_angle_z.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
;jmp still
|
||||
@@ -221,6 +236,104 @@ button:
|
||||
stdcall mem.Free,[image_data_toolbar]
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
align 4
|
||||
mouse:
|
||||
push eax ebx
|
||||
mcall SF_MOUSE_GET,SSF_BUTTON_EXT
|
||||
bt eax,0
|
||||
jnc .end_m
|
||||
;mouse l. but. move
|
||||
cmp dword[mouse_drag],1
|
||||
jne .end_m
|
||||
|
||||
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
|
||||
mov ebx,eax
|
||||
sar ebx,16 ;mouse.x
|
||||
cmp ebx,3d_wnd_l
|
||||
jg @f
|
||||
mov ebx,3d_wnd_l
|
||||
@@:
|
||||
sub ebx,3d_wnd_l
|
||||
cmp ebx,3d_wnd_w
|
||||
jle @f
|
||||
mov ebx,3d_wnd_w
|
||||
@@:
|
||||
movsx eax,ax ;mouse.y
|
||||
cmp eax,3d_wnd_t
|
||||
jg @f
|
||||
mov eax,3d_wnd_t
|
||||
@@:
|
||||
sub eax,3d_wnd_t
|
||||
cmp eax,3d_wnd_h
|
||||
jle @f
|
||||
mov eax,3d_wnd_h
|
||||
@@:
|
||||
finit
|
||||
fild dword[mouse_y]
|
||||
mov [mouse_y],eax
|
||||
fisub dword[mouse_y]
|
||||
fdiv dword[angle_dzm] ;if the cursor moves along the y-axis (up or down)
|
||||
fadd dword[angle_z]
|
||||
fst dword[angle_z]
|
||||
stdcall update_number, txt_angle_z.v
|
||||
|
||||
fild dword[mouse_x]
|
||||
mov [mouse_x],ebx
|
||||
fisub dword[mouse_x]
|
||||
fdiv dword[angle_dym] ;if the cursor moves along the z-axis (left or right)
|
||||
fadd dword[angle_y]
|
||||
fst dword[angle_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
jmp .end_d
|
||||
.end_m:
|
||||
bt eax,16
|
||||
jnc @f
|
||||
;mouse l. but. up
|
||||
mov dword[mouse_drag],0
|
||||
jmp .end_d
|
||||
@@:
|
||||
bt eax,8
|
||||
jnc .end_d
|
||||
;mouse l. but. press
|
||||
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
|
||||
mov ebx,eax
|
||||
sar ebx,16 ;mouse.x
|
||||
cmp ebx,3d_wnd_l
|
||||
jl .end_d
|
||||
sub ebx,3d_wnd_l
|
||||
cmp ebx,3d_wnd_w
|
||||
jg .end_d
|
||||
movsx eax,ax ;mouse.y
|
||||
cmp eax,3d_wnd_t
|
||||
jl .end_d
|
||||
sub eax,3d_wnd_t
|
||||
cmp eax,3d_wnd_h
|
||||
jg .end_d
|
||||
mov dword[mouse_drag],1
|
||||
mov dword[mouse_x],ebx
|
||||
mov dword[mouse_y],eax
|
||||
.end_d:
|
||||
|
||||
pop ebx eax
|
||||
ret
|
||||
|
||||
;input:
|
||||
; st0 - number
|
||||
; txt_addr - pointer to text buffer
|
||||
align 4
|
||||
proc update_number uses eax, txt_addr:dword
|
||||
mov word[NumberSymbolsAD],3
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov eax,[txt_addr]
|
||||
mov byte[eax],0
|
||||
stdcall str_cat, eax,Data_String
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
but_st_point:
|
||||
stdcall [gluQuadricDrawStyle], [qObj],GLU_POINT
|
||||
@@ -256,11 +369,7 @@ but_zoom_p:
|
||||
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
|
||||
stdcall update_number, txt_scale.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
ret
|
||||
@@ -279,19 +388,12 @@ but_zoom_m:
|
||||
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
|
||||
stdcall update_number, txt_scale.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
draw_3d:
|
||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||
@@ -302,15 +404,24 @@ call [glPushMatrix]
|
||||
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
|
||||
push 32
|
||||
push 32
|
||||
glpush rad1
|
||||
stdcall [gluSphere], [qObj]
|
||||
|
||||
stdcall [glColor3f], 1.0, 0.0, 0.0
|
||||
stdcall [glTranslatef], -1.6,0.0,0.0
|
||||
stdcall [gluSphere], [qObj], 0.55, 16,16
|
||||
push 16
|
||||
push 16
|
||||
glpush rad2
|
||||
stdcall [gluSphere], [qObj]
|
||||
|
||||
stdcall [glColor3f], 0.0, 0.0, 1.0
|
||||
stdcall [glTranslatef], 3.2,0.0,0.0
|
||||
stdcall [gluSphere], [qObj], 0.55, 16,16
|
||||
push 16
|
||||
push 16
|
||||
glpush rad2
|
||||
stdcall [gluSphere], [qObj]
|
||||
call [glPopMatrix]
|
||||
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_scale,5,5,0xffff00
|
||||
@@ -336,10 +447,19 @@ SetLight:
|
||||
stdcall [glEnable],GL_LIGHT0
|
||||
ret
|
||||
|
||||
scale dd 0.4 ;начальный масштаб
|
||||
sc_delt dd 0.05 ;изменение масштаба при нажатии
|
||||
sc_min dd 0.1 ;минимальный масштаб
|
||||
sc_max dd 1.1 ;максимальный масштаб
|
||||
align 4
|
||||
caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
rad1 dq 1.0
|
||||
rad2 dq 0.55
|
||||
|
||||
fl_180 dd 180.0
|
||||
|
||||
scale dd 0.4 ;initial scale
|
||||
sc_delt dd 0.05 ;zoom on click
|
||||
sc_min dd 0.1 ;minimum scale
|
||||
sc_max dd 1.1 ;maximum scale
|
||||
angle_z dd 0.0
|
||||
angle_y dd 0.0
|
||||
delt_size dd 3.0
|
||||
@@ -358,13 +478,17 @@ import_tinygl:
|
||||
|
||||
macro E_LIB n
|
||||
{
|
||||
if defined sz_#n
|
||||
n dd sz_#n
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
if used n
|
||||
sz_#n db `n,0
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
|
||||
@@ -482,28 +606,23 @@ lib_name_2 db 'libimg.obj',0
|
||||
|
||||
txt_scale:
|
||||
db 'Scale: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_z:
|
||||
db 'Rotate z: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_y:
|
||||
db 'Rotate y: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
align 4
|
||||
buf_ogl:
|
||||
dd 0 ;указатель на буфер изображения
|
||||
dw 10,10 ;+4 left,top
|
||||
.w: dd 400
|
||||
.h: dd 350
|
||||
dw 3d_wnd_l ;+4 left
|
||||
.t: dw 3d_wnd_t ;+6 top
|
||||
.w: dd 3d_wnd_w
|
||||
.h: dd 3d_wnd_h
|
||||
dd 0,24 ;+16 color,bit in pixel
|
||||
|
||||
align 4
|
||||
@@ -522,9 +641,14 @@ l_libs_end:
|
||||
|
||||
align 4
|
||||
i_end:
|
||||
ctx1 rb 28 ;sizeof.TinyGLContext = 28
|
||||
ctx1 TinyGLContext
|
||||
image_data_toolbar dd 0
|
||||
qObj dd 0
|
||||
mouse_drag dd 0 ;scene rotation mode based on mouse cursor movement
|
||||
mouse_x dd 0
|
||||
mouse_y dd 0
|
||||
angle_dzm dd 0 ;~ 3d_wnd_w/180 - adding scene rotation angles when rotating the mouse
|
||||
angle_dym dd 0 ;~ 3d_wnd_h/180
|
||||
run_file_70 FileInfoBlock
|
||||
sc system_colors
|
||||
align 16
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
; Textures0 - example of texture mapping on a sphere and cube
|
||||
; Copyright (C) 2015-2025 KolibriOS team
|
||||
|
||||
use32
|
||||
org 0
|
||||
db 'MENUET01'
|
||||
@@ -8,24 +12,24 @@ include '../../../../../macros.inc'
|
||||
include '../../../../../KOSfuncs.inc'
|
||||
include '../../../../../load_img.inc'
|
||||
include '../../../../../load_lib.mac'
|
||||
include '../kosgl.inc'
|
||||
include '../opengl_const.inc'
|
||||
include '../zbuffer.inc'
|
||||
include '../../../../../develop/info3ds/info_fun_float.inc'
|
||||
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
3d_wnd_l equ 0 ;tinygl buffer left indent
|
||||
3d_wnd_t equ 30 ;tinygl buffer top indent
|
||||
3d_wnd_w equ 500
|
||||
3d_wnd_h equ 400
|
||||
|
||||
;Макрос для параметров типа double (8 байт)
|
||||
macro glpush GLDoubleVar {
|
||||
push dword[GLDoubleVar+4]
|
||||
push dword[GLDoubleVar]
|
||||
}
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
|
||||
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
|
||||
|
||||
align 4
|
||||
start:
|
||||
load_libraries l_libs_start,l_libs_end
|
||||
;проверка на сколько удачно загузились библиотеки
|
||||
;checking how successfully the libraries were loaded
|
||||
mov ebp,lib_0
|
||||
.test_lib_open:
|
||||
cmp dword [ebp+ll_struc_size-4],0
|
||||
@@ -39,9 +43,9 @@ load_libraries l_libs_start,l_libs_end
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
|
||||
mcall SF_SET_EVENTS_MASK,0x27
|
||||
|
||||
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [kosglMakeCurrent], 3d_wnd_l,3d_wnd_t,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [glEnable], GL_DEPTH_TEST
|
||||
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
||||
stdcall [glEnable], GL_NORMALIZE ;normals of the same size to avoid artifacts
|
||||
call [gluNewQuadric]
|
||||
mov [qObj],eax
|
||||
stdcall [gluQuadricTexture], eax,GL_TRUE
|
||||
@@ -49,7 +53,7 @@ load_libraries l_libs_start,l_libs_end
|
||||
stdcall [glClearColor], 0.25,0.25,0.25,0.0
|
||||
stdcall [glShadeModel], GL_SMOOTH
|
||||
|
||||
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
|
||||
mov eax,[ctx1.gl_context]
|
||||
mov eax,[eax] ;eax -> ZBuffer
|
||||
mov eax,[eax+ZBuffer.pbuf]
|
||||
mov dword[buf_ogl],eax
|
||||
@@ -63,6 +67,11 @@ load_libraries l_libs_start,l_libs_end
|
||||
load_image_file 'toolb_1.png', image_data_toolbar
|
||||
load_image_file 'text_1.png', texture, text_w,text_h ;открытие файла текстуры
|
||||
|
||||
fld dword[angle_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
fld dword[angle_z]
|
||||
stdcall update_number, txt_angle_z.v
|
||||
|
||||
;* Setup texturing *
|
||||
stdcall [glTexEnvi], GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL
|
||||
|
||||
@@ -100,7 +109,15 @@ 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
|
||||
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
|
||||
mov ebx,[buf_ogl.w]
|
||||
add ebx,(50 shl 16)+9
|
||||
mov ecx,[buf_ogl.h]
|
||||
add ecx,(30 shl 16)+4
|
||||
add ecx,eax
|
||||
add cx,[buf_ogl.t]
|
||||
mcall SF_CREATE_WINDOW,,,0x33ffffff,,caption
|
||||
|
||||
mov esi,[sc.work_button]
|
||||
mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;сферы
|
||||
@@ -144,11 +161,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -158,11 +171,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -172,11 +181,7 @@ key:
|
||||
fld dword[angle_z]
|
||||
fadd dword[delt_size]
|
||||
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
|
||||
stdcall update_number, txt_angle_z.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -186,11 +191,7 @@ key:
|
||||
fld dword[angle_z]
|
||||
fsub dword[delt_size]
|
||||
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
|
||||
stdcall update_number, txt_angle_z.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -227,6 +228,20 @@ button:
|
||||
stdcall mem.Free,[image_data_toolbar]
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
;input:
|
||||
; st0 - number
|
||||
; txt_addr - pointer to text buffer
|
||||
align 4
|
||||
proc update_number uses eax, txt_addr:dword
|
||||
mov word[NumberSymbolsAD],2
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov eax,[txt_addr]
|
||||
mov byte[eax],0
|
||||
stdcall str_cat, eax,Data_String
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
but_dr_0:
|
||||
mov dword[dr_figure],0
|
||||
@@ -287,8 +302,6 @@ but_zoom_m:
|
||||
call [kosglSwapBuffers]
|
||||
ret
|
||||
|
||||
align 4
|
||||
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
draw_3d:
|
||||
@@ -303,15 +316,24 @@ cmp dword[dr_figure],0
|
||||
jne @f
|
||||
; рисование сфер
|
||||
stdcall [glColor3f], 1.0, 1.0, 0.0
|
||||
stdcall [gluSphere], [qObj], 1.0, 32,32
|
||||
push 32
|
||||
push 32
|
||||
glpush rad1
|
||||
stdcall [gluSphere], [qObj]
|
||||
|
||||
stdcall [glColor3f], 1.0, 0.0, 0.0
|
||||
stdcall [glTranslatef], -1.6,0.0,0.0
|
||||
stdcall [gluSphere], [qObj], 0.55, 16,16
|
||||
push 16
|
||||
push 16
|
||||
glpush rad2
|
||||
stdcall [gluSphere], [qObj]
|
||||
|
||||
stdcall [glColor3f], 0.0, 0.0, 1.0
|
||||
stdcall [glTranslatef], 3.2,0.0,0.0
|
||||
stdcall [gluSphere], [qObj], 0.55, 16,16
|
||||
push 16
|
||||
push 16
|
||||
glpush rad2
|
||||
stdcall [gluSphere], [qObj]
|
||||
@@:
|
||||
cmp dword[dr_figure],1
|
||||
jne @f
|
||||
@@ -387,6 +409,13 @@ call [glPopMatrix]
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_y,5,25,0xffff00
|
||||
ret
|
||||
|
||||
align 4
|
||||
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
rad1 dq 1.0
|
||||
rad2 dq 0.55
|
||||
|
||||
scale dd 0.4 ;начальный масштаб
|
||||
sc_delt dd 0.05 ;изменение масштаба при нажатии
|
||||
sc_min dd 0.1 ;минимальный масштаб
|
||||
@@ -409,13 +438,17 @@ import_tinygl:
|
||||
|
||||
macro E_LIB n
|
||||
{
|
||||
if defined sz_#n
|
||||
n dd sz_#n
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
if used n
|
||||
sz_#n db `n,0
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
|
||||
@@ -533,28 +566,23 @@ lib_name_2 db 'libimg.obj',0
|
||||
|
||||
txt_scale:
|
||||
db 'Scale: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_z:
|
||||
db 'Rotate z: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_y:
|
||||
db 'Rotate y: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
align 4
|
||||
buf_ogl:
|
||||
dd 0 ;указатель на буфер изображения
|
||||
dw 10,10 ;+4 left,top
|
||||
.w: dd 400
|
||||
.h: dd 350
|
||||
dw 3d_wnd_l ;+4 left
|
||||
.t: dw 3d_wnd_t ;+6 top
|
||||
.w: dd 3d_wnd_w
|
||||
.h: dd 3d_wnd_h
|
||||
dd 0,24 ;+16 color,bit in pixel
|
||||
|
||||
align 4
|
||||
@@ -573,7 +601,7 @@ l_libs_end:
|
||||
|
||||
align 4
|
||||
i_end:
|
||||
ctx1 rb 28 ;sizeof.TinyGLContext = 28
|
||||
ctx1 TinyGLContext
|
||||
image_data_toolbar dd 0
|
||||
dr_figure dd 0
|
||||
qObj dd 0
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
; Textures1 - drawing the earth with and without meridians.
|
||||
; Texture size 1024*512 pixels is used.
|
||||
; Copyright (C) 2015-2025 KolibriOS team
|
||||
|
||||
use32
|
||||
org 0
|
||||
db 'MENUET01'
|
||||
@@ -8,24 +13,24 @@ include '../../../../../macros.inc'
|
||||
include '../../../../../KOSfuncs.inc'
|
||||
include '../../../../../load_img.inc'
|
||||
include '../../../../../load_lib.mac'
|
||||
include '../kosgl.inc'
|
||||
include '../opengl_const.inc'
|
||||
include '../zbuffer.inc'
|
||||
include '../../../../../develop/info3ds/info_fun_float.inc'
|
||||
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
3d_wnd_l equ 0 ;tinygl buffer left indent
|
||||
3d_wnd_t equ 30 ;tinygl buffer top indent
|
||||
3d_wnd_w equ 450
|
||||
3d_wnd_h equ 400
|
||||
|
||||
;Макрос для параметров типа double (8 байт)
|
||||
macro glpush GLDoubleVar {
|
||||
push dword[GLDoubleVar+4]
|
||||
push dword[GLDoubleVar]
|
||||
}
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
|
||||
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
|
||||
|
||||
align 4
|
||||
start:
|
||||
load_libraries l_libs_start,l_libs_end
|
||||
;проверка на сколько удачно загузились библиотеки
|
||||
;checking how successfully the libraries were loaded
|
||||
mov ebp,lib_0
|
||||
.test_lib_open:
|
||||
cmp dword [ebp+ll_struc_size-4],0
|
||||
@@ -39,9 +44,9 @@ load_libraries l_libs_start,l_libs_end
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
|
||||
mcall SF_SET_EVENTS_MASK,0x27
|
||||
|
||||
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [kosglMakeCurrent], 3d_wnd_l,3d_wnd_t,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [glEnable], GL_DEPTH_TEST
|
||||
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
||||
stdcall [glEnable], GL_NORMALIZE ;normals of the same size to avoid artifacts
|
||||
call [gluNewQuadric]
|
||||
mov [qObj],eax
|
||||
stdcall [gluQuadricTexture], eax,GL_TRUE
|
||||
@@ -49,7 +54,7 @@ load_libraries l_libs_start,l_libs_end
|
||||
stdcall [glClearColor], 0.0,0.0,0.0,0.0
|
||||
stdcall [glShadeModel], GL_SMOOTH
|
||||
|
||||
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
|
||||
mov eax,[ctx1.gl_context]
|
||||
mov eax,[eax] ;eax -> ZBuffer
|
||||
mov eax,[eax+ZBuffer.pbuf]
|
||||
mov dword[buf_ogl],eax
|
||||
@@ -63,6 +68,11 @@ load_libraries l_libs_start,l_libs_end
|
||||
load_image_file 'toolb_1.png', image_data_toolbar
|
||||
load_image_file 'text_2.png', texture, text_w,text_h ;открытие файла текстуры
|
||||
|
||||
fld dword[angle_x]
|
||||
stdcall update_number, txt_angle_x.v
|
||||
fld dword[angle_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
|
||||
;* Setup texturing *
|
||||
stdcall [glTexEnvi], GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL
|
||||
|
||||
@@ -100,7 +110,15 @@ 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
|
||||
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
|
||||
mov ebx,[buf_ogl.w]
|
||||
add ebx,(50 shl 16)+9
|
||||
mov ecx,[buf_ogl.h]
|
||||
add ecx,(30 shl 16)+4
|
||||
add ecx,eax
|
||||
add cx,[buf_ogl.t]
|
||||
mcall SF_CREATE_WINDOW,,,0x33ffffff,,caption
|
||||
|
||||
mov esi,[sc.work_button]
|
||||
mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;земля с меридиан.
|
||||
@@ -146,11 +164,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -160,11 +174,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -174,11 +184,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_x.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -188,11 +194,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_x.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -229,6 +231,20 @@ button:
|
||||
stdcall mem.Free,[image_data_toolbar]
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
;input:
|
||||
; st0 - number
|
||||
; txt_addr - pointer to text buffer
|
||||
align 4
|
||||
proc update_number uses eax, txt_addr:dword
|
||||
mov word[NumberSymbolsAD],2
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov eax,[txt_addr]
|
||||
mov byte[eax],0
|
||||
stdcall str_cat, eax,Data_String
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
but_dr_0:
|
||||
mov dword[dr_figure],0
|
||||
@@ -289,8 +305,6 @@ but_zoom_m:
|
||||
call [kosglSwapBuffers]
|
||||
ret
|
||||
|
||||
align 4
|
||||
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
draw_3d:
|
||||
@@ -304,18 +318,27 @@ call [glPushMatrix]
|
||||
|
||||
cmp dword[dr_figure],0
|
||||
jne @f
|
||||
; рисование земли с меридианами
|
||||
; drawing earth with meridians
|
||||
stdcall [glColor3f], 0.0, 0.0, 1.0
|
||||
stdcall [gluQuadricDrawStyle], [qObj],GLU_LINE
|
||||
stdcall [gluSphere], [qObj], 1.0, 24,18 ;меридианы
|
||||
push 18
|
||||
push 24
|
||||
glpush rad1
|
||||
stdcall [gluSphere], [qObj] ;meridians
|
||||
stdcall [gluQuadricDrawStyle], [qObj],GLU_FILL
|
||||
stdcall [gluSphere], [qObj], 0.995, 24,18 ;земля
|
||||
push 24
|
||||
push 18
|
||||
glpush rad2
|
||||
stdcall [gluSphere], [qObj] ;Earth
|
||||
@@:
|
||||
cmp dword[dr_figure],1
|
||||
jne @f
|
||||
; рисование земли
|
||||
; drawing the earth
|
||||
stdcall [gluQuadricDrawStyle], [qObj],GLU_FILL
|
||||
stdcall [gluSphere], [qObj], 1.0, 64,64
|
||||
push 64
|
||||
push 64
|
||||
glpush rad1
|
||||
stdcall [gluSphere], [qObj]
|
||||
@@:
|
||||
call [glPopMatrix]
|
||||
|
||||
@@ -324,6 +347,13 @@ call [glPopMatrix]
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_x,5,25,0xffff00
|
||||
ret
|
||||
|
||||
align 4
|
||||
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
rad1 dq 1.0
|
||||
rad2 dq 0.995
|
||||
|
||||
scale dd 0.95 ;начальный масштаб
|
||||
sc_delt dd 0.05 ;изменение масштаба при нажатии
|
||||
sc_min dd 0.1 ;минимальный масштаб
|
||||
@@ -339,13 +369,17 @@ import_tinygl:
|
||||
|
||||
macro E_LIB n
|
||||
{
|
||||
if defined sz_#n
|
||||
n dd sz_#n
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
if used n
|
||||
sz_#n db `n,0
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
|
||||
@@ -463,34 +497,27 @@ lib_name_2 db 'libimg.obj',0
|
||||
|
||||
txt_scale:
|
||||
db 'Scale: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_z:
|
||||
db 'Rotate z: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_x:
|
||||
db 'Rotate x: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_y:
|
||||
db 'Rotate y: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
align 4
|
||||
buf_ogl:
|
||||
dd 0 ;указатель на буфер изображения
|
||||
dw 10,10 ;+4 left,top
|
||||
.w: dd 400
|
||||
.h: dd 350
|
||||
dw 3d_wnd_l ;+4 left
|
||||
.t: dw 3d_wnd_t ;+6 top
|
||||
.w: dd 3d_wnd_w
|
||||
.h: dd 3d_wnd_h
|
||||
dd 0,24 ;+16 color,bit in pixel
|
||||
|
||||
align 4
|
||||
@@ -509,7 +536,7 @@ l_libs_end:
|
||||
|
||||
align 4
|
||||
i_end:
|
||||
ctx1 rb 28 ;sizeof.TinyGLContext = 28
|
||||
ctx1 TinyGLContext
|
||||
image_data_toolbar dd 0
|
||||
dr_figure dd 0
|
||||
qObj dd 0
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
; SPDX-License-Identifier: GPL-2.0-only
|
||||
; Textures2 - example of creating a spherical panorama using texture
|
||||
; Copyright (C) 2015-2025 KolibriOS team
|
||||
|
||||
use32
|
||||
org 0
|
||||
db 'MENUET01'
|
||||
@@ -8,24 +12,24 @@ include '../../../../../macros.inc'
|
||||
include '../../../../../KOSfuncs.inc'
|
||||
include '../../../../../load_img.inc'
|
||||
include '../../../../../load_lib.mac'
|
||||
include '../kosgl.inc'
|
||||
include '../opengl_const.inc'
|
||||
include '../zbuffer.inc'
|
||||
include '../../../../../develop/info3ds/info_fun_float.inc'
|
||||
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
3d_wnd_l equ 0 ;tinygl buffer left indent
|
||||
3d_wnd_t equ 30 ;tinygl buffer top indent
|
||||
3d_wnd_w equ 450
|
||||
3d_wnd_h equ 400
|
||||
|
||||
;Макрос для параметров типа double (8 байт)
|
||||
macro glpush GLDoubleVar {
|
||||
push dword[GLDoubleVar+4]
|
||||
push dword[GLDoubleVar]
|
||||
}
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
|
||||
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
|
||||
|
||||
align 4
|
||||
start:
|
||||
load_libraries l_libs_start,l_libs_end
|
||||
;проверка на сколько удачно загузились библиотеки
|
||||
;checking how successfully the libraries were loaded
|
||||
mov ebp,lib_0
|
||||
.test_lib_open:
|
||||
cmp dword [ebp+ll_struc_size-4],0
|
||||
@@ -39,9 +43,9 @@ load_libraries l_libs_start,l_libs_end
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
|
||||
mcall SF_SET_EVENTS_MASK,0x27
|
||||
|
||||
stdcall [kosglMakeCurrent], 5,30,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [kosglMakeCurrent], 3d_wnd_l,3d_wnd_t,[buf_ogl.w],[buf_ogl.h],ctx1
|
||||
stdcall [glEnable], GL_DEPTH_TEST
|
||||
stdcall [glEnable], GL_NORMALIZE ;делам нормали одинаковой величины во избежание артефактов
|
||||
stdcall [glEnable], GL_NORMALIZE ;normals of the same size to avoid artifacts
|
||||
call [gluNewQuadric]
|
||||
mov [qObj],eax
|
||||
stdcall [gluQuadricDrawStyle], eax,GLU_FILL
|
||||
@@ -50,7 +54,7 @@ load_libraries l_libs_start,l_libs_end
|
||||
stdcall [glClearColor], 0.0,0.0,0.0,0.0
|
||||
stdcall [glShadeModel], GL_SMOOTH
|
||||
|
||||
mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
|
||||
mov eax,[ctx1.gl_context]
|
||||
mov eax,[eax] ;eax -> ZBuffer
|
||||
mov eax,[eax+ZBuffer.pbuf]
|
||||
mov dword[buf_ogl],eax
|
||||
@@ -64,6 +68,11 @@ load_libraries l_libs_start,l_libs_end
|
||||
load_image_file 'toolb_1.png', image_data_toolbar
|
||||
load_image_file 'text_3.png', texture, text_w,text_h ;открытие файла текстуры
|
||||
|
||||
fld dword[angle_x]
|
||||
stdcall update_number, txt_angle_x.v
|
||||
fld dword[angle_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
|
||||
;* Setup texturing *
|
||||
stdcall [glTexEnvi], GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL
|
||||
|
||||
@@ -101,7 +110,15 @@ 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
|
||||
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
|
||||
mov ebx,[buf_ogl.w]
|
||||
add ebx,(50 shl 16)+9
|
||||
mov ecx,[buf_ogl.h]
|
||||
add ecx,(30 shl 16)+4
|
||||
add ecx,eax
|
||||
add cx,[buf_ogl.t]
|
||||
mcall SF_CREATE_WINDOW,,,0x33ffffff,,caption
|
||||
|
||||
mov esi,[sc.work_button]
|
||||
mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;масштаб +
|
||||
@@ -141,11 +158,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -155,11 +168,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_y.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -169,11 +178,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_x.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -183,11 +188,7 @@ key:
|
||||
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
|
||||
stdcall update_number, txt_angle_x.v
|
||||
call draw_3d
|
||||
call [kosglSwapBuffers]
|
||||
@@:
|
||||
@@ -214,6 +215,20 @@ button:
|
||||
stdcall mem.Free,[image_data_toolbar]
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
;input:
|
||||
; st0 - number
|
||||
; txt_addr - pointer to text buffer
|
||||
align 4
|
||||
proc update_number uses eax, txt_addr:dword
|
||||
mov word[NumberSymbolsAD],2
|
||||
fstp qword[Data_Double]
|
||||
call DoubleFloat_to_String
|
||||
mov eax,[txt_addr]
|
||||
mov byte[eax],0
|
||||
stdcall str_cat, eax,Data_String
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
but_zoom_p:
|
||||
finit
|
||||
@@ -260,8 +275,6 @@ but_zoom_m:
|
||||
call [kosglSwapBuffers]
|
||||
ret
|
||||
|
||||
align 4
|
||||
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
draw_3d:
|
||||
@@ -275,7 +288,12 @@ call [glPushMatrix]
|
||||
stdcall [glRotatef], [angle_x],1.0,0.0,0.0
|
||||
|
||||
; рисование панорамы
|
||||
stdcall [gluSphere], [qObj], 1.0, 64,64
|
||||
push 64
|
||||
push 64
|
||||
add esp,-8
|
||||
fld1
|
||||
fstp qword[esp]
|
||||
stdcall [gluSphere], [qObj]
|
||||
call [glPopMatrix]
|
||||
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_scale,5,5,0xffff00
|
||||
@@ -283,6 +301,10 @@ call [glPopMatrix]
|
||||
stdcall [buf2d_draw_text], buf_ogl, buf_1,txt_angle_x,5,25,0xffff00
|
||||
ret
|
||||
|
||||
align 4
|
||||
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
|
||||
|
||||
align 4
|
||||
scale dd 1.5 ;начальный масштаб
|
||||
sc_delt dd 0.05 ;изменение масштаба при нажатии
|
||||
sc_min dd 0.95 ;минимальный масштаб
|
||||
@@ -298,13 +320,17 @@ import_tinygl:
|
||||
|
||||
macro E_LIB n
|
||||
{
|
||||
if defined sz_#n
|
||||
n dd sz_#n
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
dd 0,0
|
||||
macro E_LIB n
|
||||
{
|
||||
if used n
|
||||
sz_#n db `n,0
|
||||
end if
|
||||
}
|
||||
include '../export.inc'
|
||||
|
||||
@@ -422,34 +448,27 @@ lib_name_2 db 'libimg.obj',0
|
||||
|
||||
txt_scale:
|
||||
db 'Scale: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_z:
|
||||
db 'Rotate z: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_x:
|
||||
db 'Rotate x: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
txt_angle_y:
|
||||
db 'Rotate y: '
|
||||
.v:
|
||||
db 0
|
||||
rb 10
|
||||
.v: rb 11
|
||||
|
||||
align 4
|
||||
buf_ogl:
|
||||
dd 0 ;указатель на буфер изображения
|
||||
dw 10,10 ;+4 left,top
|
||||
.w: dd 400
|
||||
.h: dd 350
|
||||
dw 3d_wnd_l ;+4 left
|
||||
.t: dw 3d_wnd_t ;+6 top
|
||||
.w: dd 3d_wnd_w
|
||||
.h: dd 3d_wnd_h
|
||||
dd 0,24 ;+16 color,bit in pixel
|
||||
|
||||
align 4
|
||||
@@ -468,7 +487,7 @@ l_libs_end:
|
||||
|
||||
align 4
|
||||
i_end:
|
||||
ctx1 rb 28 ;sizeof.TinyGLContext = 28
|
||||
ctx1 TinyGLContext
|
||||
image_data_toolbar dd 0
|
||||
qObj dd 0
|
||||
TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.)
|
||||
|
||||
Reference in New Issue
Block a user