forked from KolibriOS/kolibrios
add function 'gluPerspective',
fix function 'glFrustum' git-svn-id: svn://kolibrios.org@8059 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b81504b267
commit
5531c1c36c
@ -538,29 +538,23 @@ endl
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc glFrustum uses eax, left:dword,right:dword,bottom:dword,top:dword,\
|
||||
near:dword,farv:dword
|
||||
proc glFrustum uses eax, left:qword, right:qword, bottom:qword, top:qword,\
|
||||
near:qword, farv:qword
|
||||
locals
|
||||
p rd 7
|
||||
endl
|
||||
mov dword[p],OP_Frustum
|
||||
mov eax,[left]
|
||||
fld qword[eax]
|
||||
fld qword[left]
|
||||
fstp dword[p+4]
|
||||
mov eax,[right]
|
||||
fld qword[eax]
|
||||
fld qword[right]
|
||||
fstp dword[p+8]
|
||||
mov eax,[bottom]
|
||||
fld qword[eax]
|
||||
fld qword[bottom]
|
||||
fstp dword[p+12]
|
||||
mov eax,[top]
|
||||
fld qword[eax]
|
||||
fld qword[top]
|
||||
fstp dword[p+16]
|
||||
mov eax,[near]
|
||||
fld qword[eax]
|
||||
fld qword[near]
|
||||
fstp dword[p+20]
|
||||
mov eax,[farv]
|
||||
fld qword[eax]
|
||||
fld qword[farv]
|
||||
fstp dword[p+24]
|
||||
|
||||
mov eax,ebp
|
||||
|
@ -1,5 +1,5 @@
|
||||
use32
|
||||
org 0x0
|
||||
org 0
|
||||
db 'MENUET01'
|
||||
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))]
|
||||
}
|
||||
|
||||
;Так как некоторые извращенческие функции OpenGL воспринимают только параметры
|
||||
;типа double (8 байт) то придется пихать их в стек макросом glpush
|
||||
macro glpush GLDoubleVar {
|
||||
push dword[GLDoubleVar+4]
|
||||
push dword[GLDoubleVar]
|
||||
}
|
||||
|
||||
align 4
|
||||
start:
|
||||
load_library name_tgl, cur_dir_path, library_path, system_path, \
|
||||
@ -65,6 +72,21 @@ start:
|
||||
align 4
|
||||
red_win:
|
||||
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
|
||||
still:
|
||||
@ -93,12 +115,11 @@ a2 dd 0.3
|
||||
|
||||
; new window size or exposure
|
||||
align 4
|
||||
proc reshape uses ebx ecx, width:dword, height:dword
|
||||
proc reshape, width:dword, height:dword
|
||||
locals
|
||||
h dq ?
|
||||
mh dq ?
|
||||
endl
|
||||
|
||||
stdcall [glViewport], 0, 0, [width], [height]
|
||||
stdcall [glMatrixMode], GL_PROJECTION
|
||||
stdcall [glLoadIdentity]
|
||||
@ -107,11 +128,15 @@ endl
|
||||
fst qword[h] ;h = height / width
|
||||
fchs
|
||||
fstp qword[mh]
|
||||
mov ebx,ebp
|
||||
sub ebx,8
|
||||
mov ecx,ebp
|
||||
sub ecx,16
|
||||
stdcall [glFrustum], dword p1, dword p2, ebx, ecx, dword p5, dword p6
|
||||
|
||||
glpush p6
|
||||
glpush p5
|
||||
glpush h
|
||||
glpush mh
|
||||
glpush p2
|
||||
glpush p1
|
||||
call [glFrustum]
|
||||
|
||||
stdcall [glMatrixMode], GL_MODELVIEW
|
||||
stdcall [glLoadIdentity]
|
||||
stdcall [glTranslatef], 0.0, 0.0, -40.0
|
||||
@ -198,7 +223,6 @@ key:
|
||||
fstp dword[view_roty]
|
||||
call draw_3d
|
||||
@@:
|
||||
|
||||
jmp still
|
||||
|
||||
align 4
|
||||
@ -220,10 +244,6 @@ title3: db 'ESC - exit Arrow keys - rotate +/- zoom'
|
||||
fps: db 'FPS:'
|
||||
.end: db 0
|
||||
|
||||
align 4
|
||||
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
||||
;sizeof.TinyGLContext = 28
|
||||
|
||||
align 16
|
||||
draw_3d:
|
||||
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT
|
||||
@ -887,14 +907,18 @@ include '../export.inc'
|
||||
;--------------------------------------------------
|
||||
system_path db '/sys/lib/'
|
||||
name_tgl db 'tinygl.obj',0
|
||||
err_message_found_lib db 'Sorry I cannot load library tinygl.obj',0
|
||||
|
||||
head_f_i:
|
||||
head_f_l db 'System error',0
|
||||
err_message_import db 'Error on load import library tinygl.obj',0
|
||||
head_f_l db '"System error',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:
|
||||
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
|
||||
;sizeof.TinyGLContext = 28
|
||||
procinfo process_information
|
||||
rb 4096
|
||||
stacktop:
|
||||
cur_dir_path:
|
||||
|
@ -161,6 +161,7 @@ E_LIB glClose ;(void)
|
||||
; glu functions
|
||||
;
|
||||
|
||||
E_LIB gluPerspective ;(double, double, double, double)
|
||||
E_LIB gluNewQuadric
|
||||
E_LIB gluDeleteQuadric
|
||||
E_LIB gluQuadricDrawStyle
|
||||
|
@ -12,6 +12,13 @@ offs_qobj_TextureFlag equ 8
|
||||
offs_qobj_Normals equ 12
|
||||
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)
|
||||
;{
|
||||
;}
|
||||
@ -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,
|
||||
; GLdouble centerx, GLdouble centery, GLdouble centerz,
|
||||
|
Loading…
Reference in New Issue
Block a user