forked from KolibriOS/kolibrios
add function 'glOrtho', small optimize, clean code
git-svn-id: svn://kolibrios.org@8062 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a1ac239480
commit
185996ac6b
@ -563,6 +563,31 @@ endl
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
align 4
|
||||||
|
proc glOrtho uses eax, left:qword, right:qword, bottom:qword, top:qword,\
|
||||||
|
near:qword, farv:qword
|
||||||
|
locals
|
||||||
|
p rd 7
|
||||||
|
endl
|
||||||
|
mov dword[p],OP_Ortho
|
||||||
|
fld qword[left]
|
||||||
|
fstp dword[p+4]
|
||||||
|
fld qword[right]
|
||||||
|
fstp dword[p+8]
|
||||||
|
fld qword[bottom]
|
||||||
|
fstp dword[p+12]
|
||||||
|
fld qword[top]
|
||||||
|
fstp dword[p+16]
|
||||||
|
fld qword[near]
|
||||||
|
fstp dword[p+20]
|
||||||
|
fld qword[farv]
|
||||||
|
fstp dword[p+24]
|
||||||
|
|
||||||
|
lea eax,[ebp-28] ;=sizeof(dd)*7
|
||||||
|
stdcall gl_add_op,eax
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
; lightening
|
; lightening
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
use32
|
use32
|
||||||
org 0x0
|
org 0
|
||||||
db 'MENUET01'
|
db 'MENUET01'
|
||||||
dd 0x1
|
dd 1,start,i_end,mem,stacktop,0,cur_dir_path
|
||||||
dd start
|
|
||||||
dd i_end
|
|
||||||
dd mem,stacktop
|
|
||||||
dd 0,cur_dir_path
|
|
||||||
|
|
||||||
include '../../../../../../programs/proc32.inc'
|
include '../../../../../proc32.inc'
|
||||||
include '../../../../../../programs/macros.inc'
|
include '../../../../../macros.inc'
|
||||||
include '../../../../../../programs/develop/libraries/box_lib/load_lib.mac'
|
include '../../../../../KOSfuncs.inc'
|
||||||
include '../../../../../../programs/dll.inc'
|
include '../../../../../develop/libraries/box_lib/load_lib.mac'
|
||||||
|
include '../../../../../dll.inc'
|
||||||
include '../opengl_const.inc'
|
include '../opengl_const.inc'
|
||||||
|
|
||||||
@use_library
|
@use_library
|
||||||
@ -19,10 +16,10 @@ align 4
|
|||||||
start:
|
start:
|
||||||
load_library name_tgl, cur_dir_path, library_path, system_path, \
|
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
|
err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
|
||||||
cmp eax,-1
|
cmp eax,SF_TERMINATE_PROCESS
|
||||||
jz button.exit
|
jz button.exit
|
||||||
|
|
||||||
mcall 40,0x27
|
mcall SF_SET_EVENTS_MASK,0x27
|
||||||
|
|
||||||
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
|
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
|
||||||
stdcall [glEnable], GL_DEPTH_TEST
|
stdcall [glEnable], GL_DEPTH_TEST
|
||||||
@ -34,9 +31,9 @@ align 4
|
|||||||
red_win:
|
red_win:
|
||||||
call draw_window
|
call draw_window
|
||||||
|
|
||||||
align 4
|
align 16
|
||||||
still:
|
still:
|
||||||
mcall 10
|
mcall SF_CHECK_EVENT
|
||||||
cmp al,1
|
cmp al,1
|
||||||
jz red_win
|
jz red_win
|
||||||
cmp al,2
|
cmp al,2
|
||||||
@ -48,19 +45,19 @@ still:
|
|||||||
align 4
|
align 4
|
||||||
draw_window:
|
draw_window:
|
||||||
pushad
|
pushad
|
||||||
mcall 12,1
|
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||||
|
|
||||||
mov edx,0x33ffffff ;0x73ffffff
|
mov edx,0x33ffffff ;0x73ffffff
|
||||||
mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
|
|
||||||
mcall 12,2
|
mcall SF_REDRAW,SSF_END_DRAW
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
key:
|
key:
|
||||||
mcall 2
|
mcall SF_GET_KEY
|
||||||
|
|
||||||
cmp ah,27 ;Esc
|
cmp ah,27 ;Esc
|
||||||
je button.exit
|
je button.exit
|
||||||
@ -73,7 +70,7 @@ key:
|
|||||||
fadd dword[delt_size]
|
fadd dword[delt_size]
|
||||||
fstp dword[angle_z]
|
fstp dword[angle_z]
|
||||||
call draw_3d
|
call draw_3d
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
@@:
|
@@:
|
||||||
cmp ah,179 ;Right
|
cmp ah,179 ;Right
|
||||||
jne @f
|
jne @f
|
||||||
@ -81,31 +78,28 @@ key:
|
|||||||
fsub dword[delt_size]
|
fsub dword[delt_size]
|
||||||
fstp dword[angle_z]
|
fstp dword[angle_z]
|
||||||
call draw_3d
|
call draw_3d
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
button:
|
button:
|
||||||
mcall 17
|
mcall SF_GET_BUTTON
|
||||||
cmp ah,1
|
cmp ah,1
|
||||||
jne still
|
jne still
|
||||||
.exit:
|
.exit:
|
||||||
mcall -1
|
mcall SF_TERMINATE_PROCESS
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
|
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
|
||||||
align 4
|
|
||||||
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
|
||||||
;sizeof.TinyGLContext = 28
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
draw_3d:
|
draw_3d:
|
||||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||||
|
|
||||||
stdcall [glPushMatrix]
|
call [glPushMatrix]
|
||||||
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
||||||
|
|
||||||
stdcall [glColor3f],1.0, 0.0, 0.0
|
stdcall [glColor3f],1.0, 0.0, 0.0
|
||||||
@ -118,7 +112,7 @@ stdcall [glPushMatrix]
|
|||||||
stdcall [glVertex3f], -0.354,-0.354, 0.1
|
stdcall [glVertex3f], -0.354,-0.354, 0.1
|
||||||
stdcall [glVertex3f], -0.5, 0.0, 0.1
|
stdcall [glVertex3f], -0.5, 0.0, 0.1
|
||||||
stdcall [glVertex3f], -0.354, 0.354, 0.1
|
stdcall [glVertex3f], -0.354, 0.354, 0.1
|
||||||
stdcall [glEnd]
|
call [glEnd]
|
||||||
|
|
||||||
stdcall [glBegin],GL_LINES
|
stdcall [glBegin],GL_LINES
|
||||||
stdcall [glVertex3f], 0, 0.7, 0.3
|
stdcall [glVertex3f], 0, 0.7, 0.3
|
||||||
@ -131,9 +125,9 @@ stdcall [glPushMatrix]
|
|||||||
stdcall [glVertex3f], -0.7, 0.0, 0.3
|
stdcall [glVertex3f], -0.7, 0.0, 0.3
|
||||||
stdcall [glColor3f],1.0, 0.0, 0.0
|
stdcall [glColor3f],1.0, 0.0, 0.0
|
||||||
stdcall [glVertex3f], -0.495, 0.495, 0.7
|
stdcall [glVertex3f], -0.495, 0.495, 0.7
|
||||||
stdcall [glEnd]
|
call [glEnd]
|
||||||
|
|
||||||
stdcall [glPopMatrix]
|
call [glPopMatrix]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
angle_z dd 0.0
|
angle_z dd 0.0
|
||||||
@ -158,17 +152,21 @@ include '../export.inc'
|
|||||||
;--------------------------------------------------
|
;--------------------------------------------------
|
||||||
system_path db '/sys/lib/'
|
system_path db '/sys/lib/'
|
||||||
name_tgl db 'tinygl.obj',0
|
name_tgl db 'tinygl.obj',0
|
||||||
err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
|
|
||||||
head_f_i:
|
head_f_i:
|
||||||
head_f_l db 'System error',0
|
head_f_l db '"System error',0
|
||||||
err_message_import db 'Error on load import library tinygl.obj',0
|
err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
|
||||||
|
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
|
||||||
;--------------------------------------------------
|
;--------------------------------------------------
|
||||||
|
|
||||||
|
align 16
|
||||||
i_end:
|
i_end:
|
||||||
|
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
||||||
|
;sizeof.TinyGLContext = 28
|
||||||
rb 1024
|
rb 1024
|
||||||
stacktop:
|
stacktop:
|
||||||
cur_dir_path:
|
cur_dir_path:
|
||||||
rb 4096
|
rb 4096
|
||||||
library_path:
|
library_path:
|
||||||
rb 4096
|
rb 4096
|
||||||
mem:
|
mem:
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
use32
|
use32
|
||||||
org 0x0
|
org 0
|
||||||
db 'MENUET01'
|
db 'MENUET01'
|
||||||
dd 0x1
|
dd 1,start,i_end,mem,stacktop,0,cur_dir_path
|
||||||
dd start
|
|
||||||
dd i_end
|
|
||||||
dd mem,stacktop
|
|
||||||
dd 0,cur_dir_path
|
|
||||||
|
|
||||||
include '../../../../../../programs/proc32.inc'
|
include '../../../../../proc32.inc'
|
||||||
include '../../../../../../programs/macros.inc'
|
include '../../../../../macros.inc'
|
||||||
include '../../../../../../programs/develop/libraries/box_lib/load_lib.mac'
|
include '../../../../../KOSfuncs.inc'
|
||||||
include '../../../../../../programs/dll.inc'
|
include '../../../../../develop/libraries/box_lib/load_lib.mac'
|
||||||
|
include '../../../../../dll.inc'
|
||||||
include '../opengl_const.inc'
|
include '../opengl_const.inc'
|
||||||
|
|
||||||
@use_library
|
@use_library
|
||||||
@ -19,10 +16,10 @@ align 4
|
|||||||
start:
|
start:
|
||||||
load_library name_tgl, cur_dir_path, library_path, system_path, \
|
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
|
err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
|
||||||
cmp eax,-1
|
cmp eax,SF_TERMINATE_PROCESS
|
||||||
jz button.exit
|
jz button.exit
|
||||||
|
|
||||||
mcall 40,0x27
|
mcall SF_SET_EVENTS_MASK,0x27
|
||||||
|
|
||||||
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
|
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
|
||||||
stdcall [glEnable], GL_DEPTH_TEST
|
stdcall [glEnable], GL_DEPTH_TEST
|
||||||
@ -33,9 +30,9 @@ align 4
|
|||||||
red_win:
|
red_win:
|
||||||
call draw_window
|
call draw_window
|
||||||
|
|
||||||
align 4
|
align 16
|
||||||
still:
|
still:
|
||||||
mcall 10
|
mcall SF_CHECK_EVENT
|
||||||
cmp al,1
|
cmp al,1
|
||||||
jz red_win
|
jz red_win
|
||||||
cmp al,2
|
cmp al,2
|
||||||
@ -47,19 +44,19 @@ still:
|
|||||||
align 4
|
align 4
|
||||||
draw_window:
|
draw_window:
|
||||||
pushad
|
pushad
|
||||||
mcall 12,1
|
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||||
|
|
||||||
mov edx,0x33ffffff ;0x73ffffff
|
mov edx,0x33ffffff ;0x73ffffff
|
||||||
mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
|
|
||||||
mcall 12,2
|
mcall SF_REDRAW,SSF_END_DRAW
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
key:
|
key:
|
||||||
mcall 2
|
mcall SF_GET_KEY
|
||||||
|
|
||||||
cmp ah,27 ;Esc
|
cmp ah,27 ;Esc
|
||||||
je button.exit
|
je button.exit
|
||||||
@ -72,7 +69,7 @@ key:
|
|||||||
fadd dword[delt_size]
|
fadd dword[delt_size]
|
||||||
fstp dword[angle_z]
|
fstp dword[angle_z]
|
||||||
call draw_3d
|
call draw_3d
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
@@:
|
@@:
|
||||||
cmp ah,179 ;Right
|
cmp ah,179 ;Right
|
||||||
jne @f
|
jne @f
|
||||||
@ -80,31 +77,28 @@ key:
|
|||||||
fsub dword[delt_size]
|
fsub dword[delt_size]
|
||||||
fstp dword[angle_z]
|
fstp dword[angle_z]
|
||||||
call draw_3d
|
call draw_3d
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
button:
|
button:
|
||||||
mcall 17
|
mcall SF_GET_BUTTON
|
||||||
cmp ah,1
|
cmp ah,1
|
||||||
jne still
|
jne still
|
||||||
.exit:
|
.exit:
|
||||||
mcall -1
|
mcall SF_TERMINATE_PROCESS
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
|
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
|
||||||
align 4
|
|
||||||
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
|
||||||
;sizeof.TinyGLContext = 28
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
draw_3d:
|
draw_3d:
|
||||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||||
|
|
||||||
stdcall [glPushMatrix]
|
call [glPushMatrix]
|
||||||
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
||||||
|
|
||||||
stdcall [glScalef], 0.3,0.3,0.3
|
stdcall [glScalef], 0.3,0.3,0.3
|
||||||
@ -133,7 +127,7 @@ stdcall [glPushMatrix]
|
|||||||
stdcall [glVertex3f], -0.778, 0.778, 0.1
|
stdcall [glVertex3f], -0.778, 0.778, 0.1
|
||||||
stdcall [glEnd]
|
stdcall [glEnd]
|
||||||
|
|
||||||
stdcall [glPopMatrix]
|
call [glPopMatrix]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
angle_z dd 0.0
|
angle_z dd 0.0
|
||||||
@ -158,13 +152,17 @@ include '../export.inc'
|
|||||||
;--------------------------------------------------
|
;--------------------------------------------------
|
||||||
system_path db '/sys/lib/'
|
system_path db '/sys/lib/'
|
||||||
name_tgl db 'tinygl.obj',0
|
name_tgl db 'tinygl.obj',0
|
||||||
err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
|
|
||||||
head_f_i:
|
head_f_i:
|
||||||
head_f_l db 'System error',0
|
head_f_l db '"System error',0
|
||||||
err_message_import db 'Error on load import library tinygl.obj',0
|
err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
|
||||||
|
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
|
||||||
;--------------------------------------------------
|
;--------------------------------------------------
|
||||||
|
|
||||||
|
align 16
|
||||||
i_end:
|
i_end:
|
||||||
|
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
||||||
|
;sizeof.TinyGLContext = 28
|
||||||
rb 1024
|
rb 1024
|
||||||
stacktop:
|
stacktop:
|
||||||
cur_dir_path:
|
cur_dir_path:
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
use32
|
use32
|
||||||
org 0x0
|
org 0
|
||||||
db 'MENUET01'
|
db 'MENUET01'
|
||||||
dd 0x1
|
dd 1,start,i_end,mem,stacktop,0,cur_dir_path
|
||||||
dd start
|
|
||||||
dd i_end
|
|
||||||
dd mem,stacktop
|
|
||||||
dd 0,cur_dir_path
|
|
||||||
|
|
||||||
include '../../../../../../programs/proc32.inc'
|
include '../../../../../proc32.inc'
|
||||||
include '../../../../../../programs/macros.inc'
|
include '../../../../../macros.inc'
|
||||||
include '../../../../../../programs/develop/libraries/box_lib/load_lib.mac'
|
include '../../../../../KOSfuncs.inc'
|
||||||
include '../../../../../../programs/dll.inc'
|
include '../../../../../develop/libraries/box_lib/load_lib.mac'
|
||||||
|
include '../../../../../dll.inc'
|
||||||
include '../opengl_const.inc'
|
include '../opengl_const.inc'
|
||||||
|
|
||||||
@use_library
|
@use_library
|
||||||
@ -19,10 +16,10 @@ align 4
|
|||||||
start:
|
start:
|
||||||
load_library name_tgl, cur_dir_path, library_path, system_path, \
|
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
|
err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
|
||||||
cmp eax,-1
|
cmp eax,SF_TERMINATE_PROCESS
|
||||||
jz button.exit
|
jz button.exit
|
||||||
|
|
||||||
mcall 40,0x27
|
mcall SF_SET_EVENTS_MASK,0x27
|
||||||
|
|
||||||
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
|
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
|
||||||
stdcall [glEnable], GL_DEPTH_TEST
|
stdcall [glEnable], GL_DEPTH_TEST
|
||||||
@ -63,9 +60,9 @@ align 4
|
|||||||
red_win:
|
red_win:
|
||||||
call draw_window
|
call draw_window
|
||||||
|
|
||||||
align 4
|
align 16
|
||||||
still:
|
still:
|
||||||
mcall 10
|
mcall SF_CHECK_EVENT
|
||||||
cmp al,1
|
cmp al,1
|
||||||
jz red_win
|
jz red_win
|
||||||
cmp al,2
|
cmp al,2
|
||||||
@ -77,19 +74,19 @@ still:
|
|||||||
align 4
|
align 4
|
||||||
draw_window:
|
draw_window:
|
||||||
pushad
|
pushad
|
||||||
mcall 12,1
|
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||||
|
|
||||||
mov edx,0x33ffffff ;0x73ffffff
|
mov edx,0x33ffffff ;0x73ffffff
|
||||||
mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
|
|
||||||
mcall 12,2
|
mcall SF_REDRAW,SSF_END_DRAW
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
key:
|
key:
|
||||||
mcall 2
|
mcall SF_GET_KEY
|
||||||
|
|
||||||
cmp ah,27 ;Esc
|
cmp ah,27 ;Esc
|
||||||
je button.exit
|
je button.exit
|
||||||
@ -102,7 +99,7 @@ key:
|
|||||||
fadd dword[delt_size]
|
fadd dword[delt_size]
|
||||||
fstp dword[angle_z]
|
fstp dword[angle_z]
|
||||||
call draw_3d
|
call draw_3d
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
@@:
|
@@:
|
||||||
cmp ah,179 ;Right
|
cmp ah,179 ;Right
|
||||||
jne @f
|
jne @f
|
||||||
@ -110,31 +107,28 @@ key:
|
|||||||
fsub dword[delt_size]
|
fsub dword[delt_size]
|
||||||
fstp dword[angle_z]
|
fstp dword[angle_z]
|
||||||
call draw_3d
|
call draw_3d
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
button:
|
button:
|
||||||
mcall 17
|
mcall SF_GET_BUTTON
|
||||||
cmp ah,1
|
cmp ah,1
|
||||||
jne still
|
jne still
|
||||||
.exit:
|
.exit:
|
||||||
mcall -1
|
mcall SF_TERMINATE_PROCESS
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
|
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
|
||||||
align 4
|
|
||||||
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
|
||||||
;sizeof.TinyGLContext = 28
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
draw_3d:
|
draw_3d:
|
||||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||||
|
|
||||||
stdcall [glPushMatrix]
|
call [glPushMatrix]
|
||||||
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
||||||
stdcall [glScalef], 0.3,0.3,0.3
|
stdcall [glScalef], 0.3,0.3,0.3
|
||||||
|
|
||||||
@ -167,13 +161,17 @@ include '../export.inc'
|
|||||||
;--------------------------------------------------
|
;--------------------------------------------------
|
||||||
system_path db '/sys/lib/'
|
system_path db '/sys/lib/'
|
||||||
name_tgl db 'tinygl.obj',0
|
name_tgl db 'tinygl.obj',0
|
||||||
err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
|
|
||||||
head_f_i:
|
head_f_i:
|
||||||
head_f_l db 'System error',0
|
head_f_l db '"System error',0
|
||||||
err_message_import db 'Error on load import library tinygl.obj',0
|
err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
|
||||||
|
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
|
||||||
;--------------------------------------------------
|
;--------------------------------------------------
|
||||||
|
|
||||||
|
align 16
|
||||||
i_end:
|
i_end:
|
||||||
|
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
||||||
|
;sizeof.TinyGLContext = 28
|
||||||
rb 1024
|
rb 1024
|
||||||
stacktop:
|
stacktop:
|
||||||
cur_dir_path:
|
cur_dir_path:
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
use32
|
use32
|
||||||
org 0x0
|
org 0
|
||||||
db 'MENUET01'
|
db 'MENUET01'
|
||||||
dd 0x1
|
dd 1,start,i_end,mem,stacktop,0,cur_dir_path
|
||||||
dd start
|
|
||||||
dd i_end
|
|
||||||
dd mem,stacktop
|
|
||||||
dd 0,cur_dir_path
|
|
||||||
|
|
||||||
include '../../../../../../programs/proc32.inc'
|
include '../../../../../proc32.inc'
|
||||||
include '../../../../../../programs/macros.inc'
|
include '../../../../../macros.inc'
|
||||||
include '../../../../../../programs/develop/libraries/box_lib/load_lib.mac'
|
include '../../../../../KOSfuncs.inc'
|
||||||
include '../../../../../../programs/dll.inc'
|
include '../../../../../develop/libraries/box_lib/load_lib.mac'
|
||||||
|
include '../../../../../dll.inc'
|
||||||
include '../opengl_const.inc'
|
include '../opengl_const.inc'
|
||||||
|
|
||||||
@use_library
|
@use_library
|
||||||
@ -19,10 +16,10 @@ align 4
|
|||||||
start:
|
start:
|
||||||
load_library name_tgl, cur_dir_path, library_path, system_path, \
|
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
|
err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
|
||||||
cmp eax,-1
|
cmp eax,SF_TERMINATE_PROCESS
|
||||||
jz button.exit
|
jz button.exit
|
||||||
|
|
||||||
mcall 40,0x27
|
mcall SF_SET_EVENTS_MASK,0x27
|
||||||
|
|
||||||
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
|
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
|
||||||
;stdcall [glEnable], GL_DEPTH_TEST
|
;stdcall [glEnable], GL_DEPTH_TEST
|
||||||
@ -35,9 +32,9 @@ align 4
|
|||||||
red_win:
|
red_win:
|
||||||
call draw_window
|
call draw_window
|
||||||
|
|
||||||
align 4
|
align 16
|
||||||
still:
|
still:
|
||||||
mcall 10
|
mcall SF_CHECK_EVENT
|
||||||
cmp al,1
|
cmp al,1
|
||||||
jz red_win
|
jz red_win
|
||||||
cmp al,2
|
cmp al,2
|
||||||
@ -49,19 +46,19 @@ still:
|
|||||||
align 4
|
align 4
|
||||||
draw_window:
|
draw_window:
|
||||||
pushad
|
pushad
|
||||||
mcall 12,1
|
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||||
|
|
||||||
mov edx,0x33ffffff ;0x73ffffff
|
mov edx,0x33ffffff ;0x73ffffff
|
||||||
mcall 0,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
|
|
||||||
mcall 12,2
|
mcall SF_REDRAW,SSF_END_DRAW
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
key:
|
key:
|
||||||
mcall 2
|
mcall SF_GET_KEY
|
||||||
|
|
||||||
cmp ah,27 ;Esc
|
cmp ah,27 ;Esc
|
||||||
je button.exit
|
je button.exit
|
||||||
@ -74,7 +71,7 @@ key:
|
|||||||
fadd dword[delt_size]
|
fadd dword[delt_size]
|
||||||
fstp dword[angle_z]
|
fstp dword[angle_z]
|
||||||
call draw_3d
|
call draw_3d
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
@@:
|
@@:
|
||||||
cmp ah,179 ;Right
|
cmp ah,179 ;Right
|
||||||
jne @f
|
jne @f
|
||||||
@ -82,31 +79,28 @@ key:
|
|||||||
fsub dword[delt_size]
|
fsub dword[delt_size]
|
||||||
fstp dword[angle_z]
|
fstp dword[angle_z]
|
||||||
call draw_3d
|
call draw_3d
|
||||||
stdcall [kosglSwapBuffers]
|
call [kosglSwapBuffers]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
jmp still
|
jmp still
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
button:
|
button:
|
||||||
mcall 17
|
mcall SF_GET_BUTTON
|
||||||
cmp ah,1
|
cmp ah,1
|
||||||
jne still
|
jne still
|
||||||
.exit:
|
.exit:
|
||||||
mcall -1
|
mcall SF_TERMINATE_PROCESS
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
|
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
|
||||||
align 4
|
|
||||||
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
|
||||||
;sizeof.TinyGLContext = 28
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
draw_3d:
|
draw_3d:
|
||||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
|
||||||
|
|
||||||
stdcall [glPushMatrix]
|
call [glPushMatrix]
|
||||||
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
stdcall [glRotatef], [angle_z],0.0,0.0,1.0
|
||||||
|
|
||||||
stdcall [glBegin],GL_TRIANGLES
|
stdcall [glBegin],GL_TRIANGLES
|
||||||
@ -159,17 +153,21 @@ include '../export.inc'
|
|||||||
;--------------------------------------------------
|
;--------------------------------------------------
|
||||||
system_path db '/sys/lib/'
|
system_path db '/sys/lib/'
|
||||||
name_tgl db 'tinygl.obj',0
|
name_tgl db 'tinygl.obj',0
|
||||||
err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
|
|
||||||
head_f_i:
|
head_f_i:
|
||||||
head_f_l db 'System error',0
|
head_f_l db '"System error',0
|
||||||
err_message_import db 'Error on load import library tinygl.obj',0
|
err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
|
||||||
|
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
|
||||||
;--------------------------------------------------
|
;--------------------------------------------------
|
||||||
|
|
||||||
|
align 16
|
||||||
i_end:
|
i_end:
|
||||||
|
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
||||||
|
;sizeof.TinyGLContext = 28
|
||||||
rb 1024
|
rb 1024
|
||||||
stacktop:
|
stacktop:
|
||||||
cur_dir_path:
|
cur_dir_path:
|
||||||
rb 4096
|
rb 4096
|
||||||
library_path:
|
library_path:
|
||||||
rb 4096
|
rb 4096
|
||||||
mem:
|
mem:
|
||||||
|
@ -141,7 +141,7 @@ E_LIB glPolygonOffset ;(float, float)
|
|||||||
;E_LIB glDepthFunc(int)
|
;E_LIB glDepthFunc(int)
|
||||||
;E_LIB glBlendFunc(int, int)
|
;E_LIB glBlendFunc(int, int)
|
||||||
;E_LIB glTexEnvf(int, int, int)
|
;E_LIB glTexEnvf(int, int, int)
|
||||||
;E_LIB glOrtho(float, float, float, float, float, float)
|
E_LIB glOrtho ;(float, float, float, float, float, float)
|
||||||
;E_LIB glVertex2i(int, int)
|
;E_LIB glVertex2i(int, int)
|
||||||
;E_LIB glDepthMask(int)
|
;E_LIB glDepthMask(int)
|
||||||
;E_LIB glFogi(int, int)
|
;E_LIB glFogi(int, int)
|
||||||
|
@ -96,8 +96,7 @@ align 4
|
|||||||
proc glopLoadMatrix uses eax edi esi, context:dword, p:dword
|
proc glopLoadMatrix uses eax edi esi, context:dword, p:dword
|
||||||
mov eax,[context]
|
mov eax,[context]
|
||||||
mov edi,[eax+GLContext.matrix_mode]
|
mov edi,[eax+GLContext.matrix_mode]
|
||||||
shl edi,2
|
lea edi,[eax+4*edi]
|
||||||
add edi,eax
|
|
||||||
mov edi,dword[edi+GLContext.matrix_stack_ptr]
|
mov edi,dword[edi+GLContext.matrix_stack_ptr]
|
||||||
|
|
||||||
mov esi,[p]
|
mov esi,[p]
|
||||||
@ -112,8 +111,7 @@ align 4
|
|||||||
proc glopLoadIdentity uses eax ebx, context:dword, p:dword
|
proc glopLoadIdentity uses eax ebx, context:dword, p:dword
|
||||||
mov eax,[context]
|
mov eax,[context]
|
||||||
mov ebx,[eax+GLContext.matrix_mode]
|
mov ebx,[eax+GLContext.matrix_mode]
|
||||||
shl ebx,2
|
lea ebx,[eax+4*ebx]
|
||||||
add ebx,eax
|
|
||||||
|
|
||||||
stdcall gl_M4_Id,[ebx+GLContext.matrix_stack_ptr]
|
stdcall gl_M4_Id,[ebx+GLContext.matrix_stack_ptr]
|
||||||
gl_matrix_update eax,ebx
|
gl_matrix_update eax,ebx
|
||||||
@ -127,14 +125,12 @@ locals
|
|||||||
endl
|
endl
|
||||||
mov esi,[p]
|
mov esi,[p]
|
||||||
add esi,4
|
add esi,4
|
||||||
mov edi,ebp
|
lea edi,[ebp-sizeof.M4]
|
||||||
sub edi,sizeof.M4
|
|
||||||
stdcall gl_M4_Transpose,edi,esi ;транспонируем входную матрицу в локальную матрицу m
|
stdcall gl_M4_Transpose,edi,esi ;транспонируем входную матрицу в локальную матрицу m
|
||||||
|
|
||||||
mov eax,[context]
|
mov eax,[context]
|
||||||
mov esi,[eax+GLContext.matrix_mode]
|
mov esi,[eax+GLContext.matrix_mode]
|
||||||
shl esi,2
|
lea esi,[eax+4*esi]
|
||||||
add esi,eax
|
|
||||||
stdcall gl_M4_MulLeft,dword[esi+GLContext.matrix_stack_ptr],edi
|
stdcall gl_M4_MulLeft,dword[esi+GLContext.matrix_stack_ptr],edi
|
||||||
|
|
||||||
gl_matrix_update eax,edi
|
gl_matrix_update eax,edi
|
||||||
@ -149,9 +145,7 @@ proc glopPushMatrix uses eax ebx, context:dword, p:dword
|
|||||||
; assert( (c->matrix_stack_ptr[ebx] - c->matrix_stack[ebx] + 1 )
|
; assert( (c->matrix_stack_ptr[ebx] - c->matrix_stack[ebx] + 1 )
|
||||||
; < c->matrix_stack_depth_max[ebx] );
|
; < c->matrix_stack_depth_max[ebx] );
|
||||||
|
|
||||||
shl ebx,2
|
lea ebx,[eax+4*ebx+GLContext.matrix_stack_ptr]
|
||||||
add ebx,eax
|
|
||||||
add ebx,GLContext.matrix_stack_ptr
|
|
||||||
add dword[ebx],sizeof.M4
|
add dword[ebx],sizeof.M4
|
||||||
mov ebx,[ebx] ;ebx = ++context.matrix_stack_ptr[context.matrix_mode]
|
mov ebx,[ebx] ;ebx = ++context.matrix_stack_ptr[context.matrix_mode]
|
||||||
|
|
||||||
@ -171,8 +165,7 @@ proc glopPopMatrix uses eax ebx, context:dword, p:dword
|
|||||||
|
|
||||||
; assert( c->matrix_stack_ptr[n] > c->matrix_stack[n] );
|
; assert( c->matrix_stack_ptr[n] > c->matrix_stack[n] );
|
||||||
|
|
||||||
shl ebx,2
|
lea ebx,[eax+4*ebx]
|
||||||
add ebx,eax
|
|
||||||
sub dword[ebx+GLContext.matrix_stack_ptr],sizeof.M4
|
sub dword[ebx+GLContext.matrix_stack_ptr],sizeof.M4
|
||||||
|
|
||||||
gl_matrix_update eax,ebx
|
gl_matrix_update eax,ebx
|
||||||
@ -193,8 +186,7 @@ endl
|
|||||||
|
|
||||||
mov eax,[context]
|
mov eax,[context]
|
||||||
mov ebx,[p]
|
mov ebx,[p]
|
||||||
mov ecx,ebp
|
lea ecx,[ebp-sizeof.M4] ;ecx=&m
|
||||||
sub ecx,sizeof.M4 ;ecx=&m
|
|
||||||
finit
|
finit
|
||||||
fldpi
|
fldpi
|
||||||
fmul dword[ebx+4]
|
fmul dword[ebx+4]
|
||||||
@ -425,8 +417,7 @@ endl
|
|||||||
|
|
||||||
mov eax,[context]
|
mov eax,[context]
|
||||||
mov ebx,[eax+GLContext.matrix_mode]
|
mov ebx,[eax+GLContext.matrix_mode]
|
||||||
shl ebx,2
|
lea ebx,[eax+4*ebx]
|
||||||
add ebx,eax
|
|
||||||
stdcall gl_M4_MulLeft,dword[ebx+GLContext.matrix_stack_ptr],ecx
|
stdcall gl_M4_MulLeft,dword[ebx+GLContext.matrix_stack_ptr],ecx
|
||||||
gl_matrix_update eax,ebx
|
gl_matrix_update eax,ebx
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
@ -445,8 +436,7 @@ proc glopScale uses eax ebx ecx, context:dword, p:dword
|
|||||||
|
|
||||||
mov eax,[context]
|
mov eax,[context]
|
||||||
mov ebx,[eax+GLContext.matrix_mode]
|
mov ebx,[eax+GLContext.matrix_mode]
|
||||||
shl ebx,2
|
lea ebx,[eax+4*ebx]
|
||||||
add ebx,eax
|
|
||||||
mov ebx,[ebx+GLContext.matrix_stack_ptr] ;ebx = &m[0]
|
mov ebx,[ebx+GLContext.matrix_stack_ptr] ;ebx = &m[0]
|
||||||
|
|
||||||
fld dword[ecx+ 4] ;x
|
fld dword[ecx+ 4] ;x
|
||||||
@ -482,8 +472,7 @@ proc glopTranslate uses eax ebx ecx, context:dword, p:dword
|
|||||||
|
|
||||||
mov eax,[context]
|
mov eax,[context]
|
||||||
mov ebx,[eax+GLContext.matrix_mode]
|
mov ebx,[eax+GLContext.matrix_mode]
|
||||||
shl ebx,2
|
lea ebx,[eax+4*ebx]
|
||||||
add ebx,eax
|
|
||||||
mov ebx,[ebx+GLContext.matrix_stack_ptr] ;ebx = &m[0]
|
mov ebx,[ebx+GLContext.matrix_stack_ptr] ;ebx = &m[0]
|
||||||
|
|
||||||
fld dword[ecx+ 4] ;x
|
fld dword[ecx+ 4] ;x
|
||||||
@ -607,4 +596,94 @@ end if
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
align 4
|
||||||
|
proc glopOrtho uses eax ebx ecx, context:dword, p:dword
|
||||||
|
locals
|
||||||
|
x dd ?
|
||||||
|
y dd ?
|
||||||
|
A dd ?
|
||||||
|
B dd ?
|
||||||
|
C dd ?
|
||||||
|
D dd ?
|
||||||
|
m M4
|
||||||
|
endl
|
||||||
|
mov eax,[context]
|
||||||
|
mov ebx,[p]
|
||||||
|
|
||||||
|
fld dword[ebx+8]
|
||||||
|
fsub dword[ebx+4] ;st0 = (right-left)
|
||||||
|
fld1
|
||||||
|
fadd st0,st0 ;st0 = 2.0
|
||||||
|
fdiv st0,st1
|
||||||
|
fstp dword[x] ;x = 2.0 / (right-left)
|
||||||
|
fld dword[ebx+16]
|
||||||
|
fsub dword[ebx+12] ;st0 = (top-bottom)
|
||||||
|
fld1
|
||||||
|
fadd st0,st0 ;st0 = 2.0
|
||||||
|
fdiv st0,st1
|
||||||
|
fstp dword[y] ;y = 2.0 / (top-bottom)
|
||||||
|
fld dword[ebx+8]
|
||||||
|
fadd dword[ebx+4]
|
||||||
|
fchs ;st0 = -(right+left)
|
||||||
|
fdiv st0,st2 ;st2 = (right-left)
|
||||||
|
fstp dword[A] ;A = -(right+left) / (right-left)
|
||||||
|
fld dword[ebx+16]
|
||||||
|
fadd dword[ebx+12]
|
||||||
|
fchs ;st0 = -(top+bottom)
|
||||||
|
fdiv st0,st1 ;st1 = (top-bottom)
|
||||||
|
fstp dword[B] ;B = -(top+bottom) / (top-bottom)
|
||||||
|
fld dword[ebx+24]
|
||||||
|
fsub dword[ebx+20] ;st0 = (farp-near)
|
||||||
|
fld1
|
||||||
|
fadd st0,st0
|
||||||
|
fchs ;st0 = -2.0
|
||||||
|
fdiv st0,st1
|
||||||
|
fstp dword[C] ;C = -2.0 / (farp-near)
|
||||||
|
fld dword[ebx+24]
|
||||||
|
fadd dword[ebx+20] ;st0 = farp+near
|
||||||
|
fchs ;st0 = -(farp+near)
|
||||||
|
fdiv st0,st1
|
||||||
|
fstp dword[D] ;D = -(farp*near) / (farp-near)
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
|
||||||
|
lea ecx,[ebp-sizeof.M4]
|
||||||
|
|
||||||
|
mov ebx,[x]
|
||||||
|
mov dword[ecx],ebx
|
||||||
|
mov dword[ecx+4],0.0
|
||||||
|
mov dword[ecx+8],0.0
|
||||||
|
mov ebx,[A]
|
||||||
|
mov dword[ecx+12],ebx
|
||||||
|
mov dword[ecx+16],0.0
|
||||||
|
mov ebx,[y]
|
||||||
|
mov dword[ecx+20],ebx
|
||||||
|
mov dword[ecx+24],0.0
|
||||||
|
mov ebx,[B]
|
||||||
|
mov dword[ecx+28],ebx
|
||||||
|
mov dword[ecx+32],0.0
|
||||||
|
mov dword[ecx+36],0.0
|
||||||
|
mov ebx,[C]
|
||||||
|
mov dword[ecx+40],ebx
|
||||||
|
mov ebx,[D]
|
||||||
|
mov dword[ecx+44],ebx
|
||||||
|
mov dword[ecx+48],0.0
|
||||||
|
mov dword[ecx+52],0.0
|
||||||
|
mov dword[ecx+56],0.0
|
||||||
|
mov dword[ecx+60],1.0
|
||||||
|
|
||||||
|
mov ebx,[eax+GLContext.matrix_mode]
|
||||||
|
lea ebx,[eax+4*ebx]
|
||||||
|
stdcall gl_M4_MulLeft,dword[ebx+GLContext.matrix_stack_ptr],ecx
|
||||||
|
|
||||||
|
if DEBUG ;glopOrtho
|
||||||
|
stdcall gl_print_matrix,ecx,4
|
||||||
|
stdcall gl_print_matrix,dword[ebx+GLContext.matrix_stack_ptr],4
|
||||||
|
end if
|
||||||
|
gl_matrix_update eax,ebx
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
@ -22,6 +22,7 @@ ADD_OP Scale,3,'%f %f %f'
|
|||||||
|
|
||||||
ADD_OP Viewport,4,'%d %d %d %d'
|
ADD_OP Viewport,4,'%d %d %d %d'
|
||||||
ADD_OP Frustum,6,'%f %f %f %f %f %f'
|
ADD_OP Frustum,6,'%f %f %f %f %f %f'
|
||||||
|
ADD_OP Ortho,6,'%f %f %f %f %f %f'
|
||||||
|
|
||||||
ADD_OP Material,6,'%C %C %f %f %f %f'
|
ADD_OP Material,6,'%C %C %f %f %f %f'
|
||||||
ADD_OP ColorMaterial,2,'%C %C'
|
ADD_OP ColorMaterial,2,'%C %C'
|
||||||
|
@ -58,8 +58,7 @@ endl
|
|||||||
mov dword[q+8],ecx
|
mov dword[q+8],ecx
|
||||||
mov esi,[p]
|
mov esi,[p]
|
||||||
add esi,4
|
add esi,4
|
||||||
mov edi,ebp
|
lea edi,[ebp-16] ;edi = &q[3]
|
||||||
sub edi,16 ;edi = &q[3]
|
|
||||||
mov ecx,4
|
mov ecx,4
|
||||||
rep movsd
|
rep movsd
|
||||||
;mov edi,ebp
|
;mov edi,ebp
|
||||||
@ -144,16 +143,14 @@ if DEBUG ;context.matrix_stack_ptr[0]
|
|||||||
stdcall gl_print_matrix,dword[edx+GLContext.matrix_stack_ptr],4
|
stdcall gl_print_matrix,dword[edx+GLContext.matrix_stack_ptr],4
|
||||||
end if
|
end if
|
||||||
; precompute inverse modelview
|
; precompute inverse modelview
|
||||||
mov ebx,ebp
|
lea ebx,[ebp-sizeof.M4]
|
||||||
sub ebx,sizeof.M4
|
|
||||||
stdcall gl_M4_Inv, ebx,dword[edx+GLContext.matrix_stack_ptr]
|
stdcall gl_M4_Inv, ebx,dword[edx+GLContext.matrix_stack_ptr]
|
||||||
if DEBUG ;tmp
|
if DEBUG ;tmp
|
||||||
stdcall dbg_print,txt_sp,txt_nl
|
stdcall dbg_print,txt_sp,txt_nl
|
||||||
stdcall gl_print_matrix,ebx,4
|
stdcall gl_print_matrix,ebx,4
|
||||||
end if
|
end if
|
||||||
push ebx
|
push ebx
|
||||||
mov ebx,edx
|
lea ebx,[edx+GLContext.matrix_model_view_inv]
|
||||||
add ebx,GLContext.matrix_model_view_inv
|
|
||||||
stdcall gl_M4_Transpose, ebx
|
stdcall gl_M4_Transpose, ebx
|
||||||
if DEBUG ;context.matrix_model_view_inv
|
if DEBUG ;context.matrix_model_view_inv
|
||||||
stdcall dbg_print,txt_sp,txt_nl
|
stdcall dbg_print,txt_sp,txt_nl
|
||||||
@ -162,8 +159,7 @@ end if
|
|||||||
jmp .end_if_0
|
jmp .end_if_0
|
||||||
align 4
|
align 4
|
||||||
@@:
|
@@:
|
||||||
mov ecx,edx
|
lea ecx,[edx+GLContext.matrix_model_projection]
|
||||||
add ecx,GLContext.matrix_model_projection
|
|
||||||
; precompute projection matrix
|
; precompute projection matrix
|
||||||
stdcall gl_M4_Mul, ecx,dword[edx+GLContext.matrix_stack_ptr+4],dword[edx+GLContext.matrix_stack_ptr]
|
stdcall gl_M4_Mul, ecx,dword[edx+GLContext.matrix_stack_ptr+4],dword[edx+GLContext.matrix_stack_ptr]
|
||||||
|
|
||||||
@ -192,8 +188,7 @@ align 4
|
|||||||
.end_if_0:
|
.end_if_0:
|
||||||
|
|
||||||
; test if the texture matrix is not Identity
|
; test if the texture matrix is not Identity
|
||||||
mov eax,edx
|
lea eax,[edx+GLContext.matrix_stack_ptr+8]
|
||||||
add eax,GLContext.matrix_stack_ptr+8
|
|
||||||
stdcall gl_M4_IsId,eax
|
stdcall gl_M4_IsId,eax
|
||||||
xor eax,1
|
xor eax,1
|
||||||
mov dword[edx+GLContext.apply_texture_matrix],eax
|
mov dword[edx+GLContext.apply_texture_matrix],eax
|
||||||
@ -265,9 +260,9 @@ align 4
|
|||||||
; eye coordinates needed for lighting
|
; eye coordinates needed for lighting
|
||||||
mov ebx,dword[eax+GLContext.matrix_stack_ptr]
|
mov ebx,dword[eax+GLContext.matrix_stack_ptr]
|
||||||
finit
|
finit
|
||||||
fld dword[edx+offs_vert_coord+offs_X]
|
fld dword[edx+GLVertex.coord+offs_X]
|
||||||
fld dword[edx+offs_vert_coord+offs_Y]
|
fld dword[edx+GLVertex.coord+offs_Y]
|
||||||
fld dword[edx+offs_vert_coord+offs_Z]
|
fld dword[edx+GLVertex.coord+offs_Z]
|
||||||
|
|
||||||
mov ecx,4
|
mov ecx,4
|
||||||
.cycle_0:
|
.cycle_0:
|
||||||
@ -280,7 +275,7 @@ align 4
|
|||||||
fmul st0,st2 ;st0 *= v.coord.Z
|
fmul st0,st2 ;st0 *= v.coord.Z
|
||||||
fadd dword[ebx+12] ;st0 += m[3]
|
fadd dword[ebx+12] ;st0 += m[3]
|
||||||
faddp ;st0 = v.ec.X
|
faddp ;st0 = v.ec.X
|
||||||
fstp dword[edx+offs_vert_ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
|
fstp dword[edx+GLVertex.ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
|
||||||
add ebx,16 ;следущая строка матрицы
|
add ebx,16 ;следущая строка матрицы
|
||||||
add edx,4 ;следущая координата вектора
|
add edx,4 ;следущая координата вектора
|
||||||
loop .cycle_0
|
loop .cycle_0
|
||||||
@ -295,10 +290,10 @@ align 4
|
|||||||
mov ebx,dword[eax+GLContext.matrix_stack_ptr+4]
|
mov ebx,dword[eax+GLContext.matrix_stack_ptr+4]
|
||||||
mov edx,[v]
|
mov edx,[v]
|
||||||
|
|
||||||
fld dword[edx+offs_vert_ec+offs_X]
|
fld dword[edx+GLVertex.ec+offs_X]
|
||||||
fld dword[edx+offs_vert_ec+offs_Y]
|
fld dword[edx+GLVertex.ec+offs_Y]
|
||||||
fld dword[edx+offs_vert_ec+offs_Z]
|
fld dword[edx+GLVertex.ec+offs_Z]
|
||||||
fld dword[edx+offs_vert_ec+offs_W]
|
fld dword[edx+GLVertex.ec+offs_W]
|
||||||
|
|
||||||
mov ecx,4
|
mov ecx,4
|
||||||
.cycle_1:
|
.cycle_1:
|
||||||
@ -313,7 +308,7 @@ align 4
|
|||||||
fld dword[ebx+12] ;st0 = m[3]
|
fld dword[ebx+12] ;st0 = m[3]
|
||||||
fmul st0,st2 ;st0 *= v.ec.W
|
fmul st0,st2 ;st0 *= v.ec.W
|
||||||
faddp ;st0 = v.pc.X
|
faddp ;st0 = v.pc.X
|
||||||
fstp dword[edx+offs_vert_pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + v.ec.W * m[3]
|
fstp dword[edx+GLVertex.pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + v.ec.W * m[3]
|
||||||
add ebx,16 ;следущая строка матрицы
|
add ebx,16 ;следущая строка матрицы
|
||||||
add edx,4 ;следущая координата вектора
|
add edx,4 ;следущая координата вектора
|
||||||
loop .cycle_1
|
loop .cycle_1
|
||||||
@ -326,17 +321,15 @@ align 4
|
|||||||
ffree st0
|
ffree st0
|
||||||
fincstp
|
fincstp
|
||||||
|
|
||||||
mov ebx,eax
|
lea ebx,[eax+GLContext.matrix_model_view_inv]
|
||||||
add ebx,GLContext.matrix_model_view_inv
|
lea edi,[eax+GLContext.current_normal]
|
||||||
mov edi,eax
|
|
||||||
add edi,GLContext.current_normal
|
|
||||||
mov edx,[v]
|
mov edx,[v]
|
||||||
|
|
||||||
fld dword[edi] ;edi = &n
|
fld dword[edi] ;edi = &n
|
||||||
fld dword[edi+offs_Y]
|
fld dword[edi+offs_Y]
|
||||||
fld dword[edi+offs_Z]
|
fld dword[edi+offs_Z]
|
||||||
|
|
||||||
add edx,offs_vert_normal
|
add edx,GLVertex.normal
|
||||||
|
|
||||||
fld dword[ebx] ;st0 = m[0]
|
fld dword[ebx] ;st0 = m[0]
|
||||||
fmul st0,st3 ;st0 *= n.X
|
fmul st0,st3 ;st0 *= n.X
|
||||||
@ -376,16 +369,14 @@ align 4
|
|||||||
.els_0:
|
.els_0:
|
||||||
; no eye coordinates needed, no normal
|
; no eye coordinates needed, no normal
|
||||||
; NOTE: W = 1 is assumed
|
; NOTE: W = 1 is assumed
|
||||||
mov ebx,eax
|
lea ebx,[eax+GLContext.matrix_model_projection]
|
||||||
add ebx,GLContext.matrix_model_projection
|
|
||||||
|
|
||||||
finit
|
finit
|
||||||
fld dword[edx+offs_vert_coord+offs_X]
|
fld dword[edx+GLVertex.coord+offs_X]
|
||||||
fld dword[edx+offs_vert_coord+offs_Y]
|
fld dword[edx+GLVertex.coord+offs_Y]
|
||||||
fld dword[edx+offs_vert_coord+offs_Z]
|
fld dword[edx+GLVertex.coord+offs_Z]
|
||||||
|
|
||||||
mov esi,edx
|
lea esi,[edx+GLVertex.pc]
|
||||||
add esi,offs_vert_pc
|
|
||||||
|
|
||||||
fld dword[ebx] ;st0 = m[0]
|
fld dword[ebx] ;st0 = m[0]
|
||||||
fmul st0,st3 ;st0 *= v.coord.X
|
fmul st0,st3 ;st0 *= v.coord.X
|
||||||
@ -449,13 +440,13 @@ align 4
|
|||||||
if DEBUG ;gl_vertex_transform
|
if DEBUG ;gl_vertex_transform
|
||||||
stdcall dbg_print,f_vt,txt_nl
|
stdcall dbg_print,f_vt,txt_nl
|
||||||
mov edx,[v]
|
mov edx,[v]
|
||||||
add edx,offs_vert_pc
|
add edx,GLVertex.pc
|
||||||
stdcall gl_print_matrix,edx,1
|
stdcall gl_print_matrix,edx,1
|
||||||
end if
|
end if
|
||||||
mov edx,[v]
|
mov edx,[v]
|
||||||
stdcall gl_clipcode, dword[edx+offs_vert_pc+offs_X], dword[edx+offs_vert_pc+offs_Y],\
|
stdcall gl_clipcode, dword[edx+GLVertex.pc+offs_X], dword[edx+GLVertex.pc+offs_Y],\
|
||||||
dword[edx+offs_vert_pc+offs_Z], dword[edx+offs_vert_pc+offs_W]
|
dword[edx+GLVertex.pc+offs_Z], dword[edx+GLVertex.pc+offs_W]
|
||||||
mov dword[edx+offs_vert_clip_code],eax
|
mov dword[edx+GLVertex.clip_code],eax
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
@ -503,8 +494,7 @@ pushad
|
|||||||
|
|
||||||
mov esi,[p]
|
mov esi,[p]
|
||||||
add esi,4
|
add esi,4
|
||||||
mov edi,ebx
|
lea edi,[ebx+GLVertex.coord] ;edi = &v.coord
|
||||||
add edi,offs_vert_coord ;edi = &v.coord
|
|
||||||
mov ecx,4
|
mov ecx,4
|
||||||
rep movsd
|
rep movsd
|
||||||
|
|
||||||
@ -517,10 +507,8 @@ pushad
|
|||||||
jmp @f
|
jmp @f
|
||||||
align 4
|
align 4
|
||||||
.els_0:
|
.els_0:
|
||||||
mov esi,edx
|
lea esi,[edx+GLContext.current_color]
|
||||||
add esi,GLContext.current_color
|
lea edi,[ebx+GLVertex.color] ;edi = &v.color
|
||||||
mov edi,ebx
|
|
||||||
add edi,offs_vert_color ;edi = &v.color
|
|
||||||
mov ecx,4
|
mov ecx,4
|
||||||
rep movsd
|
rep movsd
|
||||||
@@:
|
@@:
|
||||||
@ -530,32 +518,28 @@ align 4
|
|||||||
je @f
|
je @f
|
||||||
cmp dword[edx+GLContext.apply_texture_matrix],0
|
cmp dword[edx+GLContext.apply_texture_matrix],0
|
||||||
je .els_1
|
je .els_1
|
||||||
mov eax,edx
|
lea eax,[edx+GLContext.current_tex_coord]
|
||||||
add eax,GLContext.current_tex_coord
|
|
||||||
push eax ;&context.current_tex_coord
|
push eax ;&context.current_tex_coord
|
||||||
mov eax,ebx
|
lea eax,[ebx+GLVertex.tex_coord]
|
||||||
add eax,offs_vert_tex_coord
|
|
||||||
stdcall gl_M4_MulV4, eax, dword[edx+GLContext.matrix_stack_ptr+8]
|
stdcall gl_M4_MulV4, eax, dword[edx+GLContext.matrix_stack_ptr+8]
|
||||||
jmp @f
|
jmp @f
|
||||||
align 4
|
align 4
|
||||||
.els_1:
|
.els_1:
|
||||||
mov esi,edx
|
lea esi,[edx+GLContext.current_tex_coord]
|
||||||
add esi,GLContext.current_tex_coord
|
lea edi,[ebx+GLVertex.tex_coord]
|
||||||
mov edi,ebx
|
|
||||||
add edi,offs_vert_tex_coord
|
|
||||||
mov ecx,4
|
mov ecx,4
|
||||||
rep movsd
|
rep movsd
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
; precompute the mapping to the viewport
|
; precompute the mapping to the viewport
|
||||||
cmp dword[ebx+offs_vert_clip_code],0
|
cmp dword[ebx+GLVertex.clip_code],0
|
||||||
jne @f
|
jne @f
|
||||||
stdcall gl_transform_to_viewport, edx,ebx
|
stdcall gl_transform_to_viewport, edx,ebx
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
; edge flag
|
; edge flag
|
||||||
mov eax,[edx+GLContext.current_edge_flag]
|
mov eax,[edx+GLContext.current_edge_flag]
|
||||||
mov dword[ebx+offs_vert_edge_flag],eax ;v.edge_flag = context.current_edge_flag
|
mov dword[ebx+GLVertex.edge_flag],eax ;v.edge_flag = context.current_edge_flag
|
||||||
|
|
||||||
cmp dword[edx+GLContext.begin_type],GL_POINTS
|
cmp dword[edx+GLContext.begin_type],GL_POINTS
|
||||||
jne @f
|
jne @f
|
||||||
@ -585,8 +569,7 @@ align 4
|
|||||||
cmp dword[n],1
|
cmp dword[n],1
|
||||||
jne .els_2
|
jne .els_2
|
||||||
mov esi,[edx+GLContext.vertex]
|
mov esi,[edx+GLContext.vertex]
|
||||||
mov edi,esi
|
lea edi,[esi+2*sizeof.GLVertex]
|
||||||
add edi,2*sizeof.GLVertex
|
|
||||||
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
||||||
rep movsd ;context.vertex[2] = context.vertex[0]
|
rep movsd ;context.vertex[2] = context.vertex[0]
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
@ -594,12 +577,9 @@ align 4
|
|||||||
.els_2:
|
.els_2:
|
||||||
cmp dword[n],2
|
cmp dword[n],2
|
||||||
jne .end_f ;else if (n == 2)
|
jne .end_f ;else if (n == 2)
|
||||||
mov eax,[edx+GLContext.vertex]
|
mov edi,[edx+GLContext.vertex]
|
||||||
push eax
|
lea esi,[edi+sizeof.GLVertex]
|
||||||
mov edi,eax
|
stdcall gl_draw_line, edx, esi, edi
|
||||||
add eax,sizeof.GLVertex
|
|
||||||
mov esi,eax
|
|
||||||
stdcall gl_draw_line, edx, eax
|
|
||||||
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
||||||
rep movsd ;context.vertex[0] = context.vertex[1]
|
rep movsd ;context.vertex[0] = context.vertex[1]
|
||||||
mov dword[n],1
|
mov dword[n],1
|
||||||
@ -662,12 +642,10 @@ align 4
|
|||||||
jne .end_f
|
jne .end_f
|
||||||
mov eax,[edx+GLContext.vertex]
|
mov eax,[edx+GLContext.vertex]
|
||||||
mov [esp-12],eax
|
mov [esp-12],eax
|
||||||
add eax,sizeof.GLVertex
|
lea edi,[eax+sizeof.GLVertex]
|
||||||
mov [esp-8],eax
|
mov [esp-8],edi
|
||||||
mov edi,eax
|
lea esi,[edi+sizeof.GLVertex]
|
||||||
add eax,sizeof.GLVertex
|
mov [esp-4],esi
|
||||||
mov [esp-4],eax
|
|
||||||
mov esi,eax
|
|
||||||
sub esp,12
|
sub esp,12
|
||||||
stdcall gl_draw_triangle, edx ;v0,v1,v2
|
stdcall gl_draw_triangle, edx ;v0,v1,v2
|
||||||
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
|
||||||
@ -682,15 +660,15 @@ align 4
|
|||||||
jne .end_f
|
jne .end_f
|
||||||
mov eax,[edx+GLContext.vertex]
|
mov eax,[edx+GLContext.vertex]
|
||||||
add eax,2*sizeof.GLVertex
|
add eax,2*sizeof.GLVertex
|
||||||
mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[2].edge_flag = 0
|
mov dword[eax+GLVertex.edge_flag],0 ;context.vertex[2].edge_flag = 0
|
||||||
push eax
|
push eax
|
||||||
sub eax,sizeof.GLVertex
|
sub eax,sizeof.GLVertex
|
||||||
push eax
|
push eax
|
||||||
sub eax,sizeof.GLVertex
|
sub eax,sizeof.GLVertex
|
||||||
stdcall gl_draw_triangle, edx,eax ;v0,v1,v2
|
stdcall gl_draw_triangle, edx,eax ;v0,v1,v2
|
||||||
mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[0].edge_flag = 0
|
mov dword[eax+GLVertex.edge_flag],0 ;context.vertex[0].edge_flag = 0
|
||||||
add eax,2*sizeof.GLVertex
|
add eax,2*sizeof.GLVertex
|
||||||
mov dword[eax+offs_vert_edge_flag],1 ;context.vertex[2].edge_flag = 1
|
mov dword[eax+GLVertex.edge_flag],1 ;context.vertex[2].edge_flag = 1
|
||||||
add eax,sizeof.GLVertex
|
add eax,sizeof.GLVertex
|
||||||
push eax
|
push eax
|
||||||
sub eax,sizeof.GLVertex
|
sub eax,sizeof.GLVertex
|
||||||
|
Loading…
Reference in New Issue
Block a user