add function 'gluPerspective',

fix function 'glFrustum'

git-svn-id: svn://kolibrios.org@8059 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2020-09-09 11:56:39 +00:00
parent b81504b267
commit 5531c1c36c
4 changed files with 93 additions and 33 deletions

View File

@ -538,29 +538,23 @@ endl
endp endp
align 4 align 4
proc glFrustum uses eax, left:dword,right:dword,bottom:dword,top:dword,\ proc glFrustum uses eax, left:qword, right:qword, bottom:qword, top:qword,\
near:dword,farv:dword near:qword, farv:qword
locals locals
p rd 7 p rd 7
endl endl
mov dword[p],OP_Frustum mov dword[p],OP_Frustum
mov eax,[left] fld qword[left]
fld qword[eax]
fstp dword[p+4] fstp dword[p+4]
mov eax,[right] fld qword[right]
fld qword[eax]
fstp dword[p+8] fstp dword[p+8]
mov eax,[bottom] fld qword[bottom]
fld qword[eax]
fstp dword[p+12] fstp dword[p+12]
mov eax,[top] fld qword[top]
fld qword[eax]
fstp dword[p+16] fstp dword[p+16]
mov eax,[near] fld qword[near]
fld qword[eax]
fstp dword[p+20] fstp dword[p+20]
mov eax,[farv] fld qword[farv]
fld qword[eax]
fstp dword[p+24] fstp dword[p+24]
mov eax,ebp mov eax,ebp

View File

@ -1,5 +1,5 @@
use32 use32
org 0x0 org 0
db 'MENUET01' db 'MENUET01'
dd 1,start,i_end,mem,stacktop,0,cur_dir_path dd 1,start,i_end,mem,stacktop,0,cur_dir_path
@ -18,6 +18,13 @@ macro matr_cell c_funct,c_param,funct,param, dia
dia dword[esp-4*(c_param*(c_funct-funct)+(1+c_param-param))] dia dword[esp-4*(c_param*(c_funct-funct)+(1+c_param-param))]
} }
;Так как некоторые извращенческие функции OpenGL воспринимают только параметры
;типа double (8 байт) то придется пихать их в стек макросом glpush
macro glpush GLDoubleVar {
push dword[GLDoubleVar+4]
push dword[GLDoubleVar]
}
align 4 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, \
@ -65,6 +72,21 @@ start:
align 4 align 4
red_win: red_win:
call draw_window call draw_window
mcall SF_THREAD_INFO,procinfo,-1
mov eax,dword[procinfo.box.height]
cmp eax,120
jge @f
mov eax,120 ;min size
@@:
sub eax,42
mov ebx,dword[procinfo.box.width]
cmp ebx,200
jge @f
mov ebx,200
@@:
sub ebx,10
stdcall reshape, ebx,eax
.end0:
align 16 align 16
still: still:
@ -93,12 +115,11 @@ a2 dd 0.3
; new window size or exposure ; new window size or exposure
align 4 align 4
proc reshape uses ebx ecx, width:dword, height:dword proc reshape, width:dword, height:dword
locals locals
h dq ? h dq ?
mh dq ? mh dq ?
endl endl
stdcall [glViewport], 0, 0, [width], [height] stdcall [glViewport], 0, 0, [width], [height]
stdcall [glMatrixMode], GL_PROJECTION stdcall [glMatrixMode], GL_PROJECTION
stdcall [glLoadIdentity] stdcall [glLoadIdentity]
@ -107,11 +128,15 @@ endl
fst qword[h] ;h = height / width fst qword[h] ;h = height / width
fchs fchs
fstp qword[mh] fstp qword[mh]
mov ebx,ebp
sub ebx,8 glpush p6
mov ecx,ebp glpush p5
sub ecx,16 glpush h
stdcall [glFrustum], dword p1, dword p2, ebx, ecx, dword p5, dword p6 glpush mh
glpush p2
glpush p1
call [glFrustum]
stdcall [glMatrixMode], GL_MODELVIEW stdcall [glMatrixMode], GL_MODELVIEW
stdcall [glLoadIdentity] stdcall [glLoadIdentity]
stdcall [glTranslatef], 0.0, 0.0, -40.0 stdcall [glTranslatef], 0.0, 0.0, -40.0
@ -198,7 +223,6 @@ key:
fstp dword[view_roty] fstp dword[view_roty]
call draw_3d call draw_3d
@@: @@:
jmp still jmp still
align 4 align 4
@ -220,10 +244,6 @@ title3: db 'ESC - exit Arrow keys - rotate +/- zoom'
fps: db 'FPS:' fps: db 'FPS:'
.end: db 0 .end: db 0
align 4
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
align 16 align 16
draw_3d: draw_3d:
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT
@ -887,14 +907,18 @@ 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 align 16
i_end: i_end:
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
;sizeof.TinyGLContext = 28
procinfo process_information
rb 4096 rb 4096
stacktop: stacktop:
cur_dir_path: cur_dir_path:

View File

@ -161,6 +161,7 @@ E_LIB glClose ;(void)
; glu functions ; glu functions
; ;
E_LIB gluPerspective ;(double, double, double, double)
E_LIB gluNewQuadric E_LIB gluNewQuadric
E_LIB gluDeleteQuadric E_LIB gluDeleteQuadric
E_LIB gluQuadricDrawStyle E_LIB gluQuadricDrawStyle

View File

@ -12,6 +12,13 @@ offs_qobj_TextureFlag equ 8
offs_qobj_Normals equ 12 offs_qobj_Normals equ 12
offs_qobj_ErrorFunc equ 16 offs_qobj_ErrorFunc equ 16
;Так как некоторые извращенческие функции OpenGL воспринимают только параметры
;типа double (8 байт) то придется пихать их в стек макросом glpush
macro glpush GLDoubleVar {
push dword[GLDoubleVar+4]
push dword[GLDoubleVar]
}
;void drawTorus(float rc, int numc, float rt, int numt) ;void drawTorus(float rc, int numc, float rt, int numt)
;{ ;{
;} ;}
@ -20,9 +27,43 @@ offs_qobj_ErrorFunc equ 16
;{ ;{
;} ;}
;void gluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar ) align 4
;{ an360f dd 360.0
;}
align 16
proc gluPerspective, fovy:qword, aspect:qword, zNear:qword, zFar:qword
locals
mfW dq ?
fW dq ?
mfH dq ?
fH dq ?
endl
fldpi
fmul qword[fovy]
fdiv dword[an360f]
fptan
ffree st0 ;выкидываем 1.0 которая осталось после вычисления тангенса
fincstp
fmul qword[zNear]
fld st0
fchs
fstp qword[mfH]
fst qword[fH]
fmul qword[aspect]
fld st0
fchs
fstp qword[mfW]
fstp qword[fW]
glpush zFar
glpush zNear
glpush fH
glpush mfH
glpush fW
glpush mfW
call glFrustum
ret
endp
;void gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, ;void gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez,
; GLdouble centerx, GLdouble centery, GLdouble centerz, ; GLdouble centerx, GLdouble centery, GLdouble centerz,