TinyGL:
- fixed setting of 'GL_FRONT_AND_BACK' mode - fixed setting of 'GL_SPOT_DIRECTION' angle - optimization of drawing triangles and lines - fixes in 'gluCylinder' and 'gluSphere' functions - 'gluDisk' function added - optimize function 'calc_buf' - clean code Flag: add lighting info3ds, info3ds_u, test_glu0, test_glu1, test_glu2, textures0, textures1, textures2: - updated programs using 'gluCylinder' and 'gluSphere'
This commit is contained in:
@@ -692,6 +692,15 @@ struct TinyGLContext
|
||||
long int dx, dy, x, y;
|
||||
};
|
||||
|
||||
struct GLUquadricObj
|
||||
{
|
||||
GLenum DrawStyle; // GLU_FILL, LINE, SILHOUETTE, or POINT
|
||||
GLenum Orientation; // GLU_INSIDE or GLU_OUTSIDE
|
||||
GLboolean TextureFlag; // Generate texture coords?
|
||||
GLenum Normals; // GLU_NONE, GLU_FLAT, or GLU_SMOOTH
|
||||
void (__stdcall* ErrorFunc)(GLenum err); // Error handler callback function
|
||||
};
|
||||
|
||||
//
|
||||
// tinygl - import table
|
||||
//
|
||||
@@ -748,7 +757,7 @@ void (__stdcall* glEdgeFlag)(int flag) = (void (__stdcall*)(int))&"glEdgeFlag";
|
||||
void (__stdcall* glMatrixMode)(int mode) = (void (__stdcall*)(int))&"glMatrixMode";
|
||||
void (__stdcall* glLoadMatrixf)(const float* m) = (void (__stdcall*)(const float*))&"glLoadMatrixf";
|
||||
void (__stdcall* glLoadIdentity)() = (void (__stdcall*)())&"glLoadIdentity";
|
||||
//void (__stdcall* glMultMatrixf)(...) = (void (__stdcall*)(...))&"glMultMatrixf";
|
||||
void (__stdcall* glMultMatrixf)(const GLfloat *m) = (void (__stdcall*)(const GLfloat*))&"glMultMatrixf";
|
||||
void (__stdcall* glPushMatrix)() = (void (__stdcall*)())&"glPushMatrix";
|
||||
void (__stdcall* glPopMatrix)() = (void (__stdcall*)())&"glPopMatrix";
|
||||
void (__stdcall* glRotatef)(float angle, float x, float y, float z) = (void (__stdcall*)(float, float, float, float))&"glRotatef";
|
||||
@@ -763,7 +772,7 @@ void (__stdcall* glEndList)() = (void (__stdcall*)())&"glEndList";
|
||||
void (__stdcall* glCallList)(unsigned int list) = (void (__stdcall*)(unsigned int))&"glCallList";
|
||||
void (__stdcall* glClear)(int mask) = (void (__stdcall*)(int))&"glClear";
|
||||
void (__stdcall* glClearColor)(float r, float g, float b, float a) = (void (__stdcall*)(float, float, float, float))&"glClearColor";
|
||||
//void (__stdcall* glClearDepth)(...) = (void (__stdcall*)(...))&"glClearDepth";
|
||||
void (__stdcall* glClearDepth)(double depth) = (void (__stdcall*)(double))&"glClearDepth";
|
||||
void (__stdcall* glRenderMode)(int mode) = (void (__stdcall*)(int))&"glRenderMode";
|
||||
//void (__stdcall* glSelectBuffer)(...) = (void (__stdcall*)(...))&"glSelectBuffer";
|
||||
//void (__stdcall* glInitNames)(...) = (void (__stdcall*)(...))&"glInitNames";
|
||||
@@ -799,18 +808,22 @@ void (__stdcall* glColorPointer)(GLint size, GLenum type, GLsizei stride, const
|
||||
void (__stdcall* glNormalPointer)(GLenum type, GLsizei stride, const GLvoid* pointer) = (void (__stdcall*)(GLenum, GLsizei, const GLvoid*))&"glNormalPointer";
|
||||
void (__stdcall* glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) = (void (__stdcall*)(GLint, GLenum, GLsizei, const GLvoid*))&"glTexCoordPointer";
|
||||
//void (__stdcall* glPolygonOffset)(...) = (void (__stdcall*)(...))&"glPolygonOffset";
|
||||
//void (__stdcall* glOrtho)(...) = (void (__stdcall*)(...))&"glOrtho";
|
||||
void (__stdcall* glOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) = (void (__stdcall*)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble))&"glOrtho";
|
||||
//void (__stdcall* glDebug)(...) = (void (__stdcall*)(...))&"glDebug";
|
||||
//void (__stdcall* glInit)(...) = (void (__stdcall*)(...))&"glInit";
|
||||
//void (__stdcall* glClose)(...) = (void (__stdcall*)(...))&"glClose";
|
||||
//void (__stdcall* gluPerspective)(...) = (void (__stdcall*)(...))&"gluPerspective";
|
||||
//void (__stdcall* gluNewQuadric)(...) = (void (__stdcall*)(...))&"gluNewQuadric";
|
||||
//void (__stdcall* gluDeleteQuadric)(...) = (void (__stdcall*)(...))&"gluDeleteQuadric";
|
||||
//void (__stdcall* gluQuadricDrawStyle)(...) = (void (__stdcall*)(...))&"gluQuadricDrawStyle";
|
||||
//void (__stdcall* gluQuadricOrientation)(...) = (void (__stdcall*)(...))&"gluQuadricOrientation";
|
||||
//void (__stdcall* gluQuadricTexture)(...) = (void (__stdcall*)(...))&"gluQuadricTexture";
|
||||
//void (__stdcall* gluCylinder)(...) = (void (__stdcall*)(...))&"gluCylinder";
|
||||
//void (__stdcall* gluSphere)(...) = (void (__stdcall*)(...))&"gluSphere";
|
||||
void (__stdcall* gluPerspective)(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) = (void (__stdcall*)(GLdouble, GLdouble, GLdouble, GLdouble))&"gluPerspective";
|
||||
GLUquadricObj* (__stdcall* gluNewQuadric)() = (GLUquadricObj* (__stdcall*)())&"gluNewQuadric";
|
||||
void (__stdcall* gluDeleteQuadric)(GLUquadricObj *state) = (void (__stdcall*)(GLUquadricObj*))&"gluDeleteQuadric";
|
||||
void (__stdcall* gluQuadricDrawStyle)(GLUquadricObj *quadObject, GLenum drawStyle) = (void (__stdcall*)(GLUquadricObj*, GLenum))&"gluQuadricDrawStyle";
|
||||
void (__stdcall* gluQuadricOrientation)(GLUquadricObj *quadObject, GLenum orientation) = (void (__stdcall*)(GLUquadricObj*, GLenum))&"gluQuadricOrientation";
|
||||
void (__stdcall* gluQuadricTexture)(GLUquadricObj *quadObject, GLboolean textureCoords) = (void (__stdcall*)(GLUquadricObj*, GLboolean))&"gluQuadricTexture";
|
||||
void (__stdcall* gluCylinder)(GLUquadricObj *qobj,
|
||||
GLdouble baseRadius, GLdouble topRadius, GLdouble height, GLint slices, GLint stacks) = (void (__stdcall*)(GLUquadricObj*, GLdouble, GLdouble, GLdouble, GLint, GLint))&"gluCylinder";
|
||||
void (__stdcall* gluDisk)(GLUquadricObj *qobj,
|
||||
GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops) = (void (__stdcall*)(GLUquadricObj*, GLdouble, GLdouble, GLint, GLint))&"gluDisk";
|
||||
void (__stdcall* gluSphere)(GLUquadricObj *qobj,
|
||||
GLdouble radius, GLint slices, GLint stacks) = (void (__stdcall*)(GLUquadricObj*, GLdouble, GLint, GLint))&"gluSphere";
|
||||
void (__stdcall* kosglMakeCurrent)(long l, long t, long w, long h, TinyGLContext*) = (void (__stdcall*)(long, long, long, long, TinyGLContext*))&"kosglMakeCurrent";
|
||||
void (__stdcall* kosglSwapBuffers)() = (void (__stdcall*)())&"kosglSwapBuffers";
|
||||
asm{
|
||||
|
@@ -18,12 +18,6 @@ include '../../develop/libraries/TinyGL/asm_fork/examples/fps.inc'
|
||||
|
||||
@use_library
|
||||
|
||||
;Macro for double type parameters (8 bytes)
|
||||
macro glpush GLDoubleVar {
|
||||
push dword[GLDoubleVar+4]
|
||||
push dword[GLDoubleVar]
|
||||
}
|
||||
|
||||
align 4
|
||||
start:
|
||||
load_library name_tgl, library_path, system_path, import_tinygl
|
||||
@@ -40,6 +34,11 @@ start:
|
||||
|
||||
stdcall [glClearColor], 0.549, 0.549, 0.588, 1.0
|
||||
|
||||
stdcall [glEnable], GL_LIGHTING
|
||||
stdcall [glLightf], GL_LIGHT0, GL_SPOT_EXPONENT, 0.0
|
||||
stdcall [glLightf], GL_LIGHT0, GL_SPOT_CUTOFF, 180.0
|
||||
stdcall [glEnable], GL_LIGHT0
|
||||
|
||||
stdcall [glLightfv], GL_LIGHT0, GL_POSITION, lightpos
|
||||
stdcall [glLightfv], GL_LIGHT0, GL_SPOT_DIRECTION, lightdirect
|
||||
|
||||
@@ -127,11 +126,6 @@ endl
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
p1 dq 28.0
|
||||
p3 dq 1.0
|
||||
p4 dq 40.0
|
||||
|
||||
align 4
|
||||
draw_window:
|
||||
pushad
|
||||
@@ -247,7 +241,11 @@ align 4
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
align 4
|
||||
p1 dq 28.0
|
||||
p3 dq 1.0
|
||||
p4 dq 40.0
|
||||
|
||||
delt_1 dd 0.08
|
||||
delt_2 dd 0.2
|
||||
delt_3 dd 0.01
|
||||
|
@@ -12,6 +12,7 @@ include '../../develop/libraries/libs-dev/libimg/libimg.inc'
|
||||
include '../../load_img.inc'
|
||||
include '../../load_lib.mac'
|
||||
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
|
||||
include '../../develop/libraries/TinyGL/asm_fork/kosgl.inc'
|
||||
include '../../develop/libraries/TinyGL/asm_fork/opengl_const.inc'
|
||||
include 'lang.inc' ; Language support for locales: ru_RU (CP866), en_US.
|
||||
include 'info_fun_float.inc'
|
||||
@@ -235,7 +236,7 @@ start:
|
||||
call [gluNewQuadric]
|
||||
mov [qObj],eax
|
||||
|
||||
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
|
||||
@@ -1362,14 +1363,14 @@ white_light dd 0.8, 0.8, 0.8, 1.0 ;
|
||||
lmodel_ambient dd 0.3, 0.3, 0.3, 1.0 ; <20><>ࠬ<EFBFBD><E0A0AC><EFBFBD><EFBFBD> 䮭<><E4AEAD><EFBFBD><EFBFBD><EFBFBD> <20>ᢥ饭<E1A2A5><E9A5AD>
|
||||
|
||||
if lang eq ru_RU
|
||||
capt db 'info 3ds <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 14.04.25',0 ;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
capt db 'info 3ds <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 29.04.25',0 ;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
else ; Default to en_US
|
||||
capt db 'info 3ds version 14.04.25',0 ;window caption
|
||||
capt db 'info 3ds version 29.04.25',0 ;window caption
|
||||
end if
|
||||
|
||||
align 16
|
||||
i_end:
|
||||
ctx1 rb 28 ;sizeof.TinyGLContext = 28
|
||||
ctx1 TinyGLContext
|
||||
procinfo process_information
|
||||
run_file_70 FileInfoBlock
|
||||
sc system_colors
|
||||
|
@@ -306,7 +306,7 @@ align 4
|
||||
faddp
|
||||
fild dword[rad_c]
|
||||
fdivp ;radius=(size.x+size.y)/rad_c
|
||||
fstp dword[sph_radius]
|
||||
fstp qword[sph_radius]
|
||||
|
||||
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>⠡ <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> x <EFBFBD> y, <EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>蠫<EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ய<EFBFBD><EFBFBD>樨 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࠦ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
fld dword[edi+obj_3d.y_scale]
|
||||
@@ -975,7 +975,10 @@ if version_edit eq 1
|
||||
stdcall [glColor3ub],[color_select+2],[color_select+1],[color_select]
|
||||
call [glPushMatrix]
|
||||
stdcall [glTranslatef], [eax],[eax+4],[eax+8]
|
||||
stdcall [gluSphere], [qObj], [sph_radius], 8,8
|
||||
push 8
|
||||
push 8
|
||||
glpush sph_radius
|
||||
stdcall [gluSphere], [qObj]
|
||||
call [glPopMatrix]
|
||||
@@:
|
||||
|
||||
@@ -996,7 +999,10 @@ align 4
|
||||
mov eax,[eax]
|
||||
call [glPushMatrix]
|
||||
stdcall [glTranslatef], [eax],[eax+4],[eax+8]
|
||||
stdcall [gluSphere], [qObj], [sph_radius], 4,4
|
||||
push 4
|
||||
push 4
|
||||
glpush sph_radius
|
||||
stdcall [gluSphere], [qObj]
|
||||
call [glPopMatrix]
|
||||
dec ecx
|
||||
jz .end_select
|
||||
@@ -1344,5 +1350,5 @@ delt_size dd 3.0 ;
|
||||
mouse_drag dd 0 ;०<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>業<EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>६<EFBFBD>饭<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
mouse_x dd 0
|
||||
mouse_y dd 0
|
||||
sph_radius dd 0 ;ࠤ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD>뤥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>⨢<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>窨
|
||||
sph_radius dq 0 ;radius of the sphere for selecting the active point
|
||||
|
||||
|
@@ -62,14 +62,14 @@ align 4
|
||||
je @f
|
||||
mov eax,[eax+GLContext.current_texture] ;eax = &context.current_texture
|
||||
mov eax,[eax] ;eax = context.current_texture
|
||||
;[eax+offs_text_images] = im = &context.current_texture.images[0]
|
||||
;[eax+GLTexture.images] = im = &context.current_texture.images[0]
|
||||
|
||||
fild dword[eax+offs_text_images+offs_imag_s_bound]
|
||||
fild dword[eax+GLTexture.images+GLImage.s_bound]
|
||||
fmul dword[ebx+GLVertex.tex_coord+offs_X]
|
||||
fistp dword[ebx+GLVertex.zp+ZBufferPoint.s]
|
||||
;v.zp.s=(int)(v.tex_coord.X * im.s_bound)
|
||||
|
||||
fild dword[eax+offs_text_images+offs_imag_t_bound]
|
||||
fild dword[eax+GLTexture.images+GLImage.t_bound]
|
||||
fmul dword[ebx+GLVertex.tex_coord+offs_Y]
|
||||
fistp dword[ebx+GLVertex.zp+ZBufferPoint.t]
|
||||
;v.zp.t=(int)(v.tex_coord.Y * im.t_bound)
|
||||
@@ -1028,9 +1028,11 @@ if PROFILE eq 1
|
||||
end if
|
||||
mov eax,[edx+GLContext.current_texture]
|
||||
mov eax,[eax] ;переход по указателю
|
||||
;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax]
|
||||
stdcall ZB_setTexture, [edx+GLContext.zb], [eax],\
|
||||
[eax+offs_imag_s_bound],[eax+offs_imag_t_bound],[eax+offs_imag_xsize_log2]
|
||||
stdcall ZB_setTexture, [edx+GLContext.zb],\
|
||||
[eax+GLTexture.images+GLImage.pixmap],\
|
||||
[eax+GLTexture.images+GLImage.s_bound],\
|
||||
[eax+GLTexture.images+GLImage.t_bound],\
|
||||
[eax+GLTexture.images+GLImage.xsize_log2]
|
||||
mov eax,[p0]
|
||||
add eax,GLVertex.zp
|
||||
push ecx
|
||||
|
@@ -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
|
||||
@@ -189,7 +204,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
|
||||
@@ -490,28 +619,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 +654,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,7 +43,15 @@ 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 ;делам нормали одинаковой величины во избежание артефактов
|
||||
call [gluNewQuadric]
|
||||
@@ -48,7 +60,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
|
||||
@@ -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,6 +447,15 @@ SetLight:
|
||||
stdcall [glEnable],GL_LIGHT0
|
||||
ret
|
||||
|
||||
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 ;начальный масштаб
|
||||
sc_delt dd 0.05 ;изменение масштаба при нажатии
|
||||
sc_min dd 0.1 ;минимальный масштаб
|
||||
@@ -482,28 +602,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 +637,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,7 +43,7 @@ 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 ;делам нормали одинаковой величины во избежание артефактов
|
||||
call [gluNewQuadric]
|
||||
@@ -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
|
||||
@@ -79,6 +83,11 @@ load_libraries l_libs_start,l_libs_end
|
||||
stdcall [glBindTexture], GL_TEXTURE_2D, [TexObj]
|
||||
stdcall [glEnable], GL_TEXTURE_2D
|
||||
|
||||
fld dword[angle_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
fld dword[angle_z]
|
||||
stdcall update_number, txt_angle_z.v
|
||||
|
||||
call draw_3d
|
||||
|
||||
align 4
|
||||
@@ -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 ;минимальный масштаб
|
||||
@@ -533,28 +562,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 +597,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,7 +44,7 @@ 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 ;делам нормали одинаковой величины во избежание артефактов
|
||||
call [gluNewQuadric]
|
||||
@@ -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_y]
|
||||
stdcall update_number, txt_angle_y.v
|
||||
fld dword[angle_x]
|
||||
stdcall update_number, txt_angle_x.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 ;минимальный масштаб
|
||||
@@ -463,34 +493,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 +532,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,7 +43,7 @@ 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 ;делам нормали одинаковой величины во избежание артефактов
|
||||
call [gluNewQuadric]
|
||||
@@ -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 ;минимальный масштаб
|
||||
@@ -422,34 +444,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 +483,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 шт.)
|
||||
|
@@ -168,7 +168,8 @@ E_LIB gluQuadricDrawStyle
|
||||
E_LIB gluQuadricOrientation
|
||||
E_LIB gluQuadricTexture
|
||||
E_LIB gluCylinder ;(GLUquadricObj, double, double, double, int, int)
|
||||
E_LIB gluSphere ;(GLUquadricObj, float, int, int)
|
||||
E_LIB gluDisk ;(GLUquadricObj, double, double, int, int)
|
||||
E_LIB gluSphere ;(GLUquadricObj, double, int, int)
|
||||
|
||||
;
|
||||
; KolibriOS functions
|
||||
|
@@ -6,29 +6,9 @@ struct GLUquadricObj
|
||||
ErrorFunc dd ? ; Error handler callback function
|
||||
ends
|
||||
|
||||
offs_qobj_DrawStyle equ 0
|
||||
offs_qobj_Orientation equ 4
|
||||
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)
|
||||
;{
|
||||
;}
|
||||
|
||||
;static void normal3f(GLfloat x, GLfloat y, GLfloat z )
|
||||
;{
|
||||
;}
|
||||
|
||||
align 4
|
||||
an360f dd 360.0
|
||||
fl_0_5 dd 0.5
|
||||
fl_360 dd 360.0
|
||||
|
||||
align 16
|
||||
proc gluPerspective, fovy:qword, aspect:qword, zNear:qword, zFar:qword
|
||||
@@ -40,7 +20,7 @@ locals
|
||||
endl
|
||||
fldpi
|
||||
fmul qword[fovy]
|
||||
fdiv dword[an360f]
|
||||
fdiv dword[fl_360]
|
||||
fptan
|
||||
ffree st0 ;выкидываем 1.0 которая осталось после вычисления тангенса
|
||||
fincstp
|
||||
@@ -76,11 +56,11 @@ gluNewQuadric:
|
||||
stdcall gl_malloc, sizeof.GLUquadricObj
|
||||
or eax,eax
|
||||
jz @f
|
||||
mov dword[eax+offs_qobj_DrawStyle],GLU_FILL
|
||||
mov dword[eax+offs_qobj_Orientation],GLU_OUTSIDE
|
||||
mov dword[eax+offs_qobj_TextureFlag],GL_FALSE
|
||||
mov dword[eax+offs_qobj_Normals],GLU_SMOOTH
|
||||
mov dword[eax+offs_qobj_ErrorFunc],0 ;NULL
|
||||
mov dword[eax+GLUquadricObj.DrawStyle],GLU_FILL
|
||||
mov dword[eax+GLUquadricObj.Orientation],GLU_OUTSIDE
|
||||
mov dword[eax+GLUquadricObj.TextureFlag],GL_FALSE
|
||||
mov dword[eax+GLUquadricObj.Normals],GLU_SMOOTH
|
||||
mov dword[eax+GLUquadricObj.ErrorFunc],0 ;NULL
|
||||
@@:
|
||||
ret
|
||||
|
||||
@@ -114,7 +94,7 @@ proc gluQuadricDrawStyle uses eax ebx, qobj:dword, drawStyle:dword
|
||||
jmp .err_q
|
||||
align 4
|
||||
@@:
|
||||
mov dword[eax+offs_qobj_DrawStyle],ebx
|
||||
mov dword[eax+GLUquadricObj.DrawStyle],ebx
|
||||
jmp @f
|
||||
align 4
|
||||
.err_q:
|
||||
@@ -139,7 +119,7 @@ proc gluQuadricOrientation uses eax ebx, qobj:dword, orientation:dword
|
||||
jmp .err_q
|
||||
align 4
|
||||
@@:
|
||||
mov dword[eax+offs_qobj_Orientation],ebx
|
||||
mov dword[eax+GLUquadricObj.Orientation],ebx
|
||||
jmp @f
|
||||
align 4
|
||||
.err_q:
|
||||
@@ -159,7 +139,7 @@ proc gluQuadricTexture uses eax ebx, qobj:dword, texture:dword
|
||||
cmp ebx,GL_FALSE
|
||||
je @f
|
||||
@@:
|
||||
mov dword[eax+offs_qobj_TextureFlag],ebx
|
||||
mov dword[eax+GLUquadricObj.TextureFlag],ebx
|
||||
jmp @f
|
||||
align 4
|
||||
.err_q:
|
||||
@@ -169,7 +149,7 @@ align 4
|
||||
endp
|
||||
|
||||
align 16
|
||||
proc gluCylinder qobj:dword, baseRadius:dword, topRadius:dword, height:dword,\
|
||||
proc gluCylinder qobj:dword, baseRadius:qword, topRadius:qword, height:qword,\
|
||||
slices:dword, stacks:dword
|
||||
locals
|
||||
da dq ? ;double
|
||||
@@ -193,7 +173,7 @@ endl
|
||||
pushad
|
||||
mov edx,[qobj]
|
||||
fld1
|
||||
cmp dword[edx+offs_qobj_Orientation],GLU_INSIDE
|
||||
cmp dword[edx+GLUquadricObj.Orientation],GLU_INSIDE
|
||||
jne @f
|
||||
fchs
|
||||
@@:
|
||||
@@ -203,14 +183,12 @@ pushad
|
||||
fadd st0,st0
|
||||
fidiv dword[slices]
|
||||
fstp qword[da] ;da = 2.0*M_PI / slices
|
||||
mov ebx,[topRadius]
|
||||
fld qword[ebx]
|
||||
mov ecx,[baseRadius]
|
||||
fsub qword[ecx]
|
||||
fld qword[topRadius]
|
||||
fsub qword[baseRadius]
|
||||
fld st0 ;copy: topRadius-baseRadius
|
||||
fidiv dword[stacks]
|
||||
fstp qword[dr] ;dr = (topRadius-baseRadius) / stacks
|
||||
mov eax,[height]
|
||||
lea eax,[height]
|
||||
fld qword[eax]
|
||||
fidiv dword[stacks]
|
||||
fstp qword[dz] ;dz = height / stacks
|
||||
@@ -218,7 +196,7 @@ pushad
|
||||
fdiv qword[eax]
|
||||
fstp dword[nz] ;nz = (baseRadius-topRadius) / height ; Z component of normal vectors
|
||||
|
||||
cmp dword[edx+offs_qobj_DrawStyle],GLU_POINT
|
||||
cmp dword[edx+GLUquadricObj.DrawStyle],GLU_POINT
|
||||
jne .else0
|
||||
stdcall glBegin,GL_POINTS
|
||||
mov ebx,[slices]
|
||||
@@ -245,8 +223,7 @@ align 4
|
||||
call glNormal3f ;x*nsign, y*nsign, nz*nsign
|
||||
|
||||
mov dword[z],0.0
|
||||
mov ecx,[baseRadius]
|
||||
fld qword[ecx]
|
||||
fld qword[baseRadius]
|
||||
fstp qword[r] ;r = baseRadius
|
||||
mov ecx,[stacks]
|
||||
inc ecx
|
||||
@@ -277,16 +254,15 @@ align 4
|
||||
call glEnd
|
||||
jmp .end_f
|
||||
.else0:
|
||||
cmp dword[edx+offs_qobj_DrawStyle],GLU_LINE
|
||||
cmp dword[edx+GLUquadricObj.DrawStyle],GLU_LINE
|
||||
je @f
|
||||
cmp dword[edx+offs_qobj_DrawStyle],GLU_SILHOUETTE
|
||||
cmp dword[edx+GLUquadricObj.DrawStyle],GLU_SILHOUETTE
|
||||
je .else2
|
||||
jmp .else1
|
||||
@@:
|
||||
; Draw rings
|
||||
mov dword[z],0.0
|
||||
mov ecx,[baseRadius]
|
||||
fld qword[ecx]
|
||||
fld qword[baseRadius]
|
||||
fstp qword[r] ;r = baseRadius
|
||||
mov ecx,[stacks]
|
||||
inc ecx
|
||||
@@ -342,28 +318,100 @@ align 4
|
||||
align 4
|
||||
.else2:
|
||||
; draw one ring at each end
|
||||
; if (baseRadius!=0.0) {
|
||||
lea ecx,[baseRadius]
|
||||
fld qword[ecx]
|
||||
ftst
|
||||
fnstsw ax
|
||||
ffree st0
|
||||
fincstp
|
||||
sahf
|
||||
je .rad_b0
|
||||
stdcall glBegin,GL_LINE_LOOP
|
||||
mov ebx,[slices]
|
||||
mov dword[i],0
|
||||
align 4
|
||||
.cycle_4: ;for (i=0;i<slices;i++)
|
||||
; {
|
||||
; x = cos(i*da);
|
||||
; y = sin(i*da);
|
||||
; normal3f( x*nsign, y*nsign, nz*nsign );
|
||||
; glVertex3f( x*baseRadius, y*baseRadius, 0.0 );
|
||||
; }
|
||||
cmp [i],ebx
|
||||
jge .cycle_4_end
|
||||
fild dword[i]
|
||||
fmul qword[da]
|
||||
fld st0
|
||||
fcos
|
||||
fstp dword[x] ;x = cos(i*da)
|
||||
fsin
|
||||
fstp dword[y] ;y = sin(i*da)
|
||||
fld dword[nsign]
|
||||
fmul dword[nz]
|
||||
fstp dword[esp-4]
|
||||
fld dword[nsign]
|
||||
fmul dword[y]
|
||||
fstp dword[esp-8]
|
||||
fld dword[nsign]
|
||||
fmul dword[x]
|
||||
fstp dword[esp-12]
|
||||
add esp,-12
|
||||
call glNormal3f ;x*nsign, y*nsign, nz*nsign
|
||||
push 0.0
|
||||
fld qword[ecx]
|
||||
fmul dword[y]
|
||||
fstp dword[esp-4]
|
||||
fld qword[ecx]
|
||||
fmul dword[x]
|
||||
fstp dword[esp-8]
|
||||
add esp,-8
|
||||
call glVertex3f ;x*baseRadius, y*baseRadius, 0.0
|
||||
inc dword[i]
|
||||
jmp .cycle_4
|
||||
.cycle_4_end:
|
||||
call glEnd
|
||||
.rad_b0:
|
||||
lea ecx,[topRadius]
|
||||
fld qword[ecx]
|
||||
ftst
|
||||
fnstsw ax
|
||||
ffree st0
|
||||
fincstp
|
||||
sahf
|
||||
je .else2_end
|
||||
stdcall glBegin,GL_LINE_LOOP
|
||||
mov ebx,[slices]
|
||||
mov dword[i],0
|
||||
align 4
|
||||
.cycle_5: ;for (i=0;i<slices;i++)
|
||||
; {
|
||||
; x = cos(i*da);
|
||||
; y = sin(i*da);
|
||||
; normal3f( x*nsign, y*nsign, nz*nsign );
|
||||
; glVertex3f( x*topRadius, y*topRadius, height );
|
||||
; }
|
||||
cmp [i],ebx
|
||||
jge .cycle_5_end
|
||||
fild dword[i]
|
||||
fmul qword[da]
|
||||
fld st0
|
||||
fcos
|
||||
fstp dword[x] ;x = cos(i*da)
|
||||
fsin
|
||||
fstp dword[y] ;y = sin(i*da)
|
||||
fld dword[nsign]
|
||||
fmul dword[nz]
|
||||
fstp dword[esp-4]
|
||||
fld dword[nsign]
|
||||
fmul dword[y]
|
||||
fstp dword[esp-8]
|
||||
fld dword[nsign]
|
||||
fmul dword[x]
|
||||
fstp dword[esp-12]
|
||||
add esp,-12
|
||||
call glNormal3f ;x*nsign, y*nsign, nz*nsign
|
||||
fld qword[height]
|
||||
fstp dword[esp-4]
|
||||
fld qword[ecx]
|
||||
fmul dword[y]
|
||||
fstp dword[esp-8]
|
||||
fld qword[ecx]
|
||||
fmul dword[x]
|
||||
fstp dword[esp-12]
|
||||
add esp,-12
|
||||
call glVertex3f ;x*topRadius, y*topRadius, height
|
||||
inc dword[i]
|
||||
jmp .cycle_5
|
||||
.cycle_5_end:
|
||||
call glEnd
|
||||
; }
|
||||
.else2_end:
|
||||
; draw length lines
|
||||
stdcall glBegin,GL_LINES
|
||||
@@ -390,8 +438,7 @@ align 4
|
||||
sub esp,12
|
||||
call glNormal3f ;x*nsign, y*nsign, nz*nsign
|
||||
mov dword[esp-4],0.0
|
||||
mov ecx,[baseRadius]
|
||||
fld qword[ecx]
|
||||
fld qword[baseRadius]
|
||||
fld st0
|
||||
fmul dword[y]
|
||||
fstp dword[esp-8]
|
||||
@@ -399,11 +446,9 @@ align 4
|
||||
fstp dword[esp-12]
|
||||
sub esp,12
|
||||
call glVertex3f ;x*baseRadius, y*baseRadius, 0.0
|
||||
mov eax,[height]
|
||||
fld qword[eax]
|
||||
fld qword[height]
|
||||
fstp dword[esp-4]
|
||||
mov ecx,[topRadius]
|
||||
fld qword[ecx]
|
||||
fld qword[topRadius]
|
||||
fld st0
|
||||
fmul dword[y]
|
||||
fstp dword[esp-8]
|
||||
@@ -419,7 +464,7 @@ align 4
|
||||
jmp .end_f
|
||||
align 4
|
||||
.else1:
|
||||
cmp dword[edx+offs_qobj_DrawStyle],GLU_FILL
|
||||
cmp dword[edx+GLUquadricObj.DrawStyle],GLU_FILL
|
||||
jne .end_f
|
||||
fld1
|
||||
fidiv dword[slices]
|
||||
@@ -453,8 +498,7 @@ align 4
|
||||
fchs
|
||||
fstp dword[x2] ;x2 = -sin((i+1)*da)
|
||||
mov dword[z],0.0
|
||||
mov ecx,[baseRadius]
|
||||
fld qword[ecx]
|
||||
fld qword[baseRadius]
|
||||
fstp qword[r] ;r = baseRadius
|
||||
mov dword[tcy],0.0
|
||||
stdcall glBegin,GL_QUAD_STRIP
|
||||
@@ -479,7 +523,7 @@ align 4
|
||||
fstp dword[esp-12]
|
||||
sub esp,12
|
||||
call glNormal3f ;x1*nsign, y1*nsign, nz*nsign
|
||||
cmp dword[edx+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[edx+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
stdcall glTexCoord2f, [tcx],[tcy]
|
||||
@@:
|
||||
@@ -504,7 +548,7 @@ align 4
|
||||
fstp dword[esp-12]
|
||||
sub esp,12
|
||||
call glNormal3f ;x2*nsign, y2*nsign, nz*nsign
|
||||
cmp dword[edx+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[edx+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
push dword[tcy]
|
||||
fld dword[tcx]
|
||||
@@ -535,7 +579,7 @@ align 4
|
||||
fstp dword[esp-12]
|
||||
sub esp,12
|
||||
call glNormal3f ;x2*nsign, y2*nsign, nz*nsign
|
||||
cmp dword[edx+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[edx+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
stdcall glTexCoord2f, [tcx],[tcy]
|
||||
@@:
|
||||
@@ -560,7 +604,7 @@ align 4
|
||||
fstp dword[esp-12]
|
||||
sub esp,12
|
||||
call glNormal3f ;x1*nsign, y1*nsign, nz*nsign
|
||||
cmp dword[edx+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[edx+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
push dword[tcy]
|
||||
fld dword[tcx]
|
||||
@@ -605,18 +649,164 @@ endp
|
||||
|
||||
; Disk (adapted from Mesa)
|
||||
|
||||
;void gluDisk(GLUquadricObj *qobj, GLdouble innerRadius, GLdouble outerRadius, GLint slices, GLint loops )
|
||||
;{
|
||||
;}
|
||||
align 16
|
||||
proc gluDisk uses eax ebx ecx edx esi, qobj:dword,\
|
||||
innerRadius:qword, outerRadius:qword, slices:dword, loops:dword
|
||||
locals
|
||||
a dq ?
|
||||
da dq ?
|
||||
dr dd ?
|
||||
r1 dd ?
|
||||
r2 dd ?
|
||||
dtc dd ?
|
||||
s dd ? ;int
|
||||
sa dd ?
|
||||
ca dd ?
|
||||
endl
|
||||
;ebx = s
|
||||
;ecx = l
|
||||
;esi = slices
|
||||
mov ecx,[loops]
|
||||
cmp ecx,1
|
||||
jl .end_f
|
||||
mov esi,[slices]
|
||||
cmp esi,1
|
||||
jl .end_f
|
||||
|
||||
mov edx,[qobj]
|
||||
cmp dword[edx+GLUquadricObj.DrawStyle],GLU_FILL
|
||||
jne .no_fill
|
||||
fld1
|
||||
cmp dword[edx+GLUquadricObj.Orientation],GLU_OUTSIDE
|
||||
je @f
|
||||
fchs
|
||||
@@:
|
||||
add esp,-4
|
||||
fstp dword[esp]
|
||||
stdcall glNormal3f,0.0,0.0
|
||||
|
||||
fldpi
|
||||
fadd st0,st0
|
||||
fidiv dword[slices]
|
||||
fstp qword[da] ;da = 2.0*M_PI / slices
|
||||
fld qword[outerRadius]
|
||||
fsub qword[innerRadius]
|
||||
fild dword[loops]
|
||||
fdivp st1,st
|
||||
fstp dword[dr] ;dr = (outerRadius-innerRadius) / loops
|
||||
|
||||
; texture of a gluDisk is a cut out of the texture unit square
|
||||
; x, y in [-outerRadius, +outerRadius]; s, t in [0, 1] (linear mapping)
|
||||
fld1
|
||||
fadd st0,st0
|
||||
fmul qword[outerRadius]
|
||||
fstp dword[dtc] ;dtc = 2.0*outerRadius
|
||||
fld qword[innerRadius]
|
||||
fstp dword[r1]
|
||||
|
||||
align 4
|
||||
.cycle_0: ;for (l=loops;l>0;l--)
|
||||
fld dword[r1]
|
||||
fadd dword[dr]
|
||||
fstp dword[r2] ;r2 = r1 + dr
|
||||
stdcall glBegin,GL_QUAD_STRIP
|
||||
xor ebx,ebx
|
||||
.cycle_1: ;for (s=0;s<=slices;s++)
|
||||
cmp esi,ebx
|
||||
jne .u1
|
||||
fldz
|
||||
fstp qword[a]
|
||||
jmp .u2
|
||||
align 4
|
||||
.u1:
|
||||
mov [s],ebx
|
||||
fild dword[s]
|
||||
fmul qword[da]
|
||||
fstp qword[a]
|
||||
.u2:
|
||||
fld qword[a]
|
||||
fld st0
|
||||
fsin
|
||||
fstp dword[sa] ;sa = sin(a)
|
||||
fcos
|
||||
fstp dword[ca] ;ca = cos(a)
|
||||
cmp dword[edx+GLUquadricObj.TextureFlag],0
|
||||
je @f
|
||||
fld dword[ca]
|
||||
fmul dword[r2]
|
||||
fdiv dword[dtc]
|
||||
fadd dword[fl_0_5]
|
||||
fstp dword[esp-4]
|
||||
fld dword[sa]
|
||||
fmul dword[r2]
|
||||
fdiv dword[dtc]
|
||||
fadd dword[fl_0_5]
|
||||
add esp,-8
|
||||
fstp dword[esp]
|
||||
call glTexCoord2f ;0.5+sa*r2/dtc,0.5+ca*r2/dtc
|
||||
@@:
|
||||
fld dword[r2]
|
||||
fmul dword[ca]
|
||||
fstp dword[esp-4]
|
||||
fld dword[r2]
|
||||
fmul dword[sa]
|
||||
add esp,-8
|
||||
fstp dword[esp]
|
||||
call glVertex2f ;r2*sa, r2*ca
|
||||
|
||||
cmp dword[edx+GLUquadricObj.TextureFlag],0
|
||||
je @f
|
||||
fld dword[ca]
|
||||
fmul dword[r1]
|
||||
fdiv dword[dtc]
|
||||
fadd dword[fl_0_5]
|
||||
fstp dword[esp-4]
|
||||
fld dword[sa]
|
||||
fmul dword[r1]
|
||||
fdiv dword[dtc]
|
||||
fadd dword[fl_0_5]
|
||||
add esp,-8
|
||||
fstp dword[esp]
|
||||
call glTexCoord2f ;0.5+sa*r1/dtc,0.5+ca*r1/dtc
|
||||
@@:
|
||||
fld dword[r1]
|
||||
fmul dword[ca]
|
||||
fstp dword[esp-4]
|
||||
fld dword[r1]
|
||||
fmul dword[sa]
|
||||
add esp,-8
|
||||
fstp dword[esp]
|
||||
call glVertex2f ;r1*sa, r1*ca
|
||||
inc ebx
|
||||
cmp esi,ebx
|
||||
jge .cycle_1
|
||||
.cycle_1_end:
|
||||
call glEnd
|
||||
mov eax,[r2]
|
||||
mov [r1],eax
|
||||
dec ecx
|
||||
jnz .cycle_0
|
||||
jmp .end_f
|
||||
align 4
|
||||
.no_fill:
|
||||
push [loops]
|
||||
push [slices]
|
||||
sub esp,8
|
||||
fldz
|
||||
fstp qword[esp]
|
||||
glpush innerRadius
|
||||
glpush outerRadius
|
||||
stdcall gluCylinder, [qobj]
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
;
|
||||
; Sphere (adapted from Mesa)
|
||||
;
|
||||
|
||||
;input:
|
||||
; float radius, int slices, int stacks
|
||||
; double radius, int slices, int stacks
|
||||
align 16
|
||||
proc gluSphere qobj:dword, radius:dword, slices:dword, stacks:dword
|
||||
proc gluSphere qobj:dword, radius:qword, slices:dword, stacks:dword
|
||||
locals
|
||||
rho dd ? ;float
|
||||
drho dd ?
|
||||
@@ -638,7 +828,7 @@ endl
|
||||
pushad
|
||||
|
||||
mov eax,[qobj]
|
||||
cmp dword[eax+offs_qobj_Normals],GLU_NONE ;if (qobj.Normals==GLU_NONE)
|
||||
cmp dword[eax+GLUquadricObj.Normals],GLU_NONE ;if (qobj.Normals==GLU_NONE)
|
||||
jne .els_0
|
||||
mov dword[normals],GL_FALSE
|
||||
jmp @f
|
||||
@@ -646,7 +836,7 @@ align 4
|
||||
.els_0:
|
||||
mov dword[normals],GL_TRUE
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_Orientation],GLU_INSIDE ;if (qobj.Orientation==GLU_INSIDE)
|
||||
cmp dword[eax+GLUquadricObj.Orientation],GLU_INSIDE ;if (qobj.Orientation==GLU_INSIDE)
|
||||
jne .els_1
|
||||
mov dword[nsign],-1.0
|
||||
jmp @f
|
||||
@@ -666,7 +856,7 @@ align 4
|
||||
ffree st0
|
||||
fincstp
|
||||
|
||||
cmp dword[eax+offs_qobj_DrawStyle],GLU_FILL ;if (qobj.DrawStyle==GLU_FILL)
|
||||
cmp dword[eax+GLUquadricObj.DrawStyle],GLU_FILL ;if (qobj.DrawStyle==GLU_FILL)
|
||||
jne .if_glu_line
|
||||
|
||||
; draw +Z end as a triangle fan
|
||||
@@ -675,13 +865,13 @@ align 4
|
||||
jne @f
|
||||
stdcall glNormal3f, 0.0, 0.0, 1.0
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[eax+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
stdcall glTexCoord2f, 0.5,1.0
|
||||
@@:
|
||||
sub esp,4
|
||||
fld dword[nsign]
|
||||
fmul dword[radius]
|
||||
fmul qword[radius]
|
||||
fstp dword[esp]
|
||||
stdcall glVertex3f, 0.0, 0.0 ;, nsign * radius
|
||||
fld dword[drho]
|
||||
@@ -728,7 +918,7 @@ align 4
|
||||
sub esp,12
|
||||
stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
|
||||
@@:
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fld dword[z]
|
||||
fmul st0,st1
|
||||
fstp dword[esp-4]
|
||||
@@ -754,7 +944,7 @@ align 4
|
||||
fstp dword[d_t] ;1.0 / stacks
|
||||
mov dword[t],1.0 ; because loop now runs from 0
|
||||
mov ebx,[stacks]
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[eax+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je .els_2
|
||||
mov dword[i],0
|
||||
mov [imax],ebx
|
||||
@@ -820,11 +1010,11 @@ align 4
|
||||
sub esp,12
|
||||
stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[eax+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
stdcall glTexCoord2f, [s],[t]
|
||||
@@:
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fld dword[z]
|
||||
fmul st0,st1
|
||||
fstp dword[esp-4]
|
||||
@@ -868,7 +1058,7 @@ align 4
|
||||
sub esp,12
|
||||
stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[eax+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
fld dword[t]
|
||||
fsub dword[d_t]
|
||||
@@ -879,7 +1069,7 @@ align 4
|
||||
fadd dword[d_s]
|
||||
fstp dword[s]
|
||||
@@:
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fld dword[z]
|
||||
fmul st0,st1
|
||||
fstp dword[esp-4]
|
||||
@@ -910,7 +1100,7 @@ align 4
|
||||
jne @f
|
||||
stdcall glNormal3f, 0.0, 0.0, -1.0
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[eax+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
stdcall glTexCoord2f, 0.5,0.0
|
||||
mov dword[s],1.0
|
||||
@@ -918,7 +1108,7 @@ align 4
|
||||
mov [t],ebx
|
||||
@@:
|
||||
sub esp,4
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fchs
|
||||
fmul dword[nsign]
|
||||
fstp dword[esp]
|
||||
@@ -970,14 +1160,14 @@ align 4
|
||||
fincstp
|
||||
stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
|
||||
@@:
|
||||
cmp dword[eax+offs_qobj_TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
cmp dword[eax+GLUquadricObj.TextureFlag],0 ;if (qobj.TextureFlag)
|
||||
je @f
|
||||
stdcall glTexCoord2f, [s],[t]
|
||||
fld dword[s]
|
||||
fsub dword[d_s]
|
||||
fstp dword[s]
|
||||
@@:
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fld dword[z]
|
||||
fmul st0,st1
|
||||
fstp dword[esp-4]
|
||||
@@ -998,9 +1188,9 @@ align 4
|
||||
|
||||
align 4
|
||||
.if_glu_line:
|
||||
cmp dword[eax+offs_qobj_DrawStyle],GLU_LINE ;if (qobj.DrawStyle==GLU_LINE)
|
||||
cmp dword[eax+GLUquadricObj.DrawStyle],GLU_LINE ;if (qobj.DrawStyle==GLU_LINE)
|
||||
je @f
|
||||
cmp dword[eax+offs_qobj_DrawStyle],GLU_SILHOUETTE ;if (qobj.DrawStyle==GLU_SILHOUETTE)
|
||||
cmp dword[eax+GLUquadricObj.DrawStyle],GLU_SILHOUETTE ;if (qobj.DrawStyle==GLU_SILHOUETTE)
|
||||
je @f
|
||||
jmp .if_glu_point
|
||||
align 4
|
||||
@@ -1056,7 +1246,7 @@ align 4
|
||||
sub esp,12
|
||||
stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
|
||||
@@:
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fld dword[z]
|
||||
fmul st0,st1
|
||||
fstp dword[esp-4]
|
||||
@@ -1123,7 +1313,7 @@ align 4
|
||||
sub esp,12
|
||||
stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
|
||||
@@:
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fld dword[z]
|
||||
fmul st0,st1
|
||||
fstp dword[esp-4]
|
||||
@@ -1148,7 +1338,7 @@ align 4
|
||||
|
||||
align 4
|
||||
.if_glu_point:
|
||||
cmp dword[eax+offs_qobj_DrawStyle],GLU_POINT ;if (qobj.DrawStyle==GLU_POINT)
|
||||
cmp dword[eax+GLUquadricObj.DrawStyle],GLU_POINT ;if (qobj.DrawStyle==GLU_POINT)
|
||||
jne .end_f
|
||||
|
||||
; top and bottom-most points
|
||||
@@ -1157,7 +1347,10 @@ align 4
|
||||
jne @f
|
||||
stdcall glNormal3f, 0.0,0.0,dword[nsign]
|
||||
@@:
|
||||
stdcall glVertex3f, 0.0,0.0,dword[radius]
|
||||
sub esp,4
|
||||
fld qword[radius]
|
||||
fstp dword[esp]
|
||||
stdcall glVertex3f, 0.0,0.0
|
||||
cmp dword[normals],GL_TRUE
|
||||
jne @f
|
||||
sub esp,4
|
||||
@@ -1167,7 +1360,7 @@ align 4
|
||||
stdcall glNormal3f, 0.0,0.0 ;,-nsign
|
||||
@@:
|
||||
sub esp,4
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fchs
|
||||
fstp dword[esp]
|
||||
stdcall glVertex3f, 0.0,0.0 ;,-radius
|
||||
@@ -1220,7 +1413,7 @@ align 4
|
||||
sub esp,12
|
||||
stdcall glNormal3f ;x*nsign, y*nsign, z*nsign
|
||||
@@:
|
||||
fld dword[radius]
|
||||
fld qword[radius]
|
||||
fld dword[z]
|
||||
fmul st0,st1
|
||||
fstp dword[esp-4]
|
||||
|
@@ -1,3 +1,9 @@
|
||||
;Macro for double type parameters (8 bytes)
|
||||
macro glpush GLDoubleVar {
|
||||
push dword[GLDoubleVar+4]
|
||||
push dword[GLDoubleVar]
|
||||
}
|
||||
|
||||
struct TinyGLContext
|
||||
gl_context dd ?
|
||||
xsize dd ? ;+4
|
||||
|
@@ -1,5 +1,6 @@
|
||||
align 4
|
||||
sp128f dd 128.0
|
||||
fl_128 dd 128.0
|
||||
fl_1e_3 dd 1.0e-3
|
||||
|
||||
align 4
|
||||
proc glopMaterial uses eax ebx ecx edi esi, context:dword, p:dword
|
||||
@@ -11,8 +12,7 @@ proc glopMaterial uses eax ebx ecx edi esi, context:dword, p:dword
|
||||
cmp ecx,GL_FRONT_AND_BACK ;if (mode == GL_FRONT_AND_BACK)
|
||||
jne @f
|
||||
mov dword[ebx+4],GL_FRONT ;p[1].i=GL_FRONT
|
||||
lea edi,[ebp+12]
|
||||
stdcall glopMaterial,eax,edi
|
||||
stdcall glopMaterial,eax,ebx
|
||||
mov ecx,GL_BACK
|
||||
@@:
|
||||
lea edi,[eax+GLContext.materials]
|
||||
@@ -58,7 +58,7 @@ align 4
|
||||
add edi,GLMaterial.shininess
|
||||
movsd
|
||||
mov dword[edi],SPECULAR_BUFFER_RESOLUTION
|
||||
fdiv dword[sp128f]
|
||||
fdiv dword[fl_128]
|
||||
fimul dword[edi]
|
||||
fistp dword[edi] ;m.shininess_i = (v[0]/128.0f)*SPECULAR_BUFFER_RESOLUTION
|
||||
jmp .end_f
|
||||
@@ -191,7 +191,7 @@ align 4
|
||||
@@:
|
||||
cmp ecx,GL_SPOT_CUTOFF
|
||||
jne .end_spot_c
|
||||
fld dword[ebp+12] ;float a=v.v[0]
|
||||
fld dword[ebx+12] ;float a=v.v[0]
|
||||
; assert(a == 180 || (a>=0 && a<=90));
|
||||
fst dword[edx+GLLight.spot_cutoff] ;l.spot_cutoff=a
|
||||
fcom dword[an180f] ;if (a != 180)
|
||||
@@ -356,9 +356,6 @@ align 4
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
fl_1e_3 dd 1.0e-3
|
||||
|
||||
; non optimized lightening model
|
||||
align 16
|
||||
proc gl_shade_vertex, context:dword, v:dword
|
||||
@@ -395,8 +392,7 @@ pushad
|
||||
|
||||
mov esi,[v]
|
||||
mov edx,[context]
|
||||
mov ecx,edx
|
||||
add ecx,GLContext.materials ;ecx(m) = &context.materials[0]
|
||||
lea ecx,[edx+GLContext.materials] ;ecx(m) = &context.materials[0]
|
||||
mov eax,[edx+GLContext.light_model_two_side]
|
||||
mov [twoside],eax
|
||||
|
||||
@@ -409,7 +405,7 @@ pushad
|
||||
|
||||
fld dword[edx+GLContext.ambient_light_model]
|
||||
fmul dword[ecx+GLMaterial.ambient]
|
||||
fadd dword[ecx] ;GLMaterial.emission=0
|
||||
fadd dword[ecx+GLMaterial.emission]
|
||||
fstp dword[R] ;R=m.emission.v[0]+m.ambient.v[0]*context.ambient_light_model.v[0]
|
||||
fld dword[edx+GLContext.ambient_light_model+4]
|
||||
fmul dword[ecx+GLMaterial.ambient+4]
|
||||
@@ -429,7 +425,7 @@ pushad
|
||||
|
||||
; ambient
|
||||
fld dword[ecx+GLMaterial.ambient]
|
||||
fmul dword[ebx] ;GLLight.ambient=0
|
||||
fmul dword[ebx+GLLight.ambient]
|
||||
fstp dword[lR] ;lR=l.ambient.v[0] * m.ambient.v[0]
|
||||
fld dword[ecx+GLMaterial.ambient+4]
|
||||
fmul dword[ebx+GLLight.ambient+4]
|
||||
@@ -446,8 +442,8 @@ pushad
|
||||
; light at infinity
|
||||
ffree st0 ;l.position.v[3]
|
||||
fincstp
|
||||
mov eax,[ebx+GLLight.norm_position]
|
||||
mov [d],eax ;d.X=l.norm_position.v[0]
|
||||
mov eax,[ebx+GLLight.norm_position+offs_X]
|
||||
mov [d+offs_X],eax ;d.X=l.norm_position.v[0]
|
||||
mov eax,[ebx+GLLight.norm_position+offs_Y]
|
||||
mov [d+offs_Y],eax ;d.Y=l.norm_position.v[1]
|
||||
mov eax,[ebx+GLLight.norm_position+offs_Z]
|
||||
@@ -459,9 +455,9 @@ align 4
|
||||
; distance attenuation
|
||||
ffree st0 ;l.position.v[3]
|
||||
fincstp
|
||||
fld dword[ebx+GLLight.position]
|
||||
fsub dword[esi+GLVertex.ec]
|
||||
fstp dword[d] ;d.X=l.position.v[0]-v.ec.v[0]
|
||||
fld dword[ebx+GLLight.position+offs_X]
|
||||
fsub dword[esi+GLVertex.ec+offs_X]
|
||||
fstp dword[d+offs_X] ;d.X=l.position.v[0]-v.ec.v[0]
|
||||
fld dword[ebx+GLLight.position+offs_Y]
|
||||
fsub dword[esi+GLVertex.ec+offs_Y]
|
||||
fstp dword[d+offs_Y] ;d.Y=l.position.v[1]-v.ec.v[1]
|
||||
@@ -483,9 +479,9 @@ align 4
|
||||
jbe @f ;if (dist>1.0e-3)
|
||||
fld1
|
||||
fdiv st0,st1
|
||||
fld dword[d]
|
||||
fld dword[d+offs_X]
|
||||
fmul st0,st1
|
||||
fstp dword[d]
|
||||
fstp dword[d+offs_X]
|
||||
fld dword[d+offs_Y]
|
||||
fmul st0,st1
|
||||
fstp dword[d+offs_Y]
|
||||
@@ -508,8 +504,8 @@ align 4
|
||||
ffree st0 ;dist
|
||||
fincstp
|
||||
.els_0_end:
|
||||
fld dword[d]
|
||||
fmul dword[n]
|
||||
fld dword[d+offs_X]
|
||||
fmul dword[n+offs_X]
|
||||
fld dword[d+offs_Y]
|
||||
fmul dword[n+offs_Y]
|
||||
faddp
|
||||
@@ -700,7 +696,7 @@ align 4
|
||||
@@:
|
||||
shl dword[idx],2
|
||||
add edi,dword[idx]
|
||||
fld dword[edi+offs_spec_buf] ;dot_spec = specbuf.buf[idx]
|
||||
fld dword[edi+GLSpecBuf.buf] ;dot_spec = specbuf.buf[idx]
|
||||
fld dword[ebx+GLLight.specular]
|
||||
fmul st0,st1
|
||||
fmul dword[ecx+GLMaterial.specular]
|
||||
|
@@ -57,12 +57,13 @@ proc delete_list uses eax ebx ecx edx, context:dword, list:dword
|
||||
; free param buffer
|
||||
mov eax,[edx] ;eax = GLList.first_op_buffer
|
||||
@@:
|
||||
cmp eax,0
|
||||
je .end_w
|
||||
mov ecx,[eax+offs_gpbu_next]
|
||||
or eax,eax
|
||||
jz .end_w
|
||||
mov ecx,[eax+GLParamBuffer.next]
|
||||
stdcall gl_free,eax
|
||||
mov eax,ecx
|
||||
jmp @b
|
||||
align 4
|
||||
.end_w:
|
||||
|
||||
stdcall gl_free,edx
|
||||
@@ -79,10 +80,10 @@ proc alloc_list uses ebx ecx, context:dword, list:dword
|
||||
mov ecx,eax
|
||||
stdcall gl_zalloc,sizeof.GLList
|
||||
|
||||
mov dword[ecx+offs_gpbu_next],0 ;ob.next=NULL
|
||||
mov dword[ecx+GLParamBuffer.next],0 ;ob.next=NULL
|
||||
mov dword[eax],ecx ;l.first_op_buffer=ob
|
||||
|
||||
mov dword[ecx+offs_gpbu_ops],OP_EndList ;ob.ops[0].op=OP_EndList
|
||||
mov dword[ecx+GLParamBuffer.ops],OP_EndList ;ob.ops[0].op=OP_EndList
|
||||
|
||||
mov ebx,[context]
|
||||
mov ebx,[ebx+GLContext.shared_state]
|
||||
@@ -138,12 +139,12 @@ pushad
|
||||
jle @f
|
||||
mov edi,eax
|
||||
stdcall gl_zalloc,sizeof.GLParamBuffer
|
||||
mov dword[eax+offs_gpbu_next],0 ;=NULL
|
||||
mov dword[eax+GLParamBuffer.next],0 ;=NULL
|
||||
|
||||
mov dword[edi+offs_gpbu_next],eax
|
||||
mov dword[edi+GLParamBuffer.next],eax
|
||||
lea esi,[edi+4*ebx]
|
||||
mov dword[esi+offs_gpbu_ops],OP_NextBuffer
|
||||
mov dword[esi+offs_gpbu_ops+4],eax
|
||||
mov dword[esi+GLParamBuffer.ops],OP_NextBuffer
|
||||
mov dword[esi+GLParamBuffer.ops+4],eax
|
||||
|
||||
mov dword[edx+GLContext.current_op_buffer],eax
|
||||
xor ebx,ebx
|
||||
@@ -168,8 +169,8 @@ push edi esi
|
||||
mov ebx,[ebx]
|
||||
lea eax,[op_table_str]
|
||||
@@:
|
||||
cmp ebx,0
|
||||
je @f
|
||||
or ebx,ebx
|
||||
jz @f
|
||||
cmp byte[eax],0
|
||||
jne .no_dec
|
||||
dec ebx
|
||||
@@ -310,8 +311,8 @@ proc glNewList uses eax ebx, list:dword, mode:dword
|
||||
; assert(ebx->compile_flag == 0);
|
||||
|
||||
stdcall find_list,ebx,[list]
|
||||
cmp eax,0
|
||||
je @f
|
||||
or eax,eax
|
||||
jz @f
|
||||
stdcall delete_list,ebx,[list]
|
||||
@@:
|
||||
stdcall alloc_list,ebx,[list]
|
||||
@@ -350,8 +351,8 @@ align 4
|
||||
proc glIsList, list:dword
|
||||
call gl_get_context
|
||||
stdcall find_list, eax,[list]
|
||||
cmp eax,0 ;NULL
|
||||
je @f
|
||||
or eax,eax ;NULL
|
||||
jz @f
|
||||
mov eax,1
|
||||
@@:
|
||||
ret
|
||||
|
@@ -1,5 +1,5 @@
|
||||
;
|
||||
; функции для вычисления зеркального цвета (блики)
|
||||
; functions for calculating specular color (glare)
|
||||
;
|
||||
|
||||
align 4
|
||||
@@ -10,49 +10,41 @@ locals
|
||||
endl
|
||||
mov dword[f_inc],SPECULAR_BUFFER_SIZE
|
||||
mov ebx,[buf]
|
||||
add ebx,offs_spec_buf
|
||||
add ebx,GLSpecBuf.buf
|
||||
mov dword[ebx],0.0 ;buf.buf[0] = 0.0
|
||||
xor ecx,ecx
|
||||
inc ecx
|
||||
fld dword[shininess] ;сначала берем y
|
||||
fld1
|
||||
fidiv dword[f_inc]
|
||||
fst dword[f_inc] ;f_inc = 1.0f/SPECULAR_BUFFER_SIZE
|
||||
fst dword[val]
|
||||
fstp dword[f_inc] ;f_inc = 1.0f/SPECULAR_BUFFER_SIZE
|
||||
mov dword[val],0.0
|
||||
align 4
|
||||
.cycle_0: ;for (i = 1; i <= SPECULAR_BUFFER_SIZE; i++)
|
||||
.cycle_0: ;for (i = 1; i < SPECULAR_BUFFER_SIZE; i++)
|
||||
inc ecx
|
||||
cmp ecx,SPECULAR_BUFFER_SIZE
|
||||
jg @f
|
||||
;Вычисляем x^y
|
||||
jge @f
|
||||
fld dword[shininess]
|
||||
fld dword[val]
|
||||
fadd dword[f_inc]
|
||||
fst dword[val] ;val += f_inc
|
||||
;need to calculate pow(val, shininess)
|
||||
|
||||
fyl2x ;Стек FPU теперь содержит: st0=z=y*log2(x):
|
||||
;Теперь считаем 2**z:
|
||||
fld st0 ;Создаем еще одну копию z
|
||||
frndint ;Округляем
|
||||
fyl2x ;the FPU stack now contains: st0=z=y*log2(x):
|
||||
;now we count 2**z:
|
||||
fld st0 ;copy z
|
||||
frndint
|
||||
fsubr st0,st1 ;st1=z, st0=z-trunc(z)
|
||||
f2xm1 ;st1=z, st0=2**(z-trunc(z))-1
|
||||
fld1
|
||||
faddp ;st1=z, st0=2**(z-trunc(z))
|
||||
fscale ;st1=z, st0=(2**trunc(z))*(2**(z-trunc(z)))=2**t
|
||||
fxch st1
|
||||
fstp st ;Результат остается на вершине стека st0
|
||||
fstp st ;the result remains on the top of the stack st0
|
||||
|
||||
add ebx,4
|
||||
fstp dword[ebx] ;buf.buf[i] = pow(val, shininess)
|
||||
ffree st0 ;испорченный shininess
|
||||
fincstp
|
||||
|
||||
fld dword[shininess] ;сначала берем y
|
||||
fld dword[val]
|
||||
fadd dword[f_inc]
|
||||
fst dword[val] ;val += f_inc
|
||||
inc ecx
|
||||
jmp .cycle_0
|
||||
@@:
|
||||
ffree st0 ;val
|
||||
fincstp
|
||||
ffree st0 ;shininess
|
||||
fincstp
|
||||
mov dword[ebx+4],1.0
|
||||
ret
|
||||
endp
|
||||
|
||||
@@ -70,22 +62,22 @@ endl
|
||||
.cycle_0:
|
||||
or eax,eax ;while (found)
|
||||
jz @f
|
||||
cmp [eax+offs_spec_shininess_i],ebx ;while (found.shininess_i != shininess_i)
|
||||
cmp [eax+GLSpecBuf.shininess_i],ebx ;while (found.shininess_i != shininess_i)
|
||||
je @f
|
||||
mov ecx,[oldest]
|
||||
mov ecx,[ecx+offs_spec_last_used]
|
||||
cmp [eax+offs_spec_last_used],ecx ;if (found.last_used < oldest.last_used)
|
||||
mov ecx,[ecx+GLSpecBuf.last_used]
|
||||
cmp [eax+GLSpecBuf.last_used],ecx ;if (found.last_used < oldest.last_used)
|
||||
jge .end_0
|
||||
mov [oldest],eax ;oldest = found
|
||||
.end_0:
|
||||
mov eax,[eax+offs_spec_next] ;found = found.next
|
||||
mov eax,[eax+GLSpecBuf.next] ;found = found.next
|
||||
jmp .cycle_0
|
||||
@@:
|
||||
cmp dword[found],0 ;if (found) /* hey, found one! */
|
||||
je @f
|
||||
mov eax,[found]
|
||||
mov ecx,[edx+GLContext.specbuf_used_counter]
|
||||
mov [eax+offs_spec_last_used],ecx ;found.last_used = context.specbuf_used_counter
|
||||
mov [eax+GLSpecBuf.last_used],ecx ;found.last_used = context.specbuf_used_counter
|
||||
inc dword[edx+GLContext.specbuf_used_counter]
|
||||
jmp .end_f ;return found
|
||||
@@:
|
||||
@@ -102,21 +94,21 @@ endl
|
||||
@@:
|
||||
inc dword[edx+GLContext.specbuf_num_buffers]
|
||||
mov ecx,[edx+GLContext.specbuf_first]
|
||||
mov [eax+offs_spec_next],ecx
|
||||
mov [eax+GLSpecBuf.next],ecx
|
||||
mov [edx+GLContext.specbuf_first],eax
|
||||
mov ecx,[edx+GLContext.specbuf_used_counter]
|
||||
mov [eax+offs_spec_last_used],ecx
|
||||
mov [eax+GLSpecBuf.last_used],ecx
|
||||
inc dword[edx+GLContext.specbuf_used_counter]
|
||||
mov [eax+offs_spec_shininess_i],ebx
|
||||
mov [eax+GLSpecBuf.shininess_i],ebx
|
||||
stdcall calc_buf, eax,dword[shininess]
|
||||
jmp .end_f
|
||||
.end_1:
|
||||
; overwrite the lru buffer
|
||||
;tgl_trace("overwriting spec buffer :(\n");
|
||||
mov eax,[oldest]
|
||||
mov [eax+offs_spec_shininess_i],ebx
|
||||
mov [eax+GLSpecBuf.shininess_i],ebx
|
||||
mov ecx,[edx+GLContext.specbuf_used_counter]
|
||||
mov [eax+offs_spec_last_used],ecx
|
||||
mov [eax+GLSpecBuf.last_used],ecx
|
||||
inc dword[edx+GLContext.specbuf_used_counter]
|
||||
stdcall calc_buf, eax,dword[shininess]
|
||||
.end_f:
|
||||
|
@@ -17,9 +17,9 @@ proc find_texture uses ebx ecx, context:dword, h:dword
|
||||
cmp dword[eax],0
|
||||
je .no_found
|
||||
mov ebx,[eax]
|
||||
cmp dword[ebx+offs_text_handle],ecx
|
||||
cmp dword[ebx+GLTexture.handle],ecx
|
||||
je .found
|
||||
mov eax,[ebx+offs_text_next]
|
||||
mov eax,[ebx+GLTexture.next]
|
||||
jmp @b
|
||||
.no_found:
|
||||
xor eax,eax ;ret NULL
|
||||
@@ -32,36 +32,36 @@ proc free_texture uses eax ebx ecx edx, context:dword, h:dword
|
||||
mov edx,[context]
|
||||
|
||||
stdcall find_texture,edx,[h] ;t=find_texture(context,h)
|
||||
cmp dword[eax+offs_text_prev],0 ;if (t.prev==NULL)
|
||||
cmp dword[eax+GLTexture.prev],0 ;if (t.prev==NULL)
|
||||
jne .else
|
||||
mov edx,[edx+GLContext.shared_state+4] ;edx = &context.shared_state.texture_hash_table[0]
|
||||
mov ebx,[eax+offs_text_handle]
|
||||
mov ebx,[eax+GLTexture.handle]
|
||||
and ebx,0xff
|
||||
shl ebx,2
|
||||
add edx,ebx ;edx = &context.shared_state.texture_hash_table[t.handle % TEXTURE_HASH_TABLE_SIZE]
|
||||
mov ebx,[eax+offs_text_next]
|
||||
mov ebx,[eax+GLTexture.next]
|
||||
mov [edx],ebx ;*ht=t.next
|
||||
jmp @f
|
||||
.else:
|
||||
mov ebx,[eax+offs_text_prev]
|
||||
mov ecx,[eax+offs_text_next]
|
||||
mov [ebx+offs_text_next],ecx ;t.prev.next=t.next
|
||||
mov ebx,[eax+GLTexture.prev]
|
||||
mov ecx,[eax+GLTexture.next]
|
||||
mov [ebx+GLTexture.next],ecx ;t.prev.next=t.next
|
||||
@@:
|
||||
cmp dword[eax+offs_text_next],0 ;if (t.next!=NULL)
|
||||
cmp dword[eax+GLTexture.next],0 ;if (t.next!=NULL)
|
||||
je @f
|
||||
mov ebx,[eax+offs_text_next]
|
||||
mov ecx,[eax+offs_text_prev]
|
||||
mov [ebx+offs_text_prev],ecx ;t.next.prev=t.prev
|
||||
mov ebx,[eax+GLTexture.next]
|
||||
mov ecx,[eax+GLTexture.prev]
|
||||
mov [ebx+GLTexture.prev],ecx ;t.next.prev=t.prev
|
||||
@@:
|
||||
|
||||
xor ebx,ebx
|
||||
mov ecx,[eax+offs_text_images] ;im=&t.images[0]
|
||||
mov ecx,[eax+GLTexture.images] ;im=&t.images[0]
|
||||
.cycle_0: ;for(i=0;i<MAX_TEXTURE_LEVELS;i++)
|
||||
cmp ebx,MAX_TEXTURE_LEVELS
|
||||
jge .cycle_0_end
|
||||
cmp dword[ecx+offs_imag_pixmap],0 ;if (im.pixmap != NULL)
|
||||
cmp dword[ecx+GLImage.pixmap],0 ;if (im.pixmap != NULL)
|
||||
je @f
|
||||
stdcall gl_free,[ecx+offs_imag_pixmap]
|
||||
stdcall gl_free,[ecx+GLImage.pixmap]
|
||||
@@:
|
||||
add ecx,sizeof.GLImage
|
||||
inc ebx
|
||||
@@ -87,16 +87,16 @@ proc alloc_texture uses ebx ecx, context:dword, h:dword
|
||||
add ecx,ebx ;ecx = &context.shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE]
|
||||
|
||||
mov ebx,[ecx]
|
||||
mov [eax+offs_text_next],ebx
|
||||
mov dword[eax+offs_text_prev],0 ;NULL
|
||||
cmp dword[eax+offs_text_next],0 ;NULL
|
||||
mov [eax+GLTexture.next],ebx
|
||||
mov dword[eax+GLTexture.prev],0 ;NULL
|
||||
cmp dword[eax+GLTexture.next],0 ;NULL
|
||||
je @f
|
||||
mov [eax+offs_text_prev],eax
|
||||
mov [eax+GLTexture.prev],eax
|
||||
@@:
|
||||
mov [ecx],eax
|
||||
|
||||
mov ebx,[h]
|
||||
mov [eax+offs_text_handle],ebx
|
||||
mov [eax+GLTexture.handle],ebx
|
||||
|
||||
ret
|
||||
endp
|
||||
@@ -129,11 +129,11 @@ proc glGenTextures uses eax ebx ecx edx esi, n:dword, textures:dword
|
||||
.cycle_1: ;while (t!=NULL)
|
||||
or edx,edx
|
||||
jz .cycle_1_end
|
||||
cmp [edx+offs_text_handle],ebx ;if (t.handle>max)
|
||||
cmp [edx+GLTexture.handle],ebx ;if (t.handle>max)
|
||||
jle @f
|
||||
mov ebx,[edx+offs_text_handle] ;max=t.handle
|
||||
mov ebx,[edx+GLTexture.handle] ;max=t.handle
|
||||
@@:
|
||||
mov edx,[edx+offs_text_next] ;t=t.next
|
||||
mov edx,[edx+GLTexture.next] ;t=t.next
|
||||
jmp .cycle_1
|
||||
.cycle_1_end:
|
||||
inc ecx
|
||||
@@ -266,22 +266,22 @@ align 4
|
||||
|
||||
mov ecx,[context]
|
||||
mov ecx,[ecx+GLContext.current_texture]
|
||||
add ecx,offs_text_images
|
||||
add ecx,GLTexture.images
|
||||
imul ebx,sizeof.GLTexture
|
||||
add ecx,ebx ;ecx = &context.current_texture.images[level]
|
||||
mov [ecx+offs_imag_xsize],edx ;im.xsize=width
|
||||
mov [ecx+offs_imag_ysize],esi ;im.ysize=height
|
||||
mov [ecx+GLImage.xsize],edx ;im.xsize=width
|
||||
mov [ecx+GLImage.ysize],esi ;im.ysize=height
|
||||
mov ebx,edx
|
||||
dec ebx
|
||||
shl ebx,ZB_POINT_TEXEL_SIZE
|
||||
mov [ecx+offs_imag_s_bound],ebx ;im.s_bound = (unsigned int)(width-1)
|
||||
mov [ecx+GLImage.s_bound],ebx ;im.s_bound = (unsigned int)(width-1)
|
||||
shr ebx,ZB_POINT_TEXEL_SIZE
|
||||
|
||||
mov dword[ecx+offs_imag_xsize_log2],ZB_POINT_TEXEL_SIZE
|
||||
mov dword[ecx+GLImage.xsize_log2],ZB_POINT_TEXEL_SIZE
|
||||
or ebx,ebx
|
||||
jz .set_l2
|
||||
@@:
|
||||
dec dword[ecx+offs_imag_xsize_log2]
|
||||
dec dword[ecx+GLImage.xsize_log2]
|
||||
shr ebx,1
|
||||
or ebx,ebx
|
||||
jnz @b
|
||||
@@ -289,18 +289,18 @@ align 4
|
||||
;im.xsize_log2 = ZB_POINT_TEXEL_SIZE-log_2(width)
|
||||
dec esi
|
||||
shl esi,ZB_POINT_TEXEL_SIZE
|
||||
mov [ecx+offs_imag_t_bound],esi ;im.t_bound = (unsigned int)(height-1)
|
||||
mov [ecx+GLImage.t_bound],esi ;im.t_bound = (unsigned int)(height-1)
|
||||
shr esi,ZB_POINT_TEXEL_SIZE
|
||||
inc esi
|
||||
cmp dword[ecx+offs_imag_pixmap],0 ;if (im.pixmap!=NULL)
|
||||
cmp dword[ecx+GLImage.pixmap],0 ;if (im.pixmap!=NULL)
|
||||
je @f
|
||||
stdcall gl_free, [ecx+offs_imag_pixmap]
|
||||
stdcall gl_free, [ecx+GLImage.pixmap]
|
||||
@@:
|
||||
if TGL_FEATURE_RENDER_BITS eq 24
|
||||
imul edx,esi
|
||||
imul edx,3
|
||||
stdcall gl_malloc,edx
|
||||
mov [ecx+offs_imag_pixmap],eax ;im.pixmap = gl_malloc(width*height*3)
|
||||
mov [ecx+GLImage.pixmap],eax ;im.pixmap = gl_malloc(width*height*3)
|
||||
or eax,eax ;if(im.pixmap)
|
||||
jz @f
|
||||
mov edi,eax
|
||||
@@ -314,7 +314,7 @@ if TGL_FEATURE_RENDER_BITS eq 32
|
||||
imul edx,esi
|
||||
shl edx,2
|
||||
stdcall gl_malloc,edx
|
||||
mov [ecx+offs_imag_pixmap],eax ;im.pixmap = gl_malloc(width*height*4)
|
||||
mov [ecx+GLImage.pixmap],eax ;im.pixmap = gl_malloc(width*height*4)
|
||||
or eax,eax ;if(im.pixmap)
|
||||
jz @f
|
||||
;gl_convertRGB_to_8A8R8G8B(eax,[pixels1],ebx,esi)
|
||||
|
@@ -51,16 +51,11 @@ struct GLSpecBuf
|
||||
next dd ? ;struct GLSpecBuf*
|
||||
ends
|
||||
|
||||
offs_spec_shininess_i equ 0
|
||||
offs_spec_last_used equ 4
|
||||
offs_spec_buf equ 8
|
||||
offs_spec_next equ 8+4*(SPECULAR_BUFFER_SIZE+1)
|
||||
|
||||
struct GLLight
|
||||
ambient V4
|
||||
diffuse V4
|
||||
ambient V4
|
||||
diffuse V4
|
||||
specular V4
|
||||
position V4
|
||||
position V4
|
||||
spot_direction V3
|
||||
spot_exponent dd ? ;float
|
||||
spot_cutoff dd ? ;float
|
||||
@@ -102,9 +97,6 @@ struct GLParamBuffer
|
||||
next dd ? ;struct GLParamBuffer*
|
||||
ends
|
||||
|
||||
offs_gpbu_ops equ 0
|
||||
offs_gpbu_next equ 4*OP_BUFFER_MAX_SIZE
|
||||
|
||||
struct GLList
|
||||
first_op_buffer dd ? ;GLParamBuffer*
|
||||
; TODO: extensions for an hash table or a better allocating scheme
|
||||
@@ -133,29 +125,17 @@ struct GLImage
|
||||
t_bound dd ? ;unsigned int
|
||||
ends
|
||||
|
||||
offs_imag_pixmap equ 0
|
||||
offs_imag_xsize equ 4
|
||||
offs_imag_ysize equ 8
|
||||
offs_imag_xsize_log2 equ 12
|
||||
offs_imag_s_bound equ 16
|
||||
offs_imag_t_bound equ 20
|
||||
|
||||
; textures
|
||||
|
||||
TEXTURE_HASH_TABLE_SIZE equ 256 ;должно быть кратное 2, в коде берется остаток от деления (через and быстрее чем div)
|
||||
|
||||
struct GLTexture
|
||||
images rb sizeof.GLImage * MAX_TEXTURE_LEVELS ;GLImage[MAX_TEXTURE_LEVELS]
|
||||
images rd (sizeof.GLImage * MAX_TEXTURE_LEVELS)/4 ;GLImage[MAX_TEXTURE_LEVELS]
|
||||
handle dd ? ;int
|
||||
next dd ? ;struct GLTexture*
|
||||
prev dd ? ;struct GLTexture*
|
||||
ends
|
||||
|
||||
offs_text_images equ 0
|
||||
offs_text_handle equ sizeof.GLImage*MAX_TEXTURE_LEVELS
|
||||
offs_text_next equ 4+offs_text_handle
|
||||
offs_text_prev equ 8+offs_text_handle
|
||||
|
||||
; shared state
|
||||
|
||||
struct GLSharedState
|
||||
|
@@ -114,9 +114,7 @@ end if
|
||||
|
||||
macro DRAWLINE d_x,d_y,inc_1,inc_2
|
||||
{
|
||||
local .mz_0
|
||||
local .mz_1
|
||||
local .mz_2
|
||||
|
||||
mov eax,d_x
|
||||
mov [n],eax
|
||||
@@ -124,26 +122,12 @@ if INTERP_Z eq 1
|
||||
mov ebx,[p1]
|
||||
mov eax,[p2]
|
||||
mov eax,[eax+ZBufferPoint.z]
|
||||
cmp eax,[ebx+ZBufferPoint.z]
|
||||
jg .mz_0
|
||||
je .mz_1
|
||||
;if(p2.z<p1.z)
|
||||
sub eax,[ebx+ZBufferPoint.z]
|
||||
neg eax
|
||||
inc eax
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
neg eax
|
||||
inc eax
|
||||
jmp .mz_2
|
||||
.mz_0:
|
||||
sub eax,[ebx+ZBufferPoint.z]
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mz_2
|
||||
jz .mz_1
|
||||
;if(p2.z!=p1.z)
|
||||
cdq
|
||||
idiv dword[n]
|
||||
.mz_1:
|
||||
xor eax,eax
|
||||
.mz_2:
|
||||
mov [zinc],eax ;zinc=(p2.z-p1.z)/n
|
||||
end if
|
||||
shl dword d_y,1
|
||||
|
@@ -115,18 +115,10 @@ end if
|
||||
|
||||
macro DRAWLINE d_x,d_y,inc_1,inc_2
|
||||
{
|
||||
local .mz_0
|
||||
local .mz_1
|
||||
local .mz_2
|
||||
local .mr_0
|
||||
local .mr_1
|
||||
local .mr_2
|
||||
local .mg_0
|
||||
local .mg_1
|
||||
local .mg_2
|
||||
local .mb_0
|
||||
local .mb_1
|
||||
local .mb_2
|
||||
|
||||
mov eax,d_x
|
||||
mov [n],eax
|
||||
@@ -135,103 +127,44 @@ local .mb_2
|
||||
mov ecx,[p2]
|
||||
if INTERP_Z eq 1
|
||||
mov eax,[ecx+ZBufferPoint.z]
|
||||
cmp eax,[ebx+ZBufferPoint.z]
|
||||
jg .mz_0
|
||||
je .mz_1
|
||||
;if(p2.z<p1.z)
|
||||
sub eax,[ebx+ZBufferPoint.z]
|
||||
neg eax
|
||||
inc eax
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
neg eax
|
||||
inc eax
|
||||
jmp .mz_2
|
||||
.mz_0:
|
||||
sub eax,[ebx+ZBufferPoint.z]
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mz_2
|
||||
jz .mz_1
|
||||
;if(p2.z!=p1.z)
|
||||
cdq
|
||||
idiv dword[n]
|
||||
.mz_1:
|
||||
xor eax,eax
|
||||
.mz_2:
|
||||
mov [zinc],eax ;zinc=(p2.z-p1.z)/n
|
||||
end if
|
||||
|
||||
;ebx=&p1, ecx=&p2
|
||||
mov eax,[ecx+ZBufferPoint.r]
|
||||
cmp eax,[ebx+ZBufferPoint.r]
|
||||
jg .mr_0
|
||||
je .mr_1
|
||||
;if(p2.r<p1.r)
|
||||
sub eax,[ebx+ZBufferPoint.r]
|
||||
neg eax
|
||||
inc eax
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
neg eax
|
||||
inc eax
|
||||
jmp .mr_2
|
||||
.mr_0:
|
||||
sub eax,[ebx+ZBufferPoint.r]
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mr_2
|
||||
jz .mr_1
|
||||
;if(p2.r!=p1.r)
|
||||
shl eax,8
|
||||
cdq
|
||||
idiv dword[n]
|
||||
.mr_1:
|
||||
xor eax,eax
|
||||
.mr_2:
|
||||
mov [rinc],eax ;rinc=((p2.r-p1.r)<<8)/n
|
||||
|
||||
mov eax,[ecx+ZBufferPoint.g]
|
||||
cmp eax,[ebx+ZBufferPoint.g]
|
||||
jg .mg_0
|
||||
je .mg_1
|
||||
;if(p2.g<p1.g)
|
||||
sub eax,[ebx+ZBufferPoint.g]
|
||||
neg eax
|
||||
inc eax
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
neg eax
|
||||
inc eax
|
||||
jmp .mg_2
|
||||
.mg_0:
|
||||
sub eax,[ebx+ZBufferPoint.g]
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mg_2
|
||||
jz .mg_1
|
||||
;if(p2.g!=p1.g)
|
||||
shl eax,8
|
||||
cdq
|
||||
idiv dword[n]
|
||||
.mg_1:
|
||||
xor eax,eax
|
||||
.mg_2:
|
||||
mov [ginc],eax ;ginc=((p2.g-p1.g)<<8)/n
|
||||
|
||||
mov eax,[ecx+ZBufferPoint.b]
|
||||
cmp eax,[ebx+ZBufferPoint.b]
|
||||
jg .mb_0
|
||||
je .mb_1
|
||||
;if(p2.b<p1.b)
|
||||
sub eax,[ebx+ZBufferPoint.b]
|
||||
neg eax
|
||||
inc eax
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
neg eax
|
||||
inc eax
|
||||
jmp .mb_2
|
||||
.mb_0:
|
||||
sub eax,[ebx+ZBufferPoint.b]
|
||||
shl eax,8
|
||||
xor edx,edx
|
||||
div dword[n]
|
||||
jmp .mb_2
|
||||
jz .mb_1
|
||||
;if(p2.b!=p1.b)
|
||||
shl eax,8
|
||||
cdq
|
||||
idiv dword[n]
|
||||
.mb_1:
|
||||
xor eax,eax
|
||||
.mb_2:
|
||||
mov [binc],eax ;binc=((p2.b-p1.b)<<8)/n
|
||||
|
||||
shl dword d_y,1
|
||||
|
@@ -393,20 +393,9 @@ align 4
|
||||
mov [dx1],eax ;dx1 = l2.x - l1.x
|
||||
cmp edx,0 ;if (dy1 > 0)
|
||||
jle .els_3
|
||||
xor edx,edx
|
||||
cmp eax,0
|
||||
jl .otr_dx1
|
||||
shl eax,16
|
||||
div dword[dy1] ;eax = (dx1 << 16) / dy1
|
||||
jmp .end_3
|
||||
align 4
|
||||
.otr_dx1:
|
||||
neg eax
|
||||
inc eax
|
||||
shl eax,16
|
||||
div dword[dy1] ;eax = (-dx1 << 16) / dy1
|
||||
neg eax
|
||||
inc eax
|
||||
cdq
|
||||
idiv dword[dy1] ;eax = (dx1 << 16) / dy1
|
||||
jmp .end_3
|
||||
align 4
|
||||
.els_3:
|
||||
@@ -505,7 +494,6 @@ end if
|
||||
.end_upd_l:
|
||||
|
||||
; compute values for the right edge
|
||||
|
||||
cmp dword[update_right],0 ;if(update_right)
|
||||
je .end_upd_r
|
||||
mov ebx,[pr1]
|
||||
@@ -521,20 +509,9 @@ end if
|
||||
mov [dy2],edx ;dy2 = pr2.y - pr1.y
|
||||
cmp edx,0 ;if (dy2 > 0)
|
||||
jle .els_4
|
||||
xor edx,edx
|
||||
cmp eax,0
|
||||
jl .otr_dx2
|
||||
shl eax,16
|
||||
div dword[dy2] ;eax = (dx2 << 16) / dy2
|
||||
jmp .end_4
|
||||
align 4
|
||||
.otr_dx2:
|
||||
neg eax
|
||||
inc eax ;dx2 *= -1
|
||||
shl eax,16
|
||||
div dword[dy2] ;eax = (-dx2 << 16) / dy2
|
||||
neg eax
|
||||
inc eax
|
||||
cdq
|
||||
idiv dword[dy2] ;eax = (dx2 << 16) / dy2
|
||||
jmp .end_4
|
||||
align 4
|
||||
.els_4:
|
||||
|
Reference in New Issue
Block a user