From 62b33c499496c9b5ef69a1462369ef284c1f27de Mon Sep 17 00:00:00 2001 From: IgorA Date: Fri, 31 Oct 2014 21:28:24 +0000 Subject: [PATCH] Fork for library tinygl, assembly version. Can draw lines, and do some matrix operations. git-svn-id: svn://kolibrios.org@5153 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../develop/libraries/TinyGL/asm_fork/api.asm | 1005 +++++++++ .../libraries/TinyGL/asm_fork/arrays.asm | 360 +++ .../libraries/TinyGL/asm_fork/build.bat | 4 + .../libraries/TinyGL/asm_fork/clear.asm | 34 + .../libraries/TinyGL/asm_fork/clip.asm | 923 ++++++++ .../libraries/TinyGL/asm_fork/export.inc | 164 ++ .../TinyGL/asm_fork/info_fun_float.inc | 326 +++ .../libraries/TinyGL/asm_fork/init.asm | 207 ++ .../libraries/TinyGL/asm_fork/kosgl.asm | 146 ++ .../libraries/TinyGL/asm_fork/light.asm | 350 +++ .../libraries/TinyGL/asm_fork/list.asm | 329 +++ .../libraries/TinyGL/asm_fork/matrix.asm | 521 +++++ .../libraries/TinyGL/asm_fork/misc.asm | 273 +++ .../TinyGL/asm_fork/opengl_const.inc | 1963 +++++++++++++++++ .../libraries/TinyGL/asm_fork/opinfo.inc | 70 + .../libraries/TinyGL/asm_fork/select.asm | 168 ++ .../libraries/TinyGL/asm_fork/texture.asm | 260 +++ .../libraries/TinyGL/asm_fork/tinygl.asm | 204 ++ .../libraries/TinyGL/asm_fork/vertex.asm | 651 ++++++ .../libraries/TinyGL/asm_fork/zbuffer.asm | 545 +++++ .../libraries/TinyGL/asm_fork/zbuffer.inc | 178 ++ .../libraries/TinyGL/asm_fork/zfeatures.inc | 43 + .../develop/libraries/TinyGL/asm_fork/zgl.inc | 515 +++++ .../libraries/TinyGL/asm_fork/zline.asm | 164 ++ .../libraries/TinyGL/asm_fork/zline.inc | 226 ++ .../libraries/TinyGL/asm_fork/zline_r.inc | 257 +++ .../libraries/TinyGL/asm_fork/zmath.asm | 428 ++++ .../libraries/TinyGL/asm_fork/zmath.inc | 42 + .../libraries/TinyGL/asm_fork/ztriangle.asm | 344 +++ .../libraries/TinyGL/asm_fork/ztriangle.inc | 415 ++++ 30 files changed, 11115 insertions(+) create mode 100644 programs/develop/libraries/TinyGL/asm_fork/api.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/arrays.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/build.bat create mode 100644 programs/develop/libraries/TinyGL/asm_fork/clear.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/clip.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/export.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/info_fun_float.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/init.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/kosgl.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/light.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/list.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/matrix.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/misc.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/opengl_const.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/opinfo.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/select.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/texture.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/tinygl.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/vertex.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zbuffer.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zfeatures.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zgl.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zline.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zline.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zline_r.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zmath.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/zmath.inc create mode 100644 programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm create mode 100644 programs/develop/libraries/TinyGL/asm_fork/ztriangle.inc diff --git a/programs/develop/libraries/TinyGL/asm_fork/api.asm b/programs/develop/libraries/TinyGL/asm_fork/api.asm new file mode 100644 index 0000000000..1ea2a46e28 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/api.asm @@ -0,0 +1,1005 @@ +; glVertex + +align 4 +proc glVertex4f uses eax, x:dword, y:dword, z:dword, w:dword +locals + p rd 5 +endl + mov dword[p],OP_Vertex + mov eax,[x] + mov dword[p+4],eax + mov eax,[y] + mov dword[p+8],eax + mov eax,[z] + mov dword[p+12],eax + mov eax,[w] + mov dword[p+16],eax + + mov eax,ebp + sub eax,20 ;=sizeof(dd)*5 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glVertex2f, x:dword, y:dword + stdcall glVertex4f,[x],[y],0.0,1.0 + ret +endp + +align 4 +proc glVertex3f, x:dword, y:dword, z:dword + stdcall glVertex4f,[x],[y],[z],1.0 + ret +endp + +align 4 +proc glVertex3fv uses eax, v:dword + mov eax,[v] + stdcall glVertex4f,[eax],[eax+4],[eax+8],1.0 + ret +endp + +; glNormal + +align 4 +proc glNormal3f uses eax, x:dword, y:dword, z:dword +locals + p rd 4 +endl + mov dword[p],OP_Normal + mov eax,[x] + mov dword[p+4],eax + mov eax,[y] + mov dword[p+8],eax + mov eax,[z] + mov dword[p+12],eax + + mov eax,ebp + sub eax,16 ;=sizeof(dd)*4 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glNormal3fv uses eax, v:dword + mov eax,[v] + stdcall glNormal3f,[eax],[eax+4],[eax+8] + ret +endp + +; glColor + +align 4 +proc glColor4f uses eax, r:dword, g:dword, b:dword, a:dword +locals + p rd 8 +endl + mov dword[p],OP_Color + mov eax,[b] + mov dword[p+4],eax + mov eax,[g] + mov dword[p+8],eax + mov eax,[r] + mov dword[p+12],eax + mov eax,[a] + mov dword[p+16],eax + ; direct convertion to integer to go faster if no shading + mov eax,ebp + sub eax,12 ;ebp-12 = &p[5] + push eax + add eax,4 ;ebp-8 = &p[6] + push eax + add eax,4 ;ebp-4 = &p[7] + push eax + stdcall RGBFtoRGBI,[r],[g],[b] ;call: r,g,b,&p[7],&p[6],&p[5] + + mov eax,ebp + sub eax,32 ;=sizeof(dd)*8 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glColor4fv uses eax ebx, v:dword +locals + p rd 8 +endl + mov dword[p],OP_Color + mov eax,[v] + mov ebx,[eax+8] + mov dword[p+4],ebx + mov ebx,[eax+4] + mov dword[p+8],ebx + mov ebx,[eax] + mov dword[p+12],ebx + mov ebx,[eax+12] + mov dword[p+16],ebx + ; direct convertion to integer to go faster if no shading + mov eax,ebp + sub eax,4 + push eax ;&p[7] + sub eax,4 + push eax ;&p[6] + sub eax,4 + push eax ;&p[5] + stdcall RGBFtoRGBI,[eax+8],[eax+4],[eax] ;call: v[2],v[1],v[0],p[5],p[6],p[7] + + mov eax,ebp + sub eax,32 ;=sizeof(dd)*8 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glColor3f, r:dword, g:dword, b:dword + stdcall glColor4f,[r],[g],[b],1.0 + ret +endp + +align 4 +proc glColor3fv uses eax, v:dword + mov eax,[v] + stdcall glColor4f,[eax],[eax+4],[eax+8],1.0 + ret +endp + +; TexCoord + +align 4 +proc glTexCoord4f uses eax, s:dword, t:dword, r:dword, q:dword +locals + p rd 5 +endl + mov dword[p],OP_TexCoord + mov eax,[s] + mov dword[p+4],eax + mov eax,[t] + mov dword[p+8],eax + mov eax,[r] + mov dword[p+12],eax + mov eax,[q] + mov dword[p+16],eax + + mov eax,ebp + sub eax,20 ;=sizeof(dd)*5 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glTexCoord2f, s:dword, t:dword + stdcall glTexCoord4f,[s],[t],0.0,1.0 + ret +endp + +align 4 +proc glTexCoord2fv uses eax, v:dword + mov eax,[v] + stdcall glTexCoord4f,[eax],[eax+4],0.0,1.0 + ret +endp + +align 4 +proc glEdgeFlag uses eax, flag:dword +locals + p rd 2 +endl + mov dword[p],OP_EdgeFlag + mov eax,[flag] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +; misc + +align 4 +proc glShadeModel uses eax, mode:dword +locals + p rd 2 +endl + +; assert(mode == GL_FLAT || mode == GL_SMOOTH); + + mov dword[p],OP_ShadeModel + mov eax,[mode] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glCullFace uses eax, mode:dword +locals + p rd 2 +endl + +; assert(mode == GL_BACK || +; mode == GL_FRONT || +; mode == GL_FRONT_AND_BACK); + + mov dword[p],OP_CullFace + mov eax,[mode] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glFrontFace uses eax, mode:dword +locals + p rd 2 +endl + +; assert(mode == GL_CCW || mode == GL_CW); + + mov dword[p],OP_FrontFace + xor eax,eax + cmp dword[mode],GL_CCW + je @f + inc eax + @@: + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glPolygonMode uses eax, face:dword, mode:dword +locals + p rd 3 +endl + +; assert(face == GL_BACK || +; face == GL_FRONT || +; face == GL_FRONT_AND_BACK); +; assert(mode == GL_POINT || mode == GL_LINE || mode==GL_FILL); + + mov dword[p],OP_PolygonMode + mov eax,[face] + mov dword[p+4],eax + mov eax,[mode] + mov dword[p+8],eax + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +; glEnable / glDisable + +align 4 +proc glEnable uses eax, cap:dword +locals + p rd 3 +endl + mov dword[p],OP_EnableDisable + mov eax,[cap] + mov dword[p+4],eax + mov dword[p+8],1 + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glDisable uses eax, cap:dword +locals + p rd 3 +endl + mov dword[p],OP_EnableDisable + mov eax,[cap] + mov dword[p+4],eax + mov dword[p+8],0 + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +; glBegin / glEnd + +align 4 +proc glBegin uses eax, mode:dword +locals + p rd 2 +endl + mov dword[p],OP_Begin + mov eax,[mode] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glEnd uses eax +locals + p dd ? +endl + mov dword[p],OP_End + + mov eax,ebp + sub eax,4 ;=sizeof(dd)*1 + stdcall gl_add_op,eax + ret +endp + +; matrix + +align 4 +proc glMatrixMode uses eax, mode:dword +locals + p rd 2 +endl + mov dword[p],OP_MatrixMode + mov eax,[mode] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glLoadMatrixf uses ecx edi esi, m:dword +locals + p rd 17 +endl + mov dword[p],OP_LoadMatrix + mov ecx,16 + mov esi,[m] + mov edi,ebp + sub edi,64 ;=sizeof(M4) + rep movsd + + mov ecx,ebp + sub ecx,68 ;=sizeof(dd)*17 + stdcall gl_add_op,ecx + ret +endp + +align 4 +proc glLoadIdentity uses eax +locals + p dd ? +endl + mov dword[p],OP_LoadIdentity + + mov eax,ebp + sub eax,4 ;=sizeof(dd)*1 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glMultMatrixf uses ecx edi esi, m:dword +locals + p rd 17 +endl + mov dword[p],OP_MultMatrix + mov ecx,16 + mov esi,[m] + mov edi,ebp + sub edi,64 ;=sizeof(M4) + rep movsd + + mov ecx,ebp + sub ecx,68 ;=sizeof(dd)*17 + stdcall gl_add_op,ecx + ret +endp + +align 4 +proc glPushMatrix uses eax +locals + p dd ? +endl + mov dword[p],OP_PushMatrix + + mov eax,ebp + sub eax,4 ;=sizeof(dd)*1 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glPopMatrix uses eax +locals + p dd ? +endl + mov dword[p],OP_PopMatrix + + mov eax,ebp + sub eax,4 ;=sizeof(dd)*1 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glRotatef uses eax, angle:dword, x:dword, y:dword, z:dword +locals + p rd 5 +endl + mov dword[p],OP_Rotate + mov eax,[angle] + mov dword[p+4],eax + mov eax,[x] + mov dword[p+8],eax + mov eax,[y] + mov dword[p+12],eax + mov eax,[z] + mov dword[p+16],eax + + mov eax,ebp + sub eax,20 ;=sizeof(dd)*5 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glTranslatef uses eax, x:dword, y:dword, z:dword +locals + p rd 4 +endl + mov dword[p],OP_Translate + mov eax,[x] + mov dword[p+4],eax + mov eax,[y] + mov dword[p+8],eax + mov eax,[z] + mov dword[p+12],eax + + mov eax,ebp + sub eax,16 ;=sizeof(dd)*4 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glScalef uses eax, x:dword, y:dword, z:dword +locals + p rd 4 +endl + mov dword[p],OP_Scale + mov eax,[x] + mov dword[p+4],eax + mov eax,[y] + mov dword[p+8],eax + mov eax,[z] + mov dword[p+12],eax + + mov eax,ebp + sub eax,16 ;=sizeof(dd)*4 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glViewport uses eax, x:dword, y:dword, width:dword, heigh:dword +locals + p rd 5 +endl + mov dword[p],OP_Viewport + mov eax,[x] + mov dword[p+4],eax + mov eax,[y] + mov dword[p+8],eax + mov eax,[width] + mov dword[p+12],eax + mov eax,[heigh] + mov dword[p+16],eax + + mov eax,ebp + sub eax,20 ;=sizeof(dd)*5 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glFrustum uses eax, left:dword,right:dword,bottom:dword,top:dword,\ + near:dword,farv:dword +locals + p rd 7 +endl + mov dword[p],OP_Frustum + mov eax,[left] + fld qword[eax] + fstp dword[p+4] + mov eax,[right] + fld qword[eax] + fstp dword[p+8] + mov eax,[bottom] + fld qword[eax] + fstp dword[p+12] + mov eax,[top] + fld qword[eax] + fstp dword[p+16] + mov eax,[near] + fld qword[eax] + fstp dword[p+20] + mov eax,[farv] + fld qword[eax] + fstp dword[p+24] + + mov eax,ebp + sub eax,28 ;=sizeof(dd)*7 + stdcall gl_add_op,eax + ret +endp + +;/* lightening */ + +align 4 +proc glMaterialfv uses eax ecx, mode:dword, type:dword, v:dword +locals + p rd 7 +endl + +; assert(mode == GL_FRONT || mode == GL_BACK || mode==GL_FRONT_AND_BACK); + + mov dword[p],OP_Material + mov eax,[mode] + mov dword[p+4],eax + mov eax,[type] + mov dword[p+8],eax + + mov eax,[v] + mov ecx,[eax+8] + mov dword[p+12],ecx + mov ecx,[eax+4] + mov dword[p+16],ecx + mov ecx,[eax] + mov dword[p+20],ecx + mov ecx,[eax+12] + mov dword[p+24],ecx + + cmp dword[type],GL_SHININESS + jne @f + mov dword[p+16],0.0 + mov dword[p+20],0.0 + mov dword[p+24],0.0 + @@: + + mov eax,ebp + sub eax,28 ;=sizeof(dd)*7 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glMaterialf uses eax, mode:dword, type:dword, v:dword +locals + p rd 7 +endl + mov dword[p],OP_Material + mov eax,[mode] + mov dword[p+4],eax + mov eax,[type] + mov dword[p+8],eax + mov eax,[v] + mov dword[p+12],eax + mov dword[p+16],0.0 + mov dword[p+20],0.0 + mov dword[p+24],0.0 + + mov eax,ebp + sub eax,28 ;=sizeof(dd)*7 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glColorMaterial uses eax, mode:dword, type:dword +locals + p rd 3 +endl + mov dword[p],OP_ColorMaterial + mov eax,[mode] + mov dword[p+4],eax + mov eax,[type] + mov dword[p+8],eax + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glLightfv uses eax ecx, light:dword, type:dword, v:dword +locals + p rd 7 +endl + mov dword[p],OP_Light + mov eax,[light] + mov dword[p+4],eax + mov eax,[type] + mov dword[p+8],eax + + ;TODO: 3 composants ? + mov eax,[v] + mov ecx,[eax] + mov dword[p+12],ecx + mov ecx,[eax+4] + mov dword[p+16],ecx + mov ecx,[eax+8] + mov dword[p+20],ecx + mov ecx,[eax+12] + mov dword[p+24],ecx + + mov eax,ebp + sub eax,28 ;=sizeof(dd)*7 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glLightf uses eax, light:dword, type:dword, v:dword +locals + p rd 7 +endl + mov dword[p],OP_Light + mov eax,[light] + mov dword[p+4],eax + mov eax,[type] + mov dword[p+8],eax + mov eax,[v] + mov dword[p+12],eax + mov dword[p+16],0.0 + mov dword[p+20],0.0 + mov dword[p+24],0.0 + + mov eax,ebp + sub eax,28 ;=sizeof(dd)*7 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glLightModeli uses eax, pname:dword, param:dword +locals + p rd 6 +endl + mov dword[p],OP_LightModel + mov eax,[pname] + mov dword[p+4],eax + fild dword[param] + fstp dword[p+8] ;преобразовали int во float + + mov dword[p+12],0.0 + mov dword[p+16],0.0 + mov dword[p+20],0.0 + + mov eax,ebp + sub eax,24 ;=sizeof(dd)*6 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glLightModelfv uses eax ecx, pname:dword, param:dword +locals + p rd 6 +endl + mov dword[p],OP_LightModel + mov eax,[pname] + mov dword[p+4],eax + mov eax,[param] + mov ecx,[eax] + mov dword[p+8],ecx + mov ecx,[eax+4] + mov dword[p+12],ecx + mov ecx,[eax+8] + mov dword[p+16],ecx + mov ecx,[eax+12] + mov dword[p+20],ecx + + mov eax,ebp + sub eax,24 ;=sizeof(dd)*6 + stdcall gl_add_op,eax + ret +endp + +;/* clear */ + +align 4 +proc glClear uses eax, mask:dword +locals + p rd 2 +endl + mov dword[p],OP_Clear + mov eax,[mask] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glClearColor uses eax, r:dword, g:dword, b:dword, a:dword +locals + p rd 5 +endl + mov dword[p],OP_ClearColor + mov eax,[b] + mov dword[p+4],eax + mov eax,[g] + mov dword[p+8],eax + mov eax,[r] + mov dword[p+12],eax + mov eax,[a] + mov dword[p+16],eax + + mov eax,ebp + sub eax,20 ;=sizeof(dd)*5 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glClearDepth uses eax, depth:dword +locals + p rd 2 +endl + mov dword[p],OP_ClearDepth + mov eax,[depth] + fld qword[eax] + fstp dword[p+4] + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +;/* textures */ + +align 4 +proc glTexImage2D uses ecx edi esi,\ + target:dword, level:dword, components:dword,\ + width:dword, height:dword, border:dword,\ + format:dword, type:dword, pixels:dword +locals + p rd 10 +endl + mov dword[p],OP_TexImage2D + mov ecx,9 + mov esi,ebp + add esi,8 ;указатель на стек с входными параметрами + mov edi,ebp + sub edi,36 ;указатель на стек с локальным массивом + rep movsd ;копирование в цикле 9-ти входных параметров + + mov ecx,ebp + sub ecx,40 ;=sizeof(dd)*10 + stdcall gl_add_op,ecx + ret +endp + +align 4 +proc glBindTexture uses eax, target:dword, texture:dword +locals + p rd 3 +endl + mov dword[p],OP_BindTexture + mov eax,[target] + mov dword[p+4],eax + mov eax,[texture] + mov dword[p+8],eax + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glTexEnvi uses eax, target:dword, pname:dword, param:dword +locals + p rd 8 +endl + mov dword[p],OP_TexEnv + mov eax,[target] + mov dword[p+4],eax + mov eax,[pname] + mov dword[p+8],eax + mov eax,[param] + mov dword[p+12],eax + mov dword[p+16],0.0 + mov dword[p+20],0.0 + mov dword[p+24],0.0 + mov dword[p+28],0.0 + + mov eax,ebp + sub eax,32 ;=sizeof(dd)*8 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glTexParameteri uses eax, target:dword, pname:dword, param:dword +locals + p rd 8 +endl + mov dword[p],OP_TexParameter + mov eax,[target] + mov dword[p+4],eax + mov eax,[pname] + mov dword[p+8],eax + mov eax,[param] + mov dword[p+12],eax + mov dword[p+16],0.0 + mov dword[p+20],0.0 + mov dword[p+24],0.0 + mov dword[p+28],0.0 + + mov eax,ebp + sub eax,32 ;=sizeof(dd)*8 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glPixelStorei uses eax, pname:dword, param:dword +locals + p rd 3 +endl + mov dword[p],OP_PixelStore + mov eax,[pname] + mov dword[p+4],eax + mov eax,[param] + mov dword[p+8],eax + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +;/* selection */ + +align 4 +proc glInitNames uses eax +locals + p dd ? +endl + mov dword[p],OP_InitNames + + mov eax,ebp + sub eax,4 ;=sizeof(dd)*1 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glPushName uses eax, name:dword +locals + p rd 2 +endl + mov dword[p],OP_PushName + mov eax,[name] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glPopName uses eax +locals + p dd ? +endl + mov dword[p],OP_PopName + + mov eax,ebp + sub eax,4 ;=sizeof(dd)*1 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glLoadName uses eax, name:dword +locals + p rd 2 +endl + mov dword[p],OP_LoadName + mov eax,[name] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glPolygonOffset uses eax, factor:dword, units:dword +locals + p rd 3 +endl + mov dword[p],OP_PolygonOffset + mov eax,[factor] + mov dword[p+4],eax + mov eax,[units] + mov dword[p+8],eax + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +;/* Special Functions */ + +align 4 +proc glCallList uses eax, list:dword +locals + p rd 2 +endl + mov dword[p],OP_CallList + mov eax,[list] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glFlush ;(void) + ;nothing to do + ret +endp + +align 4 +proc glHint uses eax, target:dword, mode:dword +locals + p rd 3 +endl + mov dword[p],OP_Hint + mov eax,[target] + mov dword[p+4],eax + mov eax,[mode] + mov dword[p+8],eax + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +; Non standard functions + +align 4 +proc glDebug uses eax, mode:dword + stdcall gl_get_context ;после вызова функции в eax указатель на GLContext + push dword[mode] + pop dword[eax+offs_cont_print_flag] + ret +endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/arrays.asm b/programs/develop/libraries/TinyGL/asm_fork/arrays.asm new file mode 100644 index 0000000000..3fe4e5e03d --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/arrays.asm @@ -0,0 +1,360 @@ +VERTEX_ARRAY equ 0x0001 +COLOR_ARRAY equ 0x0002 +NORMAL_ARRAY equ 0x0004 +TEXCOORD_ARRAY equ 0x0008 + +align 4 +proc glopArrayElement uses eax ebx ecx edx, context:dword, param:dword +locals + p rd 5 +endl + mov eax,[context] + mov ebx,[param] + mov ebx,[ebx+4] ;ebx = p[1] + + bt dword[eax+offs_cont_client_states],1 ;2^1=COLOR_ARRAY + jnc @f + mov ecx,[eax+offs_cont_color_array_size] + add ecx,[eax+offs_cont_color_array_stride] + imul ecx,ebx + shl ecx,2 + add ecx,eax + add ecx,offs_cont_color_array ;ecx = &context.color_array[i] + mov ebx,ebp + sub ebx,20 ;=sizeof(dd)*5 + mov edx,[ecx] + mov [ebx+4],edx + mov edx,[ecx+4] + mov [ebx+8],edx + mov edx,[ecx+8] + mov [ebx+12],edx + cmp dword[eax+offs_cont_color_array_size],3 + jg .l0 + mov edx,1.0 + jmp .l1 + .l0: + mov edx,[ecx+12] + .l1: + mov [ebx+16],edx + stdcall glopColor, eax, ebx + @@: + bt dword[eax+offs_cont_client_states],2 ;2^2=NORMAL_ARRAY + jnc @f + mov esi,dword[eax+offs_cont_normal_array_stride] + add esi,3 + imul esi,ebx + shl esi,2 + add esi,eax + add esi,offs_cont_normal_array ;esi = &normal_array[ebx * (3 + c->normal_array_stride)] + mov edi,eax + add edi,offs_cont_current_normal + mov ecx,3 + rep movsd + mov dword[edi],0.0 + @@: + bt dword[eax+offs_cont_client_states],3 ;2^3=TEXCOORD_ARRAY + jnc @f + mov ecx,[eax+offs_cont_texcoord_array_size] + add ecx,[eax+offs_cont_texcoord_array_stride] + imul ecx,ebx + shl ecx,2 + add ecx,eax + add ecx,offs_cont_texcoord_array ;ecx = &context.texcoord_array[i] + mov edx,[ecx] + mov [eax+offs_cont_current_tex_coord],edx + mov edx,[ecx+4] + mov [eax+offs_cont_current_tex_coord+4],edx + + cmp dword[eax+offs_cont_texcoord_array_size],2 + jg .l2 + mov edx,0.0 + jmp .l3 + .l2: + mov edx,[ecx+8] + .l3: + mov [eax+offs_cont_current_tex_coord+8],edx + + cmp dword[eax+offs_cont_texcoord_array_size],3 + jg .l4 + mov edx,1.0 + jmp .l5 + .l4: + mov edx,[ecx+12] + .l5: + + mov [eax+offs_cont_current_tex_coord+12],edx + @@: + bt dword[eax+offs_cont_client_states],0 ;2^0=VERTEX_ARRAY + jnc @f + mov ecx,[eax+offs_cont_vertex_array_size] + add ecx,[eax+offs_cont_vertex_array_stride] + imul ecx,ebx + shl ecx,2 + add ecx,eax + add ecx,offs_cont_vertex_array ;ecx = &context.vertex_array[i] + mov ebx,ebp + sub ebx,20 ;=sizeof(dd)*5 + mov edx,[ecx] + mov [ebx+4],edx + mov edx,[ecx+4] + mov [ebx+8],edx + + cmp dword[eax+offs_cont_vertex_array_size],2 + jg .l6 + mov edx,0.0 + jmp .l7 + .l6: + mov edx,[ecx+8] + .l7: + mov [ebx+12],edx + + cmp dword[eax+offs_cont_vertex_array_size],3 + jg .l8 + mov edx,1.0 + jmp .l9 + .l8: + mov edx,[ecx+12] + .l9: + + mov [ebx+16],edx + stdcall glopVertex, eax, ebx + @@: + ret +endp + +align 4 +proc glArrayElement uses eax, i:dword +locals + p rd 2 +endl + mov dword[p],OP_ArrayElement + mov eax,[i] + mov dword[p+4],eax + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glopEnableClientState uses eax ebx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ebx,[ebx+4] ;ebx = p[1] + or dword[eax+offs_cont_client_states],ebx + ret +endp + +align 4 +proc glEnableClientState uses eax, array:dword +locals + p rd 2 +endl + mov dword[p],OP_EnableClientState + + cmp dword[array],GL_VERTEX_ARRAY + jne @f + mov dword[p+4],VERTEX_ARRAY + jmp .end_f + @@: + cmp dword[array],GL_NORMAL_ARRAY + jne @f + mov dword[p+4],NORMAL_ARRAY + jmp .end_f + @@: + cmp dword[array],GL_COLOR_ARRAY + jne @f + mov dword[p+4],COLOR_ARRAY + jmp .end_f + @@: + cmp dword[array],GL_TEXTURE_COORD_ARRAY + jne @f + mov dword[p+4],TEXCOORD_ARRAY + jmp .end_f + @@: + ;assert(0); + .end_f: + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glopDisableClientState uses eax ebx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ebx,[ebx+4] ;ebx = p[1] + and dword[eax+offs_cont_client_states],ebx + ret +endp + +align 4 +proc glDisableClientState uses eax, array:dword +locals + p rd 2 +endl + mov dword[p],OP_DisableClientState + + cmp dword[array],GL_VERTEX_ARRAY + jne @f + mov dword[p+4], not VERTEX_ARRAY + jmp .end_f + @@: + cmp dword[array],GL_NORMAL_ARRAY + jne @f + mov dword[p+4], not NORMAL_ARRAY + jmp .end_f + @@: + cmp dword[array],GL_COLOR_ARRAY + jne @f + mov dword[p+4], not COLOR_ARRAY + jmp .end_f + @@: + cmp dword[array],GL_TEXTURE_COORD_ARRAY + jne @f + mov dword[p+4], not TEXCOORD_ARRAY + jmp .end_f + @@: + ;assert(0); + .end_f: + + mov eax,ebp + sub eax,8 ;=sizeof(dd)*2 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glopVertexPointer uses eax ebx ecx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ecx,[ebx+4] ;ecx = p[1] + mov dword[eax+offs_cont_vertex_array_size],ecx + mov ecx,[ebx+8] ;ecx = p[2] + mov dword[eax+offs_cont_vertex_array_stride],ecx + mov ecx,[ebx+12] ;ecx = p[3] + mov dword[eax+offs_cont_vertex_array],ecx + ret +endp + +align 4 +proc glVertexPointer uses eax, size:dword, type:dword, stride:dword, pointer:dword +locals + p rd 4 +endl +; assert(type == GL_FLOAT); + + mov dword[p],OP_TexCoordPointer + mov eax,[size] + mov dword[p+4],eax + mov eax,[stride] + mov dword[p+8],eax + mov eax,[pointer] + mov dword[p+12],eax + + mov eax,ebp + sub eax,16 ;=sizeof(dd)*4 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glopColorPointer uses eax ebx ecx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ecx,[ebx+4] ;ecx = p[1] + mov dword[eax+offs_cont_color_array_size],ecx + mov ecx,[ebx+8] ;ecx = p[2] + mov dword[eax+offs_cont_color_array_stride],ecx + mov ecx,[ebx+12] ;ecx = p[3] + mov dword[eax+offs_cont_color_array],ecx + ret +endp + +align 4 +proc glColorPointer uses eax, size:dword, type:dword, stride:dword, pointer:dword +locals + p rd 4 +endl +; assert(type == GL_FLOAT); + + mov dword[p],OP_ColorPointer + mov eax,[size] + mov dword[p+4],eax + mov eax,[stride] + mov dword[p+8],eax + mov eax,[pointer] + mov dword[p+12],eax + + mov eax,ebp + sub eax,16 ;=sizeof(dd)*4 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glopNormalPointer uses eax ebx ecx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ecx,[ebx+4] ;ecx = p[1] + mov dword[eax+offs_cont_normal_array_stride],ecx + mov ecx,[ebx+8] ;ecx = p[2] + mov dword[eax+offs_cont_normal_array],ecx + ret +endp + +align 4 +proc glNormalPointer uses eax, type:dword, stride:dword, pointer:dword +locals + p rd 3 +endl +; assert(type == GL_FLOAT); + + mov dword[p],OP_NormalPointer + mov eax,[stride] + mov dword[p+4],eax + mov eax,[pointer] + mov dword[p+8],eax + + mov eax,ebp + sub eax,12 ;=sizeof(dd)*3 + stdcall gl_add_op,eax + ret +endp + +align 4 +proc glopTexCoordPointer uses eax ebx ecx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ecx,[ebx+4] ;ecx = p[1] + mov dword[eax+offs_cont_texcoord_array_size],ecx + mov ecx,[ebx+8] ;ecx = p[2] + mov dword[eax+offs_cont_texcoord_array_stride],ecx + mov ecx,[ebx+12] ;ecx = p[3] + mov dword[eax+offs_cont_texcoord_array],ecx + ret +endp + +align 4 +proc glTexCoordPointer uses eax, size:dword, type:dword, stride:dword, pointer:dword +locals + p rd 4 +endl +; assert(type == GL_FLOAT); + + mov dword[p],OP_TexCoordPointer + mov eax,[size] + mov dword[p+4],eax + mov eax,[stride] + mov dword[p+8],eax + mov eax,[pointer] + mov dword[p+12],eax + + mov eax,ebp + sub eax,16 ;=sizeof(dd)*4 + stdcall gl_add_op,eax + ret +endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/build.bat b/programs/develop/libraries/TinyGL/asm_fork/build.bat new file mode 100644 index 0000000000..4682f16368 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/build.bat @@ -0,0 +1,4 @@ +if not exist bin mkdir bin +@fasm.exe -m 16384 tinygl.asm bin\tinygl.obj +@kpack bin\tinygl.obj +pause \ No newline at end of file diff --git a/programs/develop/libraries/TinyGL/asm_fork/clear.asm b/programs/develop/libraries/TinyGL/asm_fork/clear.asm new file mode 100644 index 0000000000..697a0da68e --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/clear.asm @@ -0,0 +1,34 @@ + +align 4 +proc glopClearColor uses ecx esi edi, context:dword, p:dword + mov esi,[p] + add esi,4 + mov edi,[context] + add edi,offs_cont_clear_color + mov ecx,4 + rep movsd +endp + +align 4 +proc glopClearDepth uses eax ebx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ebx,[ebx+4] ;ebx = p[1] + mov dword[eax+offs_cont_clear_depth],ebx + ret +endp + +;void glopClear(GLContext *c,GLParam *p) +;{ +; int mask=p[1].i; +; int z=0; +; int r=(int)(c->clear_color.v[0]*65535); +; int g=(int)(c->clear_color.v[1]*65535); +; int b=(int)(c->clear_color.v[2]*65535); +; +; /* TODO : correct value of Z */ +; +; ZB_clear(c->zb,mask & GL_DEPTH_BUFFER_BIT,z, +; mask & GL_COLOR_BUFFER_BIT,r,g,b); +;} + diff --git a/programs/develop/libraries/TinyGL/asm_fork/clip.asm b/programs/develop/libraries/TinyGL/asm_fork/clip.asm new file mode 100644 index 0000000000..5ce45361ec --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/clip.asm @@ -0,0 +1,923 @@ +; fill triangle profile +; #define PROFILE + +CLIP_XMIN equ (1<<0) +CLIP_XMAX equ (1<<1) +CLIP_YMIN equ (1<<2) +CLIP_YMAX equ (1<<3) +CLIP_ZMIN equ (1<<4) +CLIP_ZMAX equ (1<<5) + +offs_X equ 0 +offs_Y equ 4 +offs_Z equ 8 +offs_W equ 12 + +align 4 +proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword +locals + point dd ? +endl + mov eax,[context] + mov ebx,[v] + + ; coordinates + fld1 + fdiv dword[ebx+offs_vert_pc+offs_W] ;st0 = 1/v.pc.W + + fld dword[ebx+offs_vert_pc+offs_X] ;st0 = v.pc.X + fmul st0,st1 + fmul dword[eax+offs_cont_viewport+offs_vpor_scale+offs_X] + fadd dword[eax+offs_cont_viewport+offs_vpor_trans+offs_X] + fistp dword[ebx+offs_vert_zp] ;v.zp.x = st0, st0 = st1 + + fld dword[ebx+offs_vert_pc+offs_Y] ;st0 = v.pc.Y + fmul st0,st1 + fmul dword[eax+offs_cont_viewport+offs_vpor_scale+offs_Y] + fadd dword[eax+offs_cont_viewport+offs_vpor_trans+offs_Y] + fistp dword[ebx+offs_vert_zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1 + + fld dword[ebx+offs_vert_pc+offs_Z] ;st0 = v.pc.Z + fmul st0,st1 + fmul dword[eax+offs_cont_viewport+offs_vpor_scale+offs_Z] + fadd dword[eax+offs_cont_viewport+offs_vpor_trans+offs_Z] + fistp dword[ebx+offs_vert_zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1 + + ; color + bt dword[eax+offs_cont_lighting_enabled],0 + jnc @f + mov ecx,ebx + add ecx,offs_vert_zp+offs_zbup_b + push ecx + add ecx,offs_zbup_g-offs_zbup_b + push ecx + add ecx,offs_zbup_r-offs_zbup_g + push ecx + stdcall RGBFtoRGBI, dword[ebx+offs_vert_color],dword[ebx+offs_vert_color+4],dword[ebx+offs_vert_color+8] + jmp .end_if + @@: + ; no need to convert to integer if no lighting : take current color + push ecx + mov ecx,[eax+offs_cont_longcurrent_color] + mov dword[ebx+offs_vert_zp+offs_zbup_r],ecx + mov ecx,[eax+offs_cont_longcurrent_color+4] + mov dword[ebx+offs_vert_zp+offs_zbup_g],ecx + mov ecx,[eax+offs_cont_longcurrent_color+8] + mov dword[ebx+offs_vert_zp+offs_zbup_b],ecx + pop ecx + .end_if: + + ; texture + bt dword[eax+offs_cont_texture_2d_enabled],0 + jnc @f + mov dword[point],dword(ZB_POINT_S_MAX - ZB_POINT_S_MIN) + fild dword[point] + fmul dword[ebx+offs_vert_tex_coord] ;st0 *= v.tex_coord.X + fistp dword[ebx+offs_vert_zp+offs_zbup_s] + add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_S_MIN + + mov dword[point],dword(ZB_POINT_T_MAX - ZB_POINT_T_MIN) + fild dword[point] + fmul dword[ebx+offs_vert_tex_coord+4] ;st0 *= v.tex_coord.Y + fistp dword[ebx+offs_vert_zp+offs_zbup_t] + add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_T_MIN + @@: +if DEBUG ;gl_transform_to_viewport +push edi + mov ecx,80 + mov eax,[ebx+offs_vert_zp] + lea edi,[buf_param] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[ebx+offs_vert_zp+offs_zbup_y] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[ebx+offs_vert_zp+offs_zbup_z] + stdcall convert_int_to_str,ecx + + stdcall str_n_cat,edi,txt_nl,2 + stdcall dbg_print,f_ttv,buf_param +pop edi +end if + ret +endp + +align 4 +proc gl_add_select1 uses eax ebx ecx, context:dword, z1:dword,z2:dword,z3:dword + mov eax,[z1] + mov ebx,eax + cmp [z2],eax + jge @f + mov eax,[z2] + @@: + cmp [z3],eax + jge @f + mov eax,[z3] + @@: + cmp [z2],ebx + jle @f + mov ebx,[z2] + @@: + cmp [z3],ebx + jle @f + mov ebx,[z3] + @@: + mov ecx,0xffffffff + sub ecx,ebx + push ecx + mov ecx,0xffffffff + sub ecx,eax + push ecx + stdcall gl_add_select, [context] ;,0xffffffff-eax,0xffffffff-ebx + ret +endp + +; point + +align 4 +proc gl_draw_point uses eax ebx, context:dword, p0:dword + mov ebx,[p0] + cmp dword[ebx+offs_vert_clip_code],0 ;if (p0.clip_code == 0) + jne @f + mov eax,[context] + cmp dword[eax+offs_cont_render_mode],GL_SELECT + jne .els + stdcall gl_add_select, eax,dword[ebx+offs_vert_zp+offs_zbup_z],dword[ebx+offs_vert_zp+offs_zbup_z] ;p0.zp.z,p0.zp.z + jmp @f + .els: + add ebx,offs_vert_zp + stdcall ZB_plot, dword[eax+offs_cont_zb],ebx + @@: + ret +endp + +; line + +align 4 +proc interpolate uses eax ebx ecx, q:dword,p0:dword,p1:dword,t:dword + mov eax,[q] + mov ebx,[p0] + mov ecx,[p1] + fld dword[t] + + ; интерполяция по координатам + fld dword[ecx+offs_vert_pc] + fsub dword[ebx+offs_vert_pc] + fmul st0,st1 + fadd dword[ebx+offs_vert_pc] + fstp dword[eax+offs_vert_pc] + + fld dword[ecx+offs_vert_pc+4] + fsub dword[ebx+offs_vert_pc+4] + fmul st0,st1 + fadd dword[ebx+offs_vert_pc+4] + fstp dword[eax+offs_vert_pc+4] + + fld dword[ecx+offs_vert_pc+8] + fsub dword[ebx+offs_vert_pc+8] + fmul st0,st1 + fadd dword[ebx+offs_vert_pc+8] + fstp dword[eax+offs_vert_pc+8] + + fld dword[ecx+offs_vert_pc+12] + fsub dword[ebx+offs_vert_pc+12] + fmul st0,st1 + fadd dword[ebx+offs_vert_pc+12] + fstp dword[eax+offs_vert_pc+12] + + ; интерполяция по цвету + fld dword[ecx+offs_vert_color] + fsub dword[ebx+offs_vert_color] + fmul st0,st1 + fadd dword[ebx+offs_vert_color] + fstp dword[eax+offs_vert_color] + + fld dword[ecx+offs_vert_color+4] + fsub dword[ebx+offs_vert_color+4] + fmul st0,st1 + fadd dword[ebx+offs_vert_color+4] + fstp dword[eax+offs_vert_color+4] + + fld dword[ecx+offs_vert_color+8] + fsub dword[ebx+offs_vert_color+8] + fmul st0,st1 + fadd dword[ebx+offs_vert_color+8] + fstp dword[eax+offs_vert_color+8] + ret +endp + +; +; Line Clipping +; + +; Line Clipping algorithm from 'Computer Graphics', Principles and +; Practice +; tmin,tmax -> &float +align 4 +proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword + fldz + fcom dword[denom] + fstsw ax + sahf + je .u2 + jmp @f + .u2: + fcom dword[num] + fstsw ax + sahf + jb .r0 ;if (denom==0 && num>0) return 0 + jmp .r1 + @@: + + fcom dword[denom] + fstsw ax + sahf + ja .els_0 ;if (0*tmax) return 0 + + mov ebx,[tmin] + fcom dword[ebx] + fstsw ax + sahf + jbe .r1 + fstp dword[ebx] ;if (t>*tmin) *tmin=t + jmp .r1 + + .els_0: ;else if (0>denom) + fld dword[num] + fdiv dword[denom] + + mov ebx,[tmin] + fcom dword[ebx] + fstsw ax + sahf + jb .r0 ;if (t<*tmin) return 0 + + mov ebx,[tmax] + fcom dword[ebx] + fstsw ax + sahf + jae .r1 + fstp dword[ebx] ;if (t<*tmin) *tmax=t + jmp .r1 + + .r0: ;return 0 + xor eax,eax + jmp .end_f + .r1: ;return 1 + xor eax,eax + inc eax + .end_f: +if DEBUG ;ClipLine1 +push edi + mov ecx,80 + lea edi,[buf_param] + stdcall convert_int_to_str,ecx + + stdcall str_n_cat,edi,txt_nl,2 + stdcall dbg_print,f_cl1,buf_param +pop edi +end if + ffree st0 ;профилактика для очистки стека + fincstp ;как минимум одно значение в стеке уже есть + ret +endp + +align 4 +proc gl_draw_line uses eax ebx edx edi esi, context:dword, p1:dword, p2:dword +locals + d_x dd ? + d_y dd ? + d_z dd ? + d_w dd ? + x1 dd ? + y1 dd ? + z1 dd ? + w1 dd ? + q1 GLVertex ? + q2 GLVertex ? + tmin dd ? ;ebp-8 + tmax dd ? ;ebp-4 +endl + + mov edx,[context] + mov edi,[p1] + mov esi,[p2] + +if DEBUG + jmp @f + f_1 db ' gl_draw_line',0 + @@: + stdcall dbg_print,f_1,m_1 +end if + cmp dword[edi+offs_vert_clip_code],0 + jne .els_i + cmp dword[esi+offs_vert_clip_code],0 + jne .els_i + ;if ( (p1.clip_code | p2.clip_code) == 0) + cmp dword[edx+offs_cont_render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT) + jne .els_1 + stdcall gl_add_select1, edx,dword[edi+offs_vert_zp+offs_zbup_z],\ + dword[esi+offs_vert_zp+offs_zbup_z],dword[esi+offs_vert_zp+offs_zbup_z] + jmp .end_f + .els_1: + add edi,offs_vert_zp + add esi,offs_vert_zp + push esi + push edi + push dword[edx+offs_cont_zb] + cmp dword[edx+offs_cont_depth_test],0 + je .els_2 + ;if (context.depth_test) + call ZB_line_z ;, dword[edx+offs_cont_zb],edi,esi + jmp .end_f + .els_2: + call ZB_line ;, dword[edx+offs_cont_zb],edi,esi + jmp .end_f + .els_i: + ;else if ( (p1.clip_code & p2.clip_code) != 0 ) + mov eax,[edi+offs_vert_clip_code] + and eax,[esi+offs_vert_clip_code] + cmp eax,0 + jne .end_f + .els_0: +if DEBUG + stdcall dbg_print,f_1,m_2 +end if + + finit + fld dword[esi+offs_vert_pc+offs_X] + fsub dword[edi+offs_vert_pc+offs_X] + fstp dword[d_x] ;d_x = p2.pc.X - p1.pc.X + fld dword[esi+offs_vert_pc+offs_Y] + fsub dword[edi+offs_vert_pc+offs_Y] + fstp dword[d_y] ;d_y = p2.pc.Y - p1.pc.Y + fld dword[esi+offs_vert_pc+offs_Z] + fsub dword[edi+offs_vert_pc+offs_Z] + fstp dword[d_z] ;d_z = p2.pc.Z - p1.pc.Z + fld dword[esi+offs_vert_pc+offs_W] + fsub dword[edi+offs_vert_pc+offs_W] + fstp dword[d_w] ;d_w = p2.pc.W - p1.pc.W + + mov eax,[edi+offs_vert_pc+offs_X] + mov [x1],eax ;x1 = p1.pc.X + mov eax,[edi+offs_vert_pc+offs_Y] + mov [y1],eax ;y1 = p1.pc.Y + mov eax,[edi+offs_vert_pc+offs_Z] + mov [z1],eax ;z1 = p1.pc.Z + mov eax,[edi+offs_vert_pc+offs_W] + mov [w1],eax ;w1 = p1.pc.W + + mov dword[tmin],0.0 + mov dword[tmax],1.0 + + mov eax,ebp + sub eax,4 + push eax ;толкаем в стек адрес &tmax + sub eax,4 + push eax ;толкаем в стек адрес &tmin + fld dword[x1] + fadd dword[w1] + fchs + fstp dword[esp-4] + fld dword[d_x] + fadd dword[d_w] + fstp dword[esp-8] + sub esp,8 + call ClipLine1 ;d_x+d_w,-x1-w1,&tmin,&tmax + bt eax,0 + jnc .end_f + + sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax + fld dword[x1] + fsub dword[w1] + fstp dword[esp-4] + fld dword[d_w] + fsub dword[d_x] + fstp dword[esp-8] + sub esp,8 + call ClipLine1 ;-d_x+d_w,x1-w1,&tmin,&tmax + bt eax,0 + jnc .end_f + + sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax + fld dword[y1] + fadd dword[w1] + fchs + fstp dword[esp-4] + fld dword[d_y] + fadd dword[d_w] + fstp dword[esp-8] + sub esp,8 + call ClipLine1 ;d_y+d_w,-y1-w1,&tmin,&tmax + bt eax,0 + jnc .end_f + + sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax + fld dword[y1] + fsub dword[w1] + fstp dword[esp-4] + fld dword[d_w] + fsub dword[d_y] + fstp dword[esp-8] + sub esp,8 + call ClipLine1 ;-d_y+d_w,y1-w1,&tmin,&tmax + bt eax,0 + jnc .end_f + + sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax + fld dword[z1] + fadd dword[w1] + fchs + fstp dword[esp-4] + fld dword[d_z] + fadd dword[d_w] + fstp dword[esp-8] + sub esp,8 + call ClipLine1 ;d_z+d_w,-z1-w1,&tmin,&tmax + bt eax,0 + jnc .end_f + + sub esp,8 ;толкаем в стек адреса переменных &tmin и &tmax + fld dword[z1] + fsub dword[w1] + fstp dword[esp-4] + fld dword[d_w] + fsub dword[d_z] + fstp dword[esp-8] + sub esp,8 + call ClipLine1 ;-d_z+d_w,z1-w1,&tmin,&tmax + bt eax,0 + jnc .end_f + + mov eax,ebp + sub eax,8+2*sizeof.GLVertex ;eax = &q1 + stdcall interpolate, eax,edi,esi,[tmin] + stdcall gl_transform_to_viewport, edx,eax + add eax,sizeof.GLVertex ;eax = &q2 + stdcall interpolate, eax,edi,esi,[tmax] + stdcall gl_transform_to_viewport, edx,eax + + sub eax,sizeof.GLVertex ;eax = &q1 + mov ebx,eax + add ebx,offs_vert_zp+offs_zbup_b + push ebx + add ebx,offs_zbup_g-offs_zbup_b + push ebx + add ebx,offs_zbup_r-offs_zbup_g + push ebx + stdcall RGBFtoRGBI, dword[eax+offs_vert_color],dword[eax+offs_vert_color+4],dword[eax+offs_vert_color+8] + + add eax,sizeof.GLVertex ;eax = &q2 + mov ebx,eax + add ebx,offs_vert_zp+offs_zbup_b + push ebx + add ebx,offs_zbup_g-offs_zbup_b + push ebx + add ebx,offs_zbup_r-offs_zbup_g + push ebx + stdcall RGBFtoRGBI, dword[eax+offs_vert_color],dword[eax+offs_vert_color+4],dword[eax+offs_vert_color+8] + + add eax,offs_vert_zp ;eax = &q2.zp + push eax + sub eax,sizeof.GLVertex ;eax = &q1.zp + push eax + push dword[edx+offs_cont_zb] + cmp dword[edx+offs_cont_depth_test],0 + je .els_3 + call ZB_line_z ;(context.zb,&q1.zp,&q2.zp) + jmp .end_f + .els_3: + call ZB_line ;(context.zb,&q1.zp,&q2.zp) + .end_f: + ret +endp + +; triangle + +; +; Clipping +; + +; We clip the segment [a,b] against the 6 planes of the normal volume. +; We compute the point 'c' of intersection and the value of the parameter 't' +; of the intersection if x=a+t(b-a). +; +; sign: 0 -> '-', 1 -> '+' +macro clip_func sign,dir,dir1,dir2 +{ +locals + t dd ? + d_X dd ? + d_Y dd ? + d_Z dd ? + d_W dd ? +endl + mov edx,[a] + mov ebx,[b] + mov ecx,[c] + fld dword[ebx] + fsub dword[edx] + fstp dword[d_X] ;d_X = (b.X - a.X) + fld dword[ebx+4] + fsub dword[edx+4] + fstp dword[d_Y] ;d_Y = (b.Y - a.Y) + fld dword[ebx+8] + fsub dword[edx+8] + fstp dword[d_Z] ;d_Z = (b.Z - a.Z) + fld dword[ebx+12] + fsub dword[edx+12] + fst dword[d_W] ;d_W = (b.W - a.W) +if sign eq 0 + fadd dword[d#dir] +else + fsub dword[d#dir] +end if + + fldz + fcomp st1 + fstsw ax + sahf + ja @f + fincstp + fst dword[t] ;t=0 + jmp .e_zero + @@: ;else + fincstp + fld dword[edx+offs#dir] +if sign eq 0 + fchs +end if + fsub dword[edx+offs_W] + fdiv st0,st1 + fst dword[t] ;t = ( sign a.dir - a.W) / den + .e_zero: + + fmul dword[d#dir1] ;st0 = t * d.dir1 + fadd dword[edx+offs#dir1] + fstp dword[ecx+offs#dir1] ;c.dir1 = a.dir1 + t * d.dir1 + + fld dword[t] + fmul dword[d#dir2] ;st0 = t * d.dir2 + fadd dword[edx+offs#dir2] + fstp dword[ecx+offs#dir2] ;c.dir2 = a.dir2 + t * d.dir2 + + fld dword[t] + fmul dword[d_W] + fadd dword[edx+offs_W] + fst dword[ecx+offs_W] ;c.W = a.W + t * d_W + +if sign eq 0 + fchs +end if + fstp dword[ecx+offs#dir] ;c.dir = sign c.W + mov eax,[t] +} + +align 4 +proc clip_xmin uses ebx ecx edx, c:dword, a:dword, b:dword + clip_func 0,_X,_Y,_Z + ret +endp + +align 4 +proc clip_xmax uses ebx ecx edx, c:dword, a:dword, b:dword + clip_func 1,_X,_Y,_Z + ret +endp + +align 4 +proc clip_ymin uses ebx ecx edx, c:dword, a:dword, b:dword + clip_func 0,_Y,_X,_Z + ret +endp + +align 4 +proc clip_ymax uses ebx ecx edx, c:dword, a:dword, b:dword + clip_func 1,_Y,_X,_Z + ret +endp + +align 4 +proc clip_zmin uses ebx ecx edx, c:dword, a:dword, b:dword + clip_func 0,_Z,_X,_Y + ret +endp + +align 4 +proc clip_zmax uses ebx ecx edx, c:dword, a:dword, b:dword + clip_func 1,_Z,_X,_Y + ret +endp + +align 4 +clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax + +;static inline void updateTmp(GLContext *c, GLVertex *q,GLVertex *p0,GLVertex *p1,float t) +;{ +; if (c->current_shade_model == GL_SMOOTH) { +; q->color.v[0]=p0->color.v[0] + (p1->color.v[0]-p0->color.v[0])*t; +; q->color.v[1]=p0->color.v[1] + (p1->color.v[1]-p0->color.v[1])*t; +; q->color.v[2]=p0->color.v[2] + (p1->color.v[2]-p0->color.v[2])*t; +; } else { +; q->color.v[0]=p0->color.v[0]; +; q->color.v[1]=p0->color.v[1]; +; q->color.v[2]=p0->color.v[2]; +; } + +; if (c->texture_2d_enabled) { +; q->tex_coord.X=p0->tex_coord.X + (p1->tex_coord.X-p0->tex_coord.X)*t; +; q->tex_coord.Y=p0->tex_coord.Y + (p1->tex_coord.Y-p0->tex_coord.Y)*t; +; } + +; q->clip_code=gl_clipcode(q->pc.X,q->pc.Y,q->pc.Z,q->pc.W); +; if (q->clip_code==0){ +; gl_transform_to_viewport(c,q); +; RGBFtoRGBI(q->color.v[0],q->color.v[1],q->color.v[2],q->zp.r,q->zp.g,q->zp.b); +; } +;} + +;static void gl_draw_triangle_clip(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2,int clip_bit); + +;void gl_draw_triangle(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2) +;{ +; int co,c_and,cc[3],front; +; float norm; +; +; cc[0]=p0->clip_code; +; cc[1]=p1->clip_code; +; cc[2]=p2->clip_code; +; +; co=cc[0] | cc[1] | cc[2]; +; +; /* we handle the non clipped case here to go faster */ +; if (co==0) { +; +; norm=(float)(p1->zp.x-p0->zp.x)*(float)(p2->zp.y-p0->zp.y)- +; (float)(p2->zp.x-p0->zp.x)*(float)(p1->zp.y-p0->zp.y); +; +; if (norm == 0) return; +; +; front = norm < 0.0; +; front = front ^ c->current_front_face; +; +; /* back face culling */ +; if (c->cull_face_enabled) { +; /* most used case first */ +; if (c->current_cull_face == GL_BACK) { +; if (front == 0) return; +; c->draw_triangle_front(c,p0,p1,p2); +; } else if (c->current_cull_face == GL_FRONT) { +; if (front != 0) return; +; c->draw_triangle_back(c,p0,p1,p2); +; } else { +; return; +; } +; } else { +; /* no culling */ +; if (front) { +; c->draw_triangle_front(c,p0,p1,p2); +; } else { +; c->draw_triangle_back(c,p0,p1,p2); +; } +; } +; } else { +; c_and=cc[0] & cc[1] & cc[2]; +; if (c_and==0) { +; gl_draw_triangle_clip(c,p0,p1,p2,0); +; } +; } +;} + +;static void gl_draw_triangle_clip(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2,int clip_bit) +;{ +; int co,c_and,co1,cc[3],edge_flag_tmp,clip_mask; +; GLVertex tmp1,tmp2,*q[3]; +; float tt; + +; cc[0]=p0->clip_code; +; cc[1]=p1->clip_code; +; cc[2]=p2->clip_code; + +; co=cc[0] | cc[1] | cc[2]; +; if (co == 0) { +; gl_draw_triangle(c,p0,p1,p2); +; } else { +; c_and=cc[0] & cc[1] & cc[2]; +; /* the triangle is completely outside */ +; if (c_and!=0) return; + +; /* find the next direction to clip */ +; while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) { +; clip_bit++; +; } + +; /* this test can be true only in case of rounding errors */ +; if (clip_bit == 6) { +;#if 0 +; printf("Error:\n"); +; printf("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W); +; printf("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W); +; printf("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W); +;#endif +; return; +; } + +; clip_mask = 1 << clip_bit; +; co1=(cc[0] ^ cc[1] ^ cc[2]) & clip_mask; + +; if (co1) { +; /* one point outside */ + +; if (cc[0] & clip_mask) { q[0]=p0; q[1]=p1; q[2]=p2; } +; else if (cc[1] & clip_mask) { q[0]=p1; q[1]=p2; q[2]=p0; } +; else { q[0]=p2; q[1]=p0; q[2]=p1; } +; +; tt=clip_proc[clip_bit](&tmp1.pc,&q[0]->pc,&q[1]->pc); +; updateTmp(c,&tmp1,q[0],q[1],tt); +; +; tt=clip_proc[clip_bit](&tmp2.pc,&q[0]->pc,&q[2]->pc); +; updateTmp(c,&tmp2,q[0],q[2],tt); +; +; tmp1.edge_flag=q[0]->edge_flag; +; edge_flag_tmp=q[2]->edge_flag; +; q[2]->edge_flag=0; +; gl_draw_triangle_clip(c,&tmp1,q[1],q[2],clip_bit+1); +; +; tmp2.edge_flag=0; +; tmp1.edge_flag=0; +; q[2]->edge_flag=edge_flag_tmp; +; gl_draw_triangle_clip(c,&tmp2,&tmp1,q[2],clip_bit+1); +; } else { +; /* two points outside */ + +; if ((cc[0] & clip_mask)==0) { q[0]=p0; q[1]=p1; q[2]=p2; } +; else if ((cc[1] & clip_mask)==0) { q[0]=p1; q[1]=p2; q[2]=p0; } +; else { q[0]=p2; q[1]=p0; q[2]=p1; } + +; tt=clip_proc[clip_bit](&tmp1.pc,&q[0]->pc,&q[1]->pc); +; updateTmp(c,&tmp1,q[0],q[1],tt); + +; tt=clip_proc[clip_bit](&tmp2.pc,&q[0]->pc,&q[2]->pc); +; updateTmp(c,&tmp2,q[0],q[2],tt); + +; tmp1.edge_flag=1; +; tmp2.edge_flag=q[2]->edge_flag; +; gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1); +; } +; } +;} + +align 4 +proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword + mov eax,[p2] + push dword[eax+offs_vert_zp+offs_Z] + mov eax,[p1] + push dword[eax+offs_vert_zp+offs_Z] + mov eax,[p0] + push dword[eax+offs_vert_zp+offs_Z] + stdcall gl_add_select1, [context] ;,p0.zp.z, p1.zp.z, p2.zp.z + ret +endp + +;#ifdef PROFILE +;int count_triangles,count_triangles_textured,count_pixels; +;#endif + +align 4 +proc gl_draw_triangle_fill uses eax edx, context:dword, p0:dword,p1:dword,p2:dword +;#ifdef PROFILE +; { +; int norm; +; assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize); +; assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize); +; assert(p1->zp.x >= 0 && p1->zp.x < c->zb->xsize); +; assert(p1->zp.y >= 0 && p1->zp.y < c->zb->ysize); +; assert(p2->zp.x >= 0 && p2->zp.x < c->zb->xsize); +; assert(p2->zp.y >= 0 && p2->zp.y < c->zb->ysize); + +; norm=(p1->zp.x-p0->zp.x)*(p2->zp.y-p0->zp.y)- +; (p2->zp.x-p0->zp.x)*(p1->zp.y-p0->zp.y); +; count_pixels+=abs(norm)/2; +; count_triangles++; +; } +;#endif + + mov edx,[context] + cmp dword[edx+offs_cont_texture_2d_enabled],0 + je .els_i + ;if (context.texture_2d_enabled) +;#ifdef PROFILE +; count_triangles_textured++; +;#endif + mov eax,dword[edx+offs_cont_current_texture] + mov eax,[eax] ;переход по указателю + ;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax] + stdcall ZB_setTexture, dword[edx+offs_cont_zb],dword[eax] +; ZB_fillTriangleMappingPerspective, dword[edx+offs_cont_zb],&p0->zp,&p1->zp,&p2->zp); + jmp .end_f + .els_i: + cmp dword[edx+offs_cont_current_shade_model],GL_SMOOTH + jne .els + ;else if (context.current_shade_model == GL_SMOOTH) +; ZB_fillTriangleSmooth, dword[edx+offs_cont_zb],&p0->zp,&p1->zp,&p2->zp); + jmp .end_f + .els: +; ZB_fillTriangleFlat, dword[edx+offs_cont_zb],&p0->zp,&p1->zp,&p2->zp); + .end_f: + ret +endp + +; Render a clipped triangle in line mode + +align 4 +proc gl_draw_triangle_line uses eax ebx ecx edx, context:dword, p0:dword,p1:dword,p2:dword + mov edx,[context] + cmp dword[edx+offs_cont_depth_test],0 + je .els + lea ecx,[ZB_line_z] + jmp @f + .els: + lea ecx,[ZB_line] + @@: + + ;if (p0.edge_flag) ZB_line_z(context.zb,&p0.zp,&p1.zp) + mov eax,[p0] + cmp dword[eax+offs_vert_edge_flag],0 + je @f + mov ebx,eax + add ebx,offs_vert_zp + mov eax,[p1] + add eax,offs_vert_zp + stdcall ecx,dword[edx+offs_cont_zb],ebx,eax + @@: + ;if (p1.edge_flag) ZB_line_z(context.zb,&p1.zp,&p2.zp) + mov eax,[p1] + cmp dword[eax+offs_vert_edge_flag],0 + je @f + mov ebx,eax + add ebx,offs_vert_zp + mov eax,[p2] + add eax,offs_vert_zp + stdcall ecx,dword[edx+offs_cont_zb],ebx,eax + @@: + ;if (p2.edge_flag) ZB_line_z(context.zb,&p2.zp,&p0.zp); + mov eax,[p2] + cmp dword[eax+offs_vert_edge_flag],0 + je @f + mov ebx,eax + add ebx,offs_vert_zp + mov eax,[p0] + add eax,offs_vert_zp + stdcall ecx,dword[edx+offs_cont_zb],ebx,eax + @@: + + ret +endp + +; Render a clipped triangle in point mode +align 4 +proc gl_draw_triangle_point uses eax ebx edx, context:dword, p0:dword,p1:dword,p2:dword + mov edx,[context] + mov eax,[p0] + cmp dword[eax+offs_vert_edge_flag],0 + je @f + mov ebx,eax + add ebx,offs_vert_zp + stdcall ZB_plot,dword[edx+offs_cont_zb],ebx + @@: + add eax,[p1] + cmp dword[eax+offs_vert_edge_flag],0 + je @f + mov ebx,eax + add ebx,offs_vert_zp + stdcall ZB_plot,dword[edx+offs_cont_zb],ebx + @@: + add eax,[p2] + cmp dword[eax+offs_vert_edge_flag],0 + je @f + mov ebx,eax + add ebx,offs_vert_zp + stdcall ZB_plot,dword[edx+offs_cont_zb],ebx + @@: + ret +endp + + + + diff --git a/programs/develop/libraries/TinyGL/asm_fork/export.inc b/programs/develop/libraries/TinyGL/asm_fork/export.inc new file mode 100644 index 0000000000..09b5e5800f --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/export.inc @@ -0,0 +1,164 @@ +; +; Export functions (103) +; + +E_LIB glEnable ;(int code) +E_LIB glDisable ;(int code) + +E_LIB glShadeModel ;(int mode) +E_LIB glCullFace ;(int mode) +E_LIB glPolygonMode ;(int face,int mode) + +E_LIB glBegin ;(int type) +E_LIB glEnd ;(void) + +E_LIB glVertex2f ;(float ,float) +E_LIB glVertex2d ;(double ,double) +E_LIB glVertex2fv ;(float *) +E_LIB glVertex2dv ;(double *) +E_LIB glVertex3f ;(float ,float ,float) +E_LIB glVertex3d ;(double ,double ,double) +E_LIB glVertex3fv ;(float *) +E_LIB glVertex3dv ;(double *) +E_LIB glVertex4f ;(float ,float ,float, float ) +E_LIB glVertex4d ;(double ,double ,double, double ) +E_LIB glVertex4fv ;(float *) +E_LIB glVertex4dv ;(double *) + +E_LIB glColor3f ;(float ,float ,float) +E_LIB glColor3d ;(double ,double ,double) +E_LIB glColor3fv ;(float *) +E_LIB glColor3dv ;(double *) +E_LIB glColor4f ;(float ,float ,float, float ) +E_LIB glColor4d ;(double ,double ,double, double ) +E_LIB glColor4fv ;(float *) +E_LIB glColor4dv ;(double *) + +E_LIB glNormal3f ;(float ,float ,float) +E_LIB glNormal3d ;(double ,double ,double) +E_LIB glNormal3fv ;(float *) +E_LIB glNormal3dv ;(double *) + +E_LIB glTexCoord1f ;(float) +E_LIB glTexCoord1d ;(double) +E_LIB glTexCoord1fv ;(float *) +E_LIB glTexCoord1dv ;(double *) +E_LIB glTexCoord2f ;(float ,float) +E_LIB glTexCoord2d ;(double ,double) +E_LIB glTexCoord2fv ;(float *) +E_LIB glTexCoord2dv ;(double *) +E_LIB glTexCoord3f ;(float ,float ,float) +E_LIB glTexCoord3d ;(double ,double ,double) +E_LIB glTexCoord3fv ;(float *) +E_LIB glTexCoord3dv ;(double *) +E_LIB glTexCoord4f ;(float ,float ,float, float ) +E_LIB glTexCoord4d ;(double ,double ,double, double ) +E_LIB glTexCoord4fv ;(float *) +E_LIB glTexCoord4dv ;(double *) + +E_LIB glEdgeFlag ;(int flag) + +; matrix +E_LIB glMatrixMode ;(int mode) +E_LIB glLoadMatrixf ;(const float *m) +E_LIB glLoadIdentity ;(void) +E_LIB glMultMatrixf ;(const float *m) +E_LIB glPushMatrix ;(void) +E_LIB glPopMatrix ;(void) +E_LIB glRotatef ;(float angle,float x,float y,float z) +E_LIB glTranslatef ;(float x,float y,float z) +E_LIB glScalef ;(float x,float y,float z) + +E_LIB glViewport ;(int x,int y,int width,int height) +E_LIB glFrustum ;(double left,double right,double bottom,double top, double near_,double far_); + +; lists +E_LIB glGenLists ;(int range) +E_LIB glIsList ;(unsigned int list) +E_LIB glNewList ;(unsigned int list,int mode) +E_LIB glEndList ;(void) +E_LIB glCallList ;(unsigned int list) + +; clear +E_LIB glClear ;(int mask) +E_LIB glClearColor ;(float r,float g,float b,float a) +E_LIB glClearDepth ;(double depth) + +; selection +E_LIB glRenderMode ;(int mode) +E_LIB glSelectBuffer ;(int size,unsigned int *buf) + +E_LIB glInitNames ;(void) +E_LIB glPushName ;(unsigned int name) +E_LIB glPopName ;(void) +E_LIB glLoadName ;(unsigned int name) + +; textures +E_LIB glGenTextures ;(int n, unsigned int *textures) +E_LIB glDeleteTextures ;(int n, const unsigned int *textures) +E_LIB glBindTexture ;(int target,int texture) +E_LIB glTexImage2D ;( int target, int level, int components, int width, int height, int border, int format, int type, void *pixels) +E_LIB glTexEnvi ;(int target,int pname,int param) +E_LIB glTexParameteri ;(int target,int pname,int param) +E_LIB glPixelStorei ;(int pname,int param) + +; lighting +E_LIB glMaterialfv ;(int mode,int type,float *v) +E_LIB glMaterialf ;(int mode,int type,float v) +E_LIB glColorMaterial ;(int mode,int type) + +E_LIB glLightfv ;(int light,int type,float *v) +E_LIB glLightf ;(int light,int type,float v) +E_LIB glLightModeli ;(int pname,int param) +E_LIB glLightModelfv ;(int pname,float *param) + +; misc +E_LIB glFlush ;(void) +E_LIB glHint ;(int target,int mode) +E_LIB glGetIntegerv ;(int pname,int *params) +E_LIB glGetFloatv ;(int pname, float *v) +E_LIB glFrontFace ;(int mode) + +; opengl 1.2 arrays +E_LIB glEnableClientState ;(GLenum array) +E_LIB glDisableClientState ;(GLenum array) +E_LIB glArrayElement ;(GLint i) +E_LIB glVertexPointer ;(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +E_LIB glColorPointer ;(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +E_LIB glNormalPointer ;(GLenum type, GLsizei stride, const GLvoid *pointer) +E_LIB glTexCoordPointer ;(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) + +; opengl 1.2 polygon offset +E_LIB glPolygonOffset ;(GLfloat factor, GLfloat units) + +; not implemented, just added to compile +;inline void glPointSize(float) {} +;inline void glLineWidth(float) {} +;inline void glDeleteLists(int, int) {} +;inline void glDepthFunc(int) {} +;inline void glBlendFunc(int, int) {} +;inline void glTexEnvf(int, int, int) {} +;inline void glOrtho(float,float,float,float,float,float){} +;inline void glVertex2i(int,int) {} +;inline void glDepthMask(int) {} +;inline void glFogi(int, int) {} +;inline void glFogfv(int, const float*) {} +;inline void glFogf(int, float) {} +;inline void glRasterPos2f(float, float) {} +;inline void glPolygonStipple(void*) {} +;inline void glTexParameterf(int, int, int) {}; +; non compatible functions + +E_LIB glDebug ;(int mode) + +E_LIB glInit ;(void *zbuffer) +E_LIB glClose ;(void) + +; +; Kolibri OS functions +; + +E_LIB kosglMakeCurrent +E_LIB kosglSwapBuffers + +purge E_LIB diff --git a/programs/develop/libraries/TinyGL/asm_fork/info_fun_float.inc b/programs/develop/libraries/TinyGL/asm_fork/info_fun_float.inc new file mode 100644 index 0000000000..b0e6d64816 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/info_fun_float.inc @@ -0,0 +1,326 @@ +; +; 㭪樨 ࠡ ᫠ float +; + +; ⢮ ᫠ ᫥ ⮩ (1-17) +NumberSymbolsAD DW 5 +; ⠭ (10 ⥯ N) +MConst DQ 1.0E1,1.0E2,1.0E3,1.0E4,1.0E5 + DQ 1.0E6,1.0E7,1.0E8,1.0E9,1.0E10 + DQ 1.0E11,1.0E12,1.0E13,1.0E14,1.0E15 + DQ 1.0E16,1.0E17,1.0E18,1.0E19,1.0E20 + DQ 1.0E21,1.0E22,1.0E23,1.0E24,1.0E25 + DQ 1.0E26,1.0E27,1.0E28,1.0E29,1.0E30 + DQ 1.0E31,1.0E32,1.0E33,1.0E34,1.0E35 + DQ 1.0E36,1.0E37,1.0E38,1.0E39,1.0E40 + DQ 1.0E41,1.0E42,1.0E43,1.0E44,1.0E45 + DQ 1.0E46,1.0E47,1.0E48,1.0E49,1.0E50 + DQ 1.0E51,1.0E52,1.0E53,1.0E54,1.0E55 + DQ 1.0E56,1.0E57,1.0E58,1.0E59,1.0E60 + DQ 1.0E61,1.0E62,1.0E63,1.0E64,1.0E65 + DQ 1.0E66,1.0E67,1.0E68,1.0E69,1.0E70 + DQ 1.0E71,1.0E72,1.0E73,1.0E74,1.0E75 + DQ 1.0E76,1.0E77,1.0E78,1.0E79,1.0E80 + DQ 1.0E81,1.0E82,1.0E83,1.0E84,1.0E85 + DQ 1.0E86,1.0E87,1.0E88,1.0E89,1.0E90 + DQ 1.0E91,1.0E92,1.0E93,1.0E94,1.0E95 + DQ 1.0E96,1.0E97,1.0E98,1.0E99,1.0E100 + DQ 1.0E101,1.0E102,1.0E103,1.0E104,1.0E105 + DQ 1.0E106,1.0E107,1.0E108,1.0E109,1.0E110 + DQ 1.0E111,1.0E112,1.0E113,1.0E114,1.0E115 + DQ 1.0E116,1.0E117,1.0E118,1.0E119,1.0E120 + DQ 1.0E121,1.0E122,1.0E123,1.0E124,1.0E125 + DQ 1.0E126,1.0E127,1.0E128 +; ᫮ 饩 ⮩ 筮 +Data_Double DQ ? +; ᫮ BCD-ଠ +Data_BCD DT ? +; ᯮ⥫ 䫠 +Data_Flag DB ? +; १ (᫨ 0 - ⥫쭮 ᫮) +Data_Sign DB ? + + +db 0 ;㪠⥫ ᤢ +; ப ࠭ ᫠ ASCII +Data_String DB 32 DUP (?) + + + +;******************************************************* +;* * +;* ᫮ ଠ 㤢 筮, १ * +;* 뤠 筮 , "⮢" ଠ * +;* 䨪஢ ⢮ ᫥ ⮩. * +;* 室 ࠬ: * +;* Data_Double - ८ࠧ㥬 ᫮; * +;* NumberSymbolsAD - ⢮ ᫥ * +;* ⮩ (0-17). * +;* 室 ࠬ: * +;* Data_String - ப-१. * +;******************************************************* +DoubleFloat_to_String: + pushad + ; 뢠 ப Data_String + lea EDI, [Data_String] + + ; ᫮ NumberSymbolsAD + ; ࠧ冷 + fninit ; ᮯ + fld [Data_Double] ;㧨 ᫮ + xor ebx,ebx + mov BX,[NumberSymbolsAD] + cmp BX, 0 + je .NoShifts ; ᫥ ⮩ + jl .Error ;訡 + dec BX + shl BX, 3 ;㬭 8 + lea eax,[MConst] + add EBX, eax + fmul qword [EBX] ;㬭 ⠭ +.NoShifts: + ; ᫮ BCD + fbstp [Data_BCD] +; ஢ १ ९ + mov AX,word [Data_BCD + 8] + cmp AX,0FFFFh ;"筮" ९? + je .Overflow +; 뤥 ᫠ ASCII- + mov AL, byte [Data_BCD + 9] + and AL,AL + jz .NoSign + mov AL,'-' + stosb +.NoSign: +; ᯠ ᫮ ASCII + mov ebx,8 ;ᬥ饭 ᫥ + mov ecx,9 ;稪 + ; । 筮 窨 ᫥ + mov DX,18 + sub DX,[NumberSymbolsAD] + js .Error ;訡, ᫨ ⥫쭠 + jz .Error ; 㫥 +.NextPair: + ; 㧨 । ࠧ冷 + mov AL, byte [ebx + Data_BCD] + mov AH,AL + ; 뤥, ॢ ASCII + ; ࠭ ࠤ + shr AL,4 + add AL,'0' + stosb + dec DX + jnz .N0 + mov AL,'.' + stosb +.N0: ; 뤥, ॢ ASCII + ; ࠭ ࠤ + mov AL,AH + and AL,0Fh + add AL,'0' + stosb + dec DX + jnz .N1 + mov AL,'.' + stosb +.N1: + dec BX + loop .NextPair + mov AL,0 + stosb + +; 騥 㫨 ᫥ + lea EDI, [Data_String] + lea ESI, [Data_String] + ; ய ᫠, ᫨ + cmp byte [ESI],'-' + jne .N2 + inc ESI + inc EDI +.N2: ; 㧨 稪 横 ⢮ ࠧ冷 + ; ᫠ 1 ( 筮 窨) + mov ecx,18+1+1 + ; ய 騥 㫨 +.N3: + cmp byte [ESI],'0' + jne .N4 + cmp byte [ESI+1],'.' + je .N4 + inc ESI + loop .N3 + ; 訡 - + jmp .Error +; ஢ ᫠ 砫 ப +.N4: rep movsb + jmp .End + +; 訡 +.Error: + mov AL,'E' + stosb + mov AL,'R' + stosb + mov AL,'R' + stosb + xor AL,AL + stosb + jmp .End +; ९ ࠧ來 ⪨ +.Overflow: + mov AL,'#' + stosb + xor AL,AL + stosb +; 楤 +.End: + popad + ret + +;**************************************************** +;* * +;* (᫮ , "⮢" ଠ) * +;* 室 ࠬ: * +;* Data_String - ᫮ ASCII. * +;* 室 ࠬ: * +;* Data_Double - ᫮ 筮 . * +;**************************************************** +String_to_DoubleFloat: + pushad + cld + ; 頥 Data_BCD + mov dword [Data_BCD],0 + mov dword [Data_BCD+4],0 + mov word [Data_BCD+8],0 + ; 頥 + mov [Data_Sign],0 + ; ᨬ SI 㪠⥫ ப + lea ESI, [Data_String] + ; ய᪠ ஡ । ᫮ + mov ecx,64 ; 横 +.ShiftIgnore: + lodsb + cmp AL,' ' + jne .ShiftIgnoreEnd + loop .ShiftIgnore + jmp .Error +.ShiftIgnoreEnd: + ; ஢塞 ᫠ + cmp AL,'-' + jne .Positive + mov [Data_Sign],80h + lodsb +.Positive: + mov [Data_Flag],0 ;ਧ 窨 + mov DX,0 ; 窨 + mov ecx,18 ;. ᫮ ࠧ冷 +.ASCIItoBCDConversion: + cmp AL,'.' ;窠? + jne .NotDot + cmp [Data_Flag],0 ;窠 砫? + jne .Error + mov [Data_Flag],1 + lodsb + cmp AL,0 ; ப? + jne .NotDot + jmp .ASCIItoBCDConversionEnd +.NotDot: + ; 1 祭 樨 窨, + ; ᫨ 砫 + cmp [Data_Flag],0 + jnz .Figures + inc DX +.Figures: + ; ᫠ ࠬ + cmp AL,'0' + jb .Error + cmp AL,'9' + ja .Error + ; 襬 । ࠤ BCD + and AL,0Fh + or byte [Data_BCD],AL + ; ஢ઠ ப + cmp byte [ESI],0 + je .ASCIItoBCDConversionEnd + ; BCD 4 ࠧ鸞 + ; (ᤢ 訥 2 ) + mov AX,word [Data_BCD+6] + shld word [Data_BCD+8],AX,4 + ; (ᤢ । 4 ) + mov EAX, dword [Data_BCD] + shld dword [Data_BCD+4],EAX,4 + ; (ᤢ 訥 4 ) + shl dword [Data_BCD],4 + ; 㦠 ᫥騩 ᨬ AL + lodsb + loop .ASCIItoBCDConversion + ; ᫨ 19- ᨬ 0 窠, + ; 訡 ९ + cmp AL,'.' + jne .NotDot2 + inc ecx + lodsb +.NotDot2: + cmp AL,0 + jne .Error ;९ ࠧ來 ⪨ + +; BCD +.ASCIItoBCDConversionEnd: + ; 訩 + mov AL,[Data_Sign] + mov byte [Data_BCD+9],AL + ; ॣ ᮯ + fninit + ; 㧨 ᮯ ᫮ BCD-ଠ + fbld [Data_BCD] + ; ᫨ ⥫ + mov EBX,18+1 + sub BX,CX + sub BX,DX + cmp EBX,0 + je .NoDiv + dec EBX + shl EBX,3 ;㬭 8 + lea eax,[MConst] + add EBX,eax + fdiv qword [EBX] ;ࠧ ⠭ +.NoDiv:; 㧨 ᫮ 筮 ଠ + fstp [Data_Double] + jmp .End + +.Error:;  訡 㫨 १ + fldz ; ⥪ ᮯ + fstp [Data_Double] +.End: + popad + ret + +align 4 +proc str_cat, str1:dword, str2:dword + push eax ecx edi esi + mov esi,dword[str2] + stdcall str_len,esi + mov ecx,eax + inc ecx + mov edi,dword[str1] + stdcall str_len,edi + add edi,eax + cld + repne movsb + pop esi edi ecx eax + ret +endp + +;output: +; eax = strlen +align 4 +proc str_len, str1:dword + mov eax,[str1] + @@: + cmp byte[eax],0 + je @f + inc eax + jmp @b + @@: + sub eax,[str1] + ret +endp \ No newline at end of file diff --git a/programs/develop/libraries/TinyGL/asm_fork/init.asm b/programs/develop/libraries/TinyGL/asm_fork/init.asm new file mode 100644 index 0000000000..47a1b9034c --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/init.asm @@ -0,0 +1,207 @@ + +align 4 +proc initSharedState uses eax ebx, context:dword + mov ebx,[context] + + stdcall gl_zalloc, 4*MAX_DISPLAY_LISTS + mov [ebx+offs_cont_shared_state],eax ;...lists=gl_zalloc(...) + stdcall gl_zalloc, 4*TEXTURE_HASH_TABLE_SIZE + mov [ebx+offs_cont_shared_state+4],eax ;...texture_hash_table=gl_zalloc(...) + + stdcall alloc_texture, [context],0 + ret +endp + +align 4 +proc endSharedState uses eax ebx, context:dword + mov ebx,[context] + mov ebx,[ebx+offs_cont_shared_state] + + ; int i; +; for(i=0;igl_context=NULL; +; return (KOSGLContext) ctx; +;} + +;void kosglDestroyContext( KOSGLContext ctx1 ) +;{ +; TinyGLContext *ctx = (TinyGLContext *) ctx1; +; if (ctx->gl_context != NULL) { +; glClose(); +; } +; gl_free(ctx); +;} + +; resize the glx viewport : we try to use the xsize and ysize +; given. We return the effective size which is guaranted to be smaller + +align 4 +proc gl_resize_viewport uses ebx ecx edx edi esi, context:dword, xsize_ptr:dword, ysize_ptr:dword + xor eax,eax + + mov ecx,[xsize_ptr] ; ecx = &xsize + mov edi,[ecx] ; edi = xsize + mov esi,[ysize_ptr] ; esi = &ysize + mov esi,[esi] ; esi = ysize + + ; we ensure that xsize and ysize are multiples of 2 for the zbuffer. + ; TODO: find a better solution + and edi, not 3 + and esi, not 3 + + cmp edi,0 + jne @f + cmp esi,0 + jne @f + mov eax,-1 + jmp .end_f + @@: + + mov [ecx],edi + dec dword[ecx] + mov ecx,[ysize_ptr] + mov [ecx],esi + dec dword[ecx] + + mov ebx,[context] + mov edx,[ebx+offs_cont_opaque] ; edx = (TinyGLContext *)context.opaque + mov [edx+4],edi + mov [edx+12],edi ;d_x = xsize + mov [edx+8],esi + mov [edx+16],esi ;d_y = ysize + + ; resize the Z buffer + stdcall ZB_resize, dword[ebx+offs_cont_zb],0,edi,esi + .end_f: + ret +endp + +; we assume here that drawable is a window +align 4 +proc kosglMakeCurrent uses ebx ecx, win_x0:dword, win_y0:dword, win_x:dword, win_y:dword, ctx1:dword + mov ebx,[ctx1] + cmp dword[ebx],0 ;if (ctx.gl_context == NULL) + jne .end_f + ; create the TinyGL context + mov ecx,[win_x0] + mov [ebx+20],ecx ;ctx.x = win_x0 + mov ecx,[win_y0] + mov [ebx+24],ecx ;ctx.y = win_y0 + mov ecx,[win_x] + mov [ebx+12],ecx ;ctx.d_x = win_x + mov ecx,[win_y] + mov [ebx+16],ecx ;ctx.d_y = win_y + + ; currently, we only support 16 bit rendering + xor eax,eax + stdcall ZB_open, dword[win_x], dword[win_y], dword ZB_MODE_RGB24, eax,eax,eax,eax ;NULL,NULL,NULL + + cmp eax,0 + jne @f + stdcall dbg_print,f_kosgl_1,err_0 + xor eax,eax + jmp .err_f + @@: + + ; initialisation of the TinyGL interpreter + stdcall glInit, eax + + call gl_get_context + mov [ebx],eax ;ctx.gl_context = eax + + mov [eax+offs_cont_opaque],ebx ;ctx.gl_context.opaque = ctx + mov dword[eax+offs_cont_gl_resize_viewport],gl_resize_viewport + + ; set the viewport : we force a call to gl_resize_viewport + dec dword[eax+offs_cont_viewport+offs_vpor_xsize] + dec dword[eax+offs_cont_viewport+offs_vpor_ysize] + + stdcall glViewport, 0, 0, [win_x], [win_y] + .end_f: + xor eax,eax + inc eax + .err_f: + ret +endp + +align 4 +proc kosglSwapBuffers uses eax ebx ecx edx esi + ; retrieve the current TinyGLContext + call gl_get_context + mov ebx,[eax+offs_cont_zb] + mov ebx,[ebx+offs_zbuf_pbuf] + mov esi,[eax+offs_cont_opaque] ;esi = &context.opaque + mov eax,7 + mov ecx,[esi+12] ;d_x + shl ecx,16 + mov cx,[esi+16] ;d_y + mov edx,[esi+20] ;x + shl edx,16 + mov dx,[esi+24] ;y + int 0x40 + ret +endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/light.asm b/programs/develop/libraries/TinyGL/asm_fork/light.asm new file mode 100644 index 0000000000..641803cd67 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/light.asm @@ -0,0 +1,350 @@ +;include 'msghandling.inc' + +align 4 +proc glopMaterial, context:dword, p:dword +; int mode=p[1].i; +; int type=p[2].i; +; float *v=&p[3].f; +; int i; +; GLMaterial *m; + +; if (mode == GL_FRONT_AND_BACK) { +; p[1].i=GL_FRONT; +; glopMaterial(c,p); +; mode=GL_BACK; +; } +; if (mode == GL_FRONT) m=&c->materials[0]; +; else m=&c->materials[1]; + +; switch(type) { +; case GL_EMISSION: +; for(i=0;i<4;i++) +; m->emission.v[i]=v[i]; +; break; +; case GL_AMBIENT: +; for(i=0;i<4;i++) +; m->ambient.v[i]=v[i]; +; break; +; case GL_DIFFUSE: +; for(i=0;i<4;i++) +; m->diffuse.v[i]=v[i]; +; break; +; case GL_SPECULAR: +; for(i=0;i<4;i++) +; m->specular.v[i]=v[i]; +; break; +; case GL_SHININESS: +; m->shininess=v[0]; +; m->shininess_i = (v[0]/128.0f)*SPECULAR_BUFFER_RESOLUTION; +; break; +; case GL_AMBIENT_AND_DIFFUSE: +; for(i=0;i<4;i++) +; m->diffuse.v[i]=v[i]; +; for(i=0;i<4;i++) +; m->ambient.v[i]=v[i]; +; break; +; default: +; assert(0); +; } + ret +endp + +align 4 +proc glopColorMaterial uses eax ebx ecx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ecx,[ebx+4] ;ecx = p[1] + mov dword[eax+offs_cont_current_color_material_mode],ecx + mov ecx,[ebx+8] ;ecx = p[2] + mov dword[eax+offs_cont_current_color_material_type],ecx + ret +endp + +;void glopLight(GLContext *c,GLParam *p) +;{ +; int light=p[1].i; +; int type=p[2].i; +; V4 v; +; GLLight *l; +; int i; +; +; assert(light >= GL_LIGHT0 && light < GL_LIGHT0+MAX_LIGHTS ); +; +; l=&c->lights[light-GL_LIGHT0]; +; +; for(i=0;i<4;i++) v.v[i]=p[3+i].f; +; +; switch(type) { +; case GL_AMBIENT: +; l->ambient=v; +; break; +; case GL_DIFFUSE: +; l->diffuse=v; +; break; +; case GL_SPECULAR: +; l->specular=v; +; break; +; case GL_POSITION: +; { +; V4 pos; +; gl_M4_MulV4(&pos,c->matrix_stack_ptr[0],&v); +; +; l->position=pos; +; +; if (l->position.v[3] == 0) { +; l->norm_position.X=pos.X; +; l->norm_position.Y=pos.Y; +; l->norm_position.Z=pos.Z; +; +; gl_V3_Norm(&l->norm_position); +; } +; } +; break; +; case GL_SPOT_DIRECTION: +; for(i=0;i<3;i++) { +; l->spot_direction.v[i]=v.v[i]; +; l->norm_spot_direction.v[i]=v.v[i]; +; } +; gl_V3_Norm(&l->norm_spot_direction); +; break; +; case GL_SPOT_EXPONENT: +; l->spot_exponent=v.v[0]; +; break; +; case GL_SPOT_CUTOFF: +; { +; float a=v.v[0]; +; assert(a == 180 || (a>=0 && a<=90)); +; l->spot_cutoff=a; +; if (a != 180) l->cos_spot_cutoff=cos(a * M_PI / 180.0); +; } +; break; +; case GL_CONSTANT_ATTENUATION: +; l->attenuation[0]=v.v[0]; +; break; +; case GL_LINEAR_ATTENUATION: +; l->attenuation[1]=v.v[0]; +; break; +; case GL_QUADRATIC_ATTENUATION: +; l->attenuation[2]=v.v[0]; +; break; +; default: +; assert(0); +; } +;} + +align 4 +proc glopLightModel uses ebx ecx esi edi, context:dword, p:dword + mov edi,[context] + mov ebx,[p] + mov esi,[ebx+8] + + cmp dword[ebx+4],GL_LIGHT_MODEL_AMBIENT + jne @f + mov ecx,4 + mov edi,dword[edi+offs_cont_ambient_light_model] + rep movsd ;for(i=0;i<4;i++) context.ambient_light_model.v[i]=v[i] + jmp .end_f + @@: + cmp dword[ebx+4],GL_LIGHT_MODEL_LOCAL_VIEWER + jne @f + fld dword[esi] ;st0 = p[2].v[0] + fistp dword[edi+offs_cont_local_light_model] + jmp .end_f + @@: + cmp dword[ebx+4],GL_LIGHT_MODEL_TWO_SIDE + jne @f + fld dword[esi] ;st0 = p[2].v[0] + fistp dword[edi+offs_cont_light_model_two_side] + jmp .end_f + @@: ;default: +; tgl_warning("glopLightModel: illegal pname: 0x%x\n", dword[ebx+4]); +; //assert(0); + .end_f: + ret +endp + +;static inline float clampf(float a,float min,float max) +;{ +; if (amax) return max; +; else return a; +;} + +align 4 +proc gl_enable_disable_light uses eax ebx ecx, context:dword, light:dword, v:dword + mov eax,[context] + mov ebx,[light] + imul ebx,sizeof.GLLight + add ebx,[eax+offs_cont_lights] + + xor ecx,ecx + cmp dword[ebx+offs_ligh_enabled],0 + jne @f + not ecx + @@: + and ecx,[v] + cmp ecx,0 + je @f + ;if (v && !l.enabled) + mov dword[ebx+offs_ligh_enabled],1 + mov ecx,[eax+offs_cont_first_light] + mov [ebx+offs_ligh_next],ecx + mov [eax+offs_cont_first_light],ebx ;context.first_light = l + mov dword[ebx+offs_ligh_prev],0 ;l.prev = NULL + jmp .end_f + @@: + xor ecx,ecx + cmp dword[v],0 + jne @f + not ecx + @@: + and ecx,[ebx+offs_ligh_enabled] + cmp ecx,0 + je .end_f + ;else if (!v && l.enabled) + mov dword[ebx+offs_ligh_enabled],0 ;l.enabled = 0 + mov ecx,[ebx+offs_ligh_next] + cmp dword[ebx+offs_ligh_prev],0 ;if (l.prev == NULL) + jne .els_0 + mov [eax+offs_cont_first_light],ecx ;context.first_light = l.next + jmp @f + .els_0: + mov eax,[ebx+offs_ligh_prev] + mov [eax+offs_ligh_next],ecx ;l.prev.next = l.next + @@: + cmp dword[ebx+offs_ligh_next],0 + je .end_f + mov ecx,[ebx+offs_ligh_prev] + mov eax,[ebx+offs_ligh_next] + mov [eax+offs_ligh_prev],ecx ;l.next.prev = l.prev + .end_f: + ret +endp + +; non optimized lightening model +align 4 +proc gl_shade_vertex, context:dword, v:dword + +; float R,G,B,A; +; GLMaterial *m; +; GLLight *l; +; V3 n,s,d; +; float dist,tmp,att,dot,dot_spot,dot_spec; +; int twoside = c->light_model_two_side; + +; m=&c->materials[0]; + +; n.X=v->normal.X; +; n.Y=v->normal.Y; +; n.Z=v->normal.Z; + +; R=m->emission.v[0]+m->ambient.v[0]*c->ambient_light_model.v[0]; +; G=m->emission.v[1]+m->ambient.v[1]*c->ambient_light_model.v[1]; +; B=m->emission.v[2]+m->ambient.v[2]*c->ambient_light_model.v[2]; +; A=clampf(m->diffuse.v[3],0,1); + +; for(l=c->first_light;l!=NULL;l=l->next) { +; float lR,lB,lG; + +; /* ambient */ +; lR=l->ambient.v[0] * m->ambient.v[0]; +; lG=l->ambient.v[1] * m->ambient.v[1]; +; lB=l->ambient.v[2] * m->ambient.v[2]; + +; if (l->position.v[3] == 0) { +; /* light at infinity */ +; d.X=l->position.v[0]; +; d.Y=l->position.v[1]; +; d.Z=l->position.v[2]; +; att=1; +; } else { +; /* distance attenuation */ +; d.X=l->position.v[0]-v->ec.v[0]; +; d.Y=l->position.v[1]-v->ec.v[1]; +; d.Z=l->position.v[2]-v->ec.v[2]; +; dist=sqrt(d.X*d.X+d.Y*d.Y+d.Z*d.Z); +; if (dist>1E-3) { +; tmp=1/dist; +; d.X*=tmp; +; d.Y*=tmp; +; d.Z*=tmp; +; } +; att=1.0f/(l->attenuation[0]+dist*(l->attenuation[1]+ +; dist*l->attenuation[2])); +; } +; dot=d.X*n.X+d.Y*n.Y+d.Z*n.Z; +; if (twoside && dot < 0) dot = -dot; +; if (dot>0) { +; /* diffuse light */ +; lR+=dot * l->diffuse.v[0] * m->diffuse.v[0]; +; lG+=dot * l->diffuse.v[1] * m->diffuse.v[1]; +; lB+=dot * l->diffuse.v[2] * m->diffuse.v[2]; +; +; /* spot light */ +; if (l->spot_cutoff != 180) { +; dot_spot=-(d.X*l->norm_spot_direction.v[0]+ +; d.Y*l->norm_spot_direction.v[1]+ +; d.Z*l->norm_spot_direction.v[2]); +; if (twoside && dot_spot < 0) dot_spot = -dot_spot; +; if (dot_spot < l->cos_spot_cutoff) { +; /* no contribution */ +; continue; +; } else { +; /* TODO: optimize */ +; if (l->spot_exponent > 0) { +; att=att*pow(dot_spot,l->spot_exponent); +; } +; } +; } + +; /* specular light */ + +; if (c->local_light_model) { +; V3 vcoord; +; vcoord.X=v->ec.X; +; vcoord.Y=v->ec.Y; +; vcoord.Z=v->ec.Z; +; gl_V3_Norm(&vcoord); +; s.X=d.X-vcoord.X; +; s.Y=d.Y-vcoord.X; +; s.Z=d.Z-vcoord.X; +; } else { +; s.X=d.X; +; s.Y=d.Y; +; s.Z=d.Z+1.0; +; } +; dot_spec=n.X*s.X+n.Y*s.Y+n.Z*s.Z; +; if (twoside && dot_spec < 0) dot_spec = -dot_spec; +; if (dot_spec>0) { +; GLSpecBuf *specbuf; +; int idx; +; tmp=sqrt(s.X*s.X+s.Y*s.Y+s.Z*s.Z); +; if (tmp > 1E-3) { +; dot_spec=dot_spec / tmp; +; } + +; /* TODO: optimize */ +; /* testing specular buffer code */ +; /* dot_spec= pow(dot_spec,m->shininess);*/ +; specbuf = specbuf_get_buffer(c, m->shininess_i, m->shininess); +; idx = (int)(dot_spec*SPECULAR_BUFFER_SIZE); +; if (idx > SPECULAR_BUFFER_SIZE) idx = SPECULAR_BUFFER_SIZE; +; dot_spec = specbuf->buf[idx]; +; lR+=dot_spec * l->specular.v[0] * m->specular.v[0]; +; lG+=dot_spec * l->specular.v[1] * m->specular.v[1]; +; lB+=dot_spec * l->specular.v[2] * m->specular.v[2]; +; } +; } + +; R+=att * lR; +; G+=att * lG; +; B+=att * lB; +; } + +; v->color.v[0]=clampf(R,0,1); +; v->color.v[1]=clampf(G,0,1); +; v->color.v[2]=clampf(B,0,1); +; v->color.v[3]=A; + ret +endp + diff --git a/programs/develop/libraries/TinyGL/asm_fork/list.asm b/programs/develop/libraries/TinyGL/asm_fork/list.asm new file mode 100644 index 0000000000..06262bc57e --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/list.asm @@ -0,0 +1,329 @@ +;строки с именами функций +op_table_str: +macro ADD_OP a,b,c +{ + db 'gl',`a,' ',c,0 +} +include 'opinfo.inc' + +;указатели на функции ;static void (*op_table_func[])(GLContext *,GLParam *)= +op_table_func: +macro ADD_OP a,b,c +{ + dd glop#a +} +include 'opinfo.inc' + +;число параметров в функциях +op_table_size: +macro ADD_OP a,b,c +{ + dd b+1 +} +include 'opinfo.inc' + + +;output: +; eax = context.shared_state.lists[list] +align 4 +proc find_list uses ebx, context:dword, list:dword + mov eax,[context] + mov eax,[eax+offs_cont_shared_state] + mov ebx,[list] + shl ebx,2 + add eax,ebx + mov eax,[eax] + ret +endp + +;static void delete_list(GLContext *c,int list) +;{ +; GLParamBuffer *pb,*pb1; +; GLList *l; + +; l=find_list(c,list); +; assert(l != NULL); + +; /* free param buffer */ +; pb=l->first_op_buffer; +; while (pb!=NULL) { +; pb1=pb->next; +; gl_free(pb); +; pb=pb1; +; } + +; gl_free(l); +; c->shared_state.lists[list]=NULL; +;} + +;static GLList *alloc_list(GLContext *c,int list) +;{ +; GLList *l; +; GLParamBuffer *ob; + +; l=gl_zalloc(sizeof(GLList)); +; ob=gl_zalloc(sizeof(GLParamBuffer)); + +; ob->next=NULL; +; l->first_op_buffer=ob; + +; ob->ops[0].op=OP_EndList; + +; c->shared_state.lists[list]=l; +; return l; +;} + +;void gl_print_op(FILE *f,GLParam *p) +;{ +; int op; +; char *s; + +; op=p[0].op; +; p++; +; s=op_table_str[op]; +; while (*s != 0) { +; if (*s == '%') { +; s++; +; switch (*s++) { +; case 'f': +; fprintf(f,"%g",p[0].f); +; break; +; default: +; fprintf(f,"%d",p[0].i); +; break; +; } +; p++; +; } else { +; fputc(*s,f); +; s++; +; } +; } +; fprintf(f,"\n"); +;} + +align 4 +proc gl_compile_op uses eax ebx, context:dword, p:dword + mov eax,[context] +; int op,op_size; +; GLParamBuffer *ob,*ob1; +; int index,i; + +; op=p[0].op; +; op_size=op_table_size[op]; +; index=c->current_op_buffer_index; +; ob=c->current_op_buffer; + +; /* we should be able to add a NextBuffer opcode */ +; if ((index + op_size) > (OP_BUFFER_MAX_SIZE-2)) { + +; ob1=gl_zalloc(sizeof(GLParamBuffer)); +; ob1->next=NULL; + +; ob->next=ob1; +; ob->ops[index].op=OP_NextBuffer; +; ob->ops[index+1].p=(void *)ob1; + +; c->current_op_buffer=ob1; +; ob=ob1; +; index=0; +; } + +; for(i=0;iops[index]=p[i]; +; index++; +; } +; c->current_op_buffer_index=index; + ret +endp + +align 4 +proc gl_add_op uses eax ebx ecx, p:dword ;GLParam* +if DEBUG +push edi esi + mov ebx,[p] + mov ebx,[ebx] + lea eax,[op_table_str] + @@: + cmp ebx,0 + je @f + cmp byte[eax],0 + jne .no_dec + dec ebx + .no_dec: + inc eax + jmp @b + @@: + stdcall dbg_print,eax,txt_nl + + mov esi,eax + mov word[NumberSymbolsAD],3 + mov ebx,[p] + lea edi,[buf_param] + mov byte[edi],0 + mov ecx,80 + .cycle_0: + cmp byte[esi],'%' + jne .no_param + cmp ebx,[p] + je @f + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + @@: + add ebx,4 + inc esi + + cmp byte[esi],'f' + jne @f + fld dword[ebx] + fstp qword[Data_Double] + call DoubleFloat_to_String + stdcall str_cat, edi,Data_String + @@: + cmp byte[esi],'d' + jne @f + stdcall str_len,edi + add edi,eax + sub ecx,eax + mov eax,dword[ebx] + stdcall convert_int_to_str,ecx + @@: + .no_param: + inc esi + cmp byte[esi],0 + jne .cycle_0 + stdcall str_cat, edi,txt_nl + stdcall dbg_print,txt_sp,buf_param +pop esi edi +end if + call gl_get_context + mov ebx,[p] + + cmp dword[eax+offs_cont_exec_flag],0 + je @f + push ebx + push eax + mov ecx,dword[ebx] ;ecx = OP_... + shl ecx,2 + lea ebx,[op_table_func] + add ecx,ebx + call dword[ecx] ;op_table_func[op](c,p) + @@: + cmp dword[eax+offs_cont_compile_flag],0 + je @f + stdcall gl_compile_op,eax,[p] + @@: + cmp dword[eax+offs_cont_print_flag],0 + je @f + ;gl_print_op(stderr,p); + @@: + ret +endp + +; this opcode is never called directly +align 4 +proc glopEndList, context:dword, p:dword +; assert(0); + ret +endp + +; this opcode is never called directly +align 4 +proc glopNextBuffer, context:dword, p:dword +; assert(0); + ret +endp + +;void glopCallList(GLContext *c,GLParam *p) +;{ +; GLList *l; +; int list,op; + +; list=p[1].ui; +; l=find_list(c,list); +; if (l == NULL) gl_fatal_error("list %d not defined",list); +; p=l->first_op_buffer->ops; + +; while (1) { +; op=p[0].op; +; if (op == OP_EndList) break; +; if (op == OP_NextBuffer) { +; p=(GLParam *)p[1].p; +; } else { +; op_table_func[op](c,p); +; p+=op_table_size[op]; +; } +; } +;} + +;void glNewList(unsigned int list,int mode) +;{ +; GLList *l; +; GLContext *c=gl_get_context(); +; +; assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE); +; assert(c->compile_flag == 0); +; +; l=find_list(c,list); +; if (l!=NULL) delete_list(c,list); +; l=alloc_list(c,list); +; +; c->current_op_buffer=l->first_op_buffer; +; c->current_op_buffer_index=0; +; +; c->compile_flag=1; +; c->exec_flag=(mode == GL_COMPILE_AND_EXECUTE); +;} + +;void glEndList(void) +;{ +; GLContext *c=gl_get_context(); +; GLParam p[1]; + +; assert(c->compile_flag == 1); + +; /* end of list */ +; p[0].op=OP_EndList; +; gl_compile_op(c,p); + +; c->compile_flag=0; +; c->exec_flag=1; +;} + +;output: +; eax = (find_list(gl_get_context,list) != NULL) +align 4 +proc glIsList, list:dword + call gl_get_context + stdcall find_list, eax,[list] + cmp eax,0 ;NULL + je @f + mov eax,1 + @@: + ret +endp + +;unsigned int glGenLists(int range) +;{ +; GLContext *c=gl_get_context(); +; int count,i,list; +; GLList **lists; + +; lists=c->shared_state.lists; +; count=0; +; for(i=0;imatrix_stack_ptr[ebx] - c->matrix_stack[ebx] + 1 ) +; < c->matrix_stack_depth_max[ebx] ); + + shl ebx,2 + add ebx,eax + add ebx,offs_cont_matrix_stack_ptr + add dword[ebx],sizeof.M4 + mov ebx,[ebx] ;ebx = ++context.matrix_stack_ptr[context.matrix_mode] + + sub ebx,sizeof.M4 + push ebx + add ebx,sizeof.M4 + stdcall gl_M4_Move, ebx + + gl_matrix_update eax,ebx + ret +endp + +align 4 +proc glopPopMatrix uses eax ebx, context:dword, p:dword + mov eax,[context] + mov ebx,[eax+offs_cont_matrix_mode] + +; assert( c->matrix_stack_ptr[n] > c->matrix_stack[n] ); + + shl ebx,2 + add ebx,eax + sub dword[ebx+offs_cont_matrix_stack_ptr],sizeof.M4 + + gl_matrix_update eax,ebx + ret +endp + +align 4 +proc glopRotate uses eax ebx ecx, context:dword, p:dword +locals + u0 dd ? + u1 dd ? + u2 dd ? + angle dd ? + cost dd ? + sint dd ? + m M4 +endl + + mov eax,[context] + mov ebx,[p] + mov ecx,ebp + sub ecx,sizeof.M4 ;ecx=&m + finit + fldpi + fmul dword[ebx+4] + fdiv dword[an180f] + fst dword[angle] ;angle = p[1].f * M_PI / 180.0 + ;st0 = angle + + fldz + fild dword[ebx+8] + fstp dword[u0] + fild dword[ebx+12] + fstp dword[u1] + fild dword[ebx+16] + fst dword[u2] + + ; simple case detection + xor ebx,ebx + fcomp st1 ;u2 ... 0 + fstsw ax + sahf + je @f + inc ebx + @@: + fcom dword[u1] ;0 ... u1 + fstsw ax + sahf + je @f + or ebx,2 + @@: + fcom dword[u0] ;0 ... u0 + fstsw ax + sahf + je @f + or ebx,4 + @@: + ;st0 = 0, st1 = angle + + ;ebx = ((u0 != 0)<<2) | ((u1 != 0)<<1) | (u2 != 0) + cmp ebx,0 + je .end_f ;если нет поворотов выход из функции + cmp ebx,4 + jne @f + fcomp dword[u0] ;0 ... u0 + fstsw ax + sahf + jae .u0ch + fchs + fstp dword[angle] ;if (u0 < 0) angle *= -1 + .u0ch: + stdcall gl_M4_Rotate, ecx,[angle],0 + jmp .end_sw + @@: + cmp ebx,2 + jne @f + fcomp dword[u1] ;0 ... u1 + fstsw ax + sahf + jae .u1ch + fchs + fstp dword[angle] ;if (u1 < 0) angle *= -1 + .u1ch: + stdcall gl_M4_Rotate, ecx,[angle],1 + jmp .end_sw + @@: + cmp ebx,1 + jne @f + fcomp dword[u2] ;0 ... u2 + fstsw ax + sahf + jae .u2ch + fchs + fstp dword[angle] ;if (u2 < 0) angle *= -1 + .u2ch: + stdcall gl_M4_Rotate, ecx,[angle],2 + jmp .end_sw + @@: ;default: +if DEBUG ;glopRotete + stdcall dbg_print,txt_sp,m_1 +end if + + ; normalize vector + fld dword[u0] + fmul st0,st0 + fld dword[u1] + fmul st0,st0 + fld dword[u2] + fmul st0,st0 + fadd st0,st1 + fadd st0,st2 +; fst dword[len] ;len = u0*u0+u1*u1+u2*u2 + fcom st1 + fstsw ax + sahf + je .end_f ;if (len == 0.0f) return + fsqrt + fld1 + fdiv st0,st1 +; fst dword[len] ;len = 1.0f / sqrt(len) + fld dword[u0] + fmul st0,st1 + fstp dword[u0] ;u0 *= len + fld dword[u1] + fmul st0,st1 + fstp dword[u1] ;u1 *= len + fld dword[u2] + fmul st0,st1 + fstp dword[u2] ;u2 *= len + ;st0 = len, st1=..., st2=..., st3 = 0, st4 = angle + + ; store cos and sin values + finit + fld dword[angle] + fcos + fst dword[cost] ;cost=cos(angle) + fld dword[angle] + fsin + fst dword[sint] ;sint=sin(angle) + + ; fill in the values + mov ebx,0.0 + mov [ecx+3*16 ],ebx ;m[3][0] + mov [ecx+3*16 +4],ebx ;m[3][1] + mov [ecx+3*16 +8],ebx ;m[3][2] + mov [ecx+ 12],ebx ;m[0][3] + mov [ecx+ 16+12],ebx ;m[1][3] + mov [ecx+2*16+12],ebx ;m[2][3] + mov ebx,1.0 + mov [ecx+3*16+12],ebx ;m[3][3] + + ; do the math +; m.m[0][0]=u[0]*u[0]+cost*(1-u[0]*u[0]); +; m.m[1][0]=u[0]*u[1]*(1-cost)-u[2]*sint; +; m.m[2][0]=u[2]*u[0]*(1-cost)+u[1]*sint; +; m.m[0][1]=u[0]*u[1]*(1-cost)+u[2]*sint; +; m.m[1][1]=u[1]*u[1]+cost*(1-u[1]*u[1]); +; m.m[2][1]=u[1]*u[2]*(1-cost)-u[0]*sint; +; m.m[0][2]=u[2]*u[0]*(1-cost)-u[1]*sint; +; m.m[1][2]=u[1]*u[2]*(1-cost)+u[0]*sint; +; m.m[2][2]=u[2]*u[2]+cost*(1-u[2]*u[2]); + .end_sw: + + mov eax,[context] + mov ebx,[eax+offs_cont_matrix_mode] + shl ebx,2 + add ebx,eax + stdcall gl_M4_MulLeft,dword[ebx+offs_cont_matrix_stack_ptr],ecx +if DEBUG ;glopRotete + stdcall gl_print_matrix,ecx,4 +end if + gl_matrix_update eax,ebx + .end_f: + ret +endp + +align 4 +proc glopScale uses eax ebx ecx, context:dword, p:dword + mov ecx,[p] + + mov eax,[context] + mov ebx,[eax+offs_cont_matrix_mode] + shl ebx,2 + add ebx,eax + mov ebx,[ebx+offs_cont_matrix_stack_ptr] ;ebx = &m[0] + + fld dword[ecx+ 4] ;x + fld dword[ecx+ 8] ;y + fld dword[ecx+12] ;z + mov ecx,4 + @@: + fld dword[ebx] ;m[0] + fmul st0,st3 ;m[0] * x + fstp dword[ebx] ;m[0] *= x + fld dword[ebx+4] ;m[1] + fmul st0,st2 ;m[1] * y + fstp dword[ebx+4];m[1] *= y + fld dword[ebx+8] ;m[2] + fmul st0,st1 ;m[2] * z + fstp dword[ebx+8];m[2] *= z + add ebx,16 + loop @b + +if DEBUG ;glopScale + mov ebx,[eax+offs_cont_matrix_mode] + shl ebx,2 + add ebx,eax + stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 +end if + gl_matrix_update eax,ebx + ret +endp + +align 4 +proc glopTranslate uses eax ebx ecx, context:dword, p:dword + mov ecx,[p] + + mov eax,[context] + mov ebx,[eax+offs_cont_matrix_mode] + shl ebx,2 + add ebx,eax + mov ebx,[ebx+offs_cont_matrix_stack_ptr] ;ebx = &m[0] + + fld dword[ecx+ 4] ;x + fld dword[ecx+ 8] ;y + fld dword[ecx+12] ;z + mov ecx,4 + @@: + fld dword[ebx] ;m[0] + fmul st0,st3 ;m[0] * x + fld dword[ebx+4] ;m[1] + fmul st0,st3 ;m[1] * y + fld dword[ebx+8] ;m[2] + fmul st0,st3 ;m[2] * z + fadd st0,st1 + fadd st0,st2 + fadd dword[ebx+12] ;m[3] + fstp dword[ebx+12] ;m[3] = m[0] * x + m[1] * y + m[2] * z + m[3] + ffree st0 + fincstp + ffree st0 + fincstp + add ebx,16 + loop @b + +if DEBUG ;glopTranslate + mov ebx,[eax+offs_cont_matrix_mode] + shl ebx,2 + add ebx,eax + stdcall gl_print_matrix,[ebx+offs_cont_matrix_stack_ptr],4 +end if + gl_matrix_update eax,ebx + ret +endp + +align 4 +proc glopFrustum uses eax ebx ecx, context:dword, p:dword +locals + x dd ? + y dd ? + A dd ? + B dd ? + C dd ? + D dd ? + m M4 +endl + mov eax,[context] + mov ebx,[p] + + fld dword[ebx+8] + fsub dword[ebx+4] ;st0 = (right-left) + fld dword[ebx+20] ;st0 = near + fadd st0,st0 + fdiv st0,st1 + fstp dword[x] ;x = (2.0*near) / (right-left) + fld dword[ebx+16] + fsub dword[ebx+12] ;st0 = (top-bottom) + fld dword[ebx+20] ;st0 = near + fadd st0,st0 + fdiv st0,st1 + fstp dword[y] ;y = (2.0*near) / (top-bottom) + fld dword[ebx+8] + fadd dword[ebx+4] ;st0 = (right+left) + fdiv st0,st2 ;st2 = (right-left) + fstp dword[A] ;A = (right+left) / (right-left) + fld dword[ebx+16] + fadd dword[ebx+12] ;st0 = (top+bottom) + fdiv st0,st1 ;st1 = (top-bottom) + fstp dword[B] ;B = (top+bottom) / (top-bottom) + fld dword[ebx+24] + fsub dword[ebx+20] ;st0 = (farp-near) + fldz + fsub dword[ebx+24] + fsub dword[ebx+20] ;st0 = -(farp+near) + fdiv st0,st1 + fstp dword[C] ;C = -(farp+near) / (farp-near) + fld dword[ebx+24] + fmul dword[ebx+20] ;st0 = farp*near + fadd st0,st0 + fchs ;st0 = -(2.0*farp*near) + fdiv st0,st1 + fstp dword[D] ;D = -(2.0*farp*near) / (farp-near) + + mov ecx,ebp + sub ecx,sizeof.M4 + + mov ebx,[x] + mov dword[ecx],ebx + mov dword[ecx+4],0.0 + mov ebx,[A] + mov dword[ecx+8],ebx + mov dword[ecx+12],0.0 + mov dword[ecx+16],0.0 + mov ebx,[y] + mov dword[ecx+20],ebx + mov ebx,[B] + mov dword[ecx+24],ebx + mov dword[ecx+28],0.0 + mov dword[ecx+32],0.0 + mov dword[ecx+36],0.0 + mov ebx,[C] + mov dword[ecx+40],ebx + mov ebx,[D] + mov dword[ecx+44],ebx + mov dword[ecx+48],0.0 + mov dword[ecx+52],0.0 + mov dword[ecx+56],-1.0 + mov dword[ecx+60],0.0 + + mov ebx,[eax+offs_cont_matrix_mode] + shl ebx,2 + add ebx,eax + stdcall gl_M4_MulLeft,dword[ebx+offs_cont_matrix_stack_ptr],ecx + +if DEBUG ;glopFrustum + stdcall gl_print_matrix,ecx,4 + stdcall gl_print_matrix,dword[ebx+offs_cont_matrix_stack_ptr],4 +end if + gl_matrix_update eax,ebx + ret +endp + + diff --git a/programs/develop/libraries/TinyGL/asm_fork/misc.asm b/programs/develop/libraries/TinyGL/asm_fork/misc.asm new file mode 100644 index 0000000000..83e82305df --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/misc.asm @@ -0,0 +1,273 @@ + +align 4 +proc glopViewport uses eax ebx ecx edx, context:dword, p:dword +locals + xsize dd ? ;int + ysize dd ? ;int + xmin dd ? ;int + ymin dd ? ;int + xsize_req dd ? ;int + ysize_req dd ? ;int +endl + mov edx,[context] + mov ebx,[p] + + mov ecx,[ebx+4] + mov [xmin],ecx + mov ecx,[ebx+8] + mov [ymin],ecx + mov ecx,[ebx+12] + mov [xsize],ecx + mov ecx,[ebx+16] + mov [ysize],ecx + + ; we may need to resize the zbuffer + + cmp dword[edx+offs_cont_viewport+offs_vpor_ysize],ecx + jne @f + mov ecx,[xmin] + cmp dword[edx+offs_cont_viewport+offs_vpor_xmin],ecx + jne @f + mov ecx,[ymin] + cmp dword[edx+offs_cont_viewport+offs_vpor_ymin],ecx + jne @f + mov ecx,[xsize] + cmp dword[edx+offs_cont_viewport+offs_vpor_xsize],ecx + jne @f + jmp .end_f + @@: + + mov ecx,[xmin] + add ecx,[xsize] + mov [xsize_req],ecx ;xsize_req = xmin + xsize + mov ecx,[ymin] + add ecx,[ysize] + mov [ysize_req],ecx ;ysize_req = ymin + ysize + + cmp dword[edx+offs_cont_gl_resize_viewport],0 + je @f + mov eax,ebp + sub eax,4 + push eax + sub eax,4 + push eax + stdcall dword[edx+offs_cont_gl_resize_viewport], edx ;gl_resize_viewport(context,&xsize_req,&ysize_req) + cmp eax,0 + je @f + stdcall dbg_print,f_vp,err_4 + @@: + + mov ecx,[xsize_req] + sub ecx,[xmin] + mov [xsize],ecx + mov ecx,[ysize_req] + sub ecx,[ymin] + mov [ysize],ecx + cmp ecx,0 + jg @f + cmp dword[xsize],0 + jg @f + stdcall dbg_print,f_vp,err_5 + @@: +if DEBUG ;glopViewport +push edi + mov ecx,80 + mov eax,[xmin] + lea edi,[buf_param] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[ymin] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[xsize] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[ysize] + stdcall convert_int_to_str,ecx + + stdcall str_n_cat,edi,txt_nl,2 + stdcall dbg_print,f_vp,buf_param +pop edi +end if + mov ecx,[xmin] + mov dword[edx+offs_cont_viewport+offs_vpor_xmin],ecx + mov ecx,[ymin] + mov dword[edx+offs_cont_viewport+offs_vpor_ymin],ecx + mov ecx,[xsize] + mov dword[edx+offs_cont_viewport+offs_vpor_xsize],ecx + mov ecx,[ysize] + mov dword[edx+offs_cont_viewport+offs_vpor_ysize],ecx + + mov dword[edx+offs_cont_viewport+offs_vpor_updated],1 + .end_f: + ret +endp + +align 4 +proc glopEnableDisable uses eax ebx ecx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ecx,[ebx+8] + mov ebx,[ebx+4] + + cmp ebx,GL_CULL_FACE + jne @f + mov [eax+offs_cont_cull_face_enabled],ecx + jmp .end_f + @@: + cmp ebx,GL_LIGHTING + jne @f + mov [eax+offs_cont_lighting_enabled],ecx + jmp .end_f + @@: + cmp ebx,GL_COLOR_MATERIAL + jne @f + mov [eax+offs_cont_color_material_enabled],ecx + jmp .end_f + @@: + cmp ebx,GL_TEXTURE_2D + jne @f + mov [eax+offs_cont_texture_2d_enabled],ecx + jmp .end_f + @@: + cmp ebx,GL_NORMALIZE + jne @f + mov [eax+offs_cont_normalize_enabled],ecx + jmp .end_f + @@: + cmp ebx,GL_DEPTH_TEST + jne @f + mov [eax+offs_cont_depth_test],ecx + jmp .end_f + @@: + cmp ebx,GL_POLYGON_OFFSET_FILL + jne .polygon_offset_fill + cmp ecx,0 + je @f + or dword[eax+offs_cont_offset_states],TGL_OFFSET_FILL + jmp .end_f + @@: + and dword[eax+offs_cont_offset_states],not TGL_OFFSET_FILL + jmp .end_f + .polygon_offset_fill: + cmp ebx,GL_POLYGON_OFFSET_POINT + jne .polygon_offset_point + cmp ecx,0 + je @f + or dword[eax+offs_cont_offset_states],TGL_OFFSET_POINT + jmp .end_f + @@: + and dword[eax+offs_cont_offset_states],not TGL_OFFSET_POINT + jmp .end_f + .polygon_offset_point: + cmp ebx,GL_POLYGON_OFFSET_LINE + jne .polygon_offset_line + cmp ecx,0 + je @f + or dword[eax+offs_cont_offset_states],TGL_OFFSET_LINE + jmp .end_f + @@: + and dword[eax+offs_cont_offset_states],not TGL_OFFSET_LINE + jmp .end_f + .polygon_offset_line: ;default: + cmp ebx,GL_LIGHT0 + jl .els_0 + cmp ebx,GL_LIGHT0+MAX_LIGHTS + jge .els_0 ;if (GL_LIGHT0 <= ebx < GL_LIGHT0+MAX_LIGHTS) + stdcall gl_enable_disable_light, eax,ebx-GL_LIGHT0,ecx + jmp .end_f + .els_0: +;//fprintf(stderr,"glEnableDisable: 0x%X not supported.\n",code); + .end_f: + ret +endp + +align 4 +proc glopShadeModel uses eax ebx, context:dword,p:dword + mov eax,[context] + mov ebx,[p] + mov ebx,[ebx+4] + mov [eax+offs_cont_current_shade_model],ebx + ret +endp + +align 4 +proc glopCullFace uses eax ebx, context:dword,p:dword + mov eax,[context] + mov ebx,[p] + mov ebx,[ebx+4] + mov [eax+offs_cont_current_cull_face],ebx + ret +endp + +align 4 +proc glopFrontFace uses eax ebx, context:dword,p:dword + mov eax,[context] + mov ebx,[p] + mov ebx,[ebx+4] + mov [eax+offs_cont_current_front_face],ebx + ret +endp + +align 4 +proc glopPolygonMode uses eax ebx, context:dword,p:dword + mov eax,[context] + mov ebx,[p] + + cmp dword[ebx+4],GL_BACK + jne @f + mov ebx,[ebx+8] + mov [eax+offs_cont_polygon_mode_back],ebx + jmp .end_f + @@: + cmp dword[ebx+4],GL_FRONT + jne @f + mov ebx,[ebx+8] + mov [eax+offs_cont_polygon_mode_front],ebx + jmp .end_f + @@: + cmp dword[ebx+4],GL_FRONT_AND_BACK + jne @f + mov ebx,[ebx+8] + mov [eax+offs_cont_polygon_mode_front],ebx + mov [eax+offs_cont_polygon_mode_back],ebx + jmp .end_f + @@: +; assert(0); + .end_f: + ret +endp + +align 4 +proc glopHint, context:dword,p:dword +if 0 +; int target=p[1].i; +; int mode=p[2].i; + + ; do nothing +end if + ret +endp + +align 4 +proc glopPolygonOffset uses eax ebx ecx, context:dword,p:dword + mov eax,[context] + mov ebx,[p] + mov ecx,[ebx+4] + mov [eax+offs_cont_offset_factor],ecx + mov ecx,[ebx+8] + mov [eax+offs_cont_offset_units],ecx + ret +endp \ No newline at end of file diff --git a/programs/develop/libraries/TinyGL/asm_fork/opengl_const.inc b/programs/develop/libraries/TinyGL/asm_fork/opengl_const.inc new file mode 100644 index 0000000000..ed2979b3f3 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/opengl_const.inc @@ -0,0 +1,1963 @@ +;GLtypes +GLenum equ dd +GLboolean equ db +GLbitfield equ dd +GLbyte equ db +GLshort equ dw +GLint equ dd +GLsizei equ dd +GLubyte equ db +GLushort equ dw +GLuint equ dd +GLfloat equ dd +GLclampf equ dd +GLdouble equ dq +GLclampd equ dq +;GLerrors +GL_NO_ERROR=0 +GL_INVALID_ENUM=$0500 +GL_INVALID_VALUE=$0501 +GL_INVALID_OPERATION=$0502 +GL_STACK_OVERFLOW=$0503 +GL_STACK_UNDERFLOW=$0504 +GL_OUT_OF_MEMORY=$0505 +;Attributebits +GL_CURRENT_BIT=$00000001 +GL_POINT_BIT=$00000002 +GL_LINE_BIT=$00000004 +GL_POLYGON_BIT=$00000008 +GL_POLYGON_STIPPLE_BIT=$00000010 +GL_PIXEL_MODE_BIT=$00000020 +GL_LIGHTING_BIT=$00000040 +GL_FOG_BIT=$00000080 +GL_DEPTH_BUFFER_BIT=$00000100 +GL_ACCUM_BUFFER_BIT=$00000200 +GL_STENCIL_BUFFER_BIT=$00000400 +GL_VIEWPORT_BIT=$00000800 +GL_TRANSFORM_BIT=$00001000 +GL_ENABLE_BIT=$00002000 +GL_COLOR_BUFFER_BIT=$00004000 +GL_HINT_BIT=$00008000 +GL_EVAL_BIT=$00010000 +GL_LIST_BIT=$00020000 +GL_TEXTURE_BIT=$00040000 +GL_SCISSOR_BIT=$00080000 +GL_ALL_ATTRIB_BITS=$000FFFFF +;Clientattributebits +GL_CLIENT_PIXEL_STORE_BIT=$00000001 +GL_CLIENT_VERTEX_ARRAY_BIT=$00000002 +GL_CLIENT_ALL_ATTRIB_BITS=$FFFFFFFF +;Booleanvalues +GL_FALSE=0 +GL_TRUE=1 +;Primitives +GL_POINTS=$0000 +GL_LINES=$0001 +GL_LINE_LOOP=$0002 +GL_LINE_STRIP=$0003 +GL_TRIANGLES=$0004 +GL_TRIANGLE_STRIP=$0005 +GL_TRIANGLE_FAN=$0006 +GL_QUADS=$0007 +GL_QUAD_STRIP=$0008 +GL_POLYGON=$0009 +;Blending +GL_ZERO=0 +GL_ONE=1 +GL_SRC_COLOR=$0300 +GL_ONE_MINUS_SRC_COLOR=$0301 +GL_SRC_ALPHA=$0302 +GL_ONE_MINUS_SRC_ALPHA=$0303 +GL_DST_ALPHA=$0304 +GL_ONE_MINUS_DST_ALPHA=$0305 +GL_DST_COLOR=$0306 +GL_ONE_MINUS_DST_COLOR=$0307 +GL_SRC_ALPHA_SATURATE=$0308 +GL_BLEND_DST=$0BE0 +GL_BLEND_SRC=$0BE1 +GL_BLEND=$0BE2 +;Blending(GL1.2ARBimaging) +GL_BLEND_COLOR=$8005 +GL_CONSTANT_COLOR=$8001 +GL_ONE_MINUS_CONSTANT_COLOR=$8002 +GL_CONSTANT_ALPHA=$8003 +GL_ONE_MINUS_CONSTANT_ALPHA=$8004 +GL_FUNC_ADD=$8006 +GL_MIN=$8007 +GL_MAX=$8008 +GL_FUNC_SUBTRACT=$800A +GL_FUNC_REVERSE_SUBTRACT=$800B +;Colortable(GL1.2ARBimaging) +GL_COLOR_TABLE=$80D0 +GL_POST_CONVOLUTION_COLOR_TABLE=$80D1 +GL_POST_COLOR_MATRIX_COLOR_TABLE=$80D2 +GL_PROXY_COLOR_TABLE=$80D3 +GL_PROXY_POST_CONVOLUTION_COLOR_TABLE=$80D4 +GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE=$80D5 +GL_COLOR_TABLE_SCALE=$80D6 +GL_COLOR_TABLE_BIAS=$80D7 +GL_COLOR_TABLE_FORMAT=$80D8 +GL_COLOR_TABLE_WIDTH=$80D9 +GL_COLOR_TABLE_RED_SIZE=$80DA +GL_COLOR_TABLE_GREEN_SIZE=$80DB +GL_COLOR_TABLE_BLUE_SIZE=$80DC +GL_COLOR_TABLE_ALPHA_SIZE=$80DD +GL_COLOR_TABLE_LUMINANCE_SIZE=$80DE +GL_COLOR_TABLE_INTENSITY_SIZE=$80DF +;Convolutions(GL1.2ARBimaging) +GL_CONVOLUTION_1D=$8010 +GL_CONVOLUTION_2D=$8011 +GL_SEPARABLE_2D=$8012 +GL_CONVOLUTION_BORDER_MODE=$8013 +GL_CONVOLUTION_FILTER_SCALE=$8014 +GL_CONVOLUTION_FILTER_BIAS=$8015 +GL_REDUCE=$8016 +GL_CONVOLUTION_FORMAT=$8017 +GL_CONVOLUTION_WIDTH=$8018 +GL_CONVOLUTION_HEIGHT=$8019 +GL_MAX_CONVOLUTION_WIDTH=$801A +GL_MAX_CONVOLUTION_HEIGHT=$801B +GL_POST_CONVOLUTION_RED_SCALE=$801C +GL_POST_CONVOLUTION_GREEN_SCALE=$801D +GL_POST_CONVOLUTION_BLUE_SCALE=$801E +GL_POST_CONVOLUTION_ALPHA_SCALE=$801F +GL_POST_CONVOLUTION_RED_BIAS=$8020 +GL_POST_CONVOLUTION_GREEN_BIAS=$8021 +GL_POST_CONVOLUTION_BLUE_BIAS=$8022 +GL_POST_CONVOLUTION_ALPHA_BIAS=$8023 +;Histogram(GL1.2ARBimaging) +GL_HISTOGRAM=$8024 +GL_PROXY_HISTOGRAM=$8025 +GL_HISTOGRAM_WIDTH=$8026 +GL_HISTOGRAM_FORMAT=$8027 +GL_HISTOGRAM_RED_SIZE=$8028 +GL_HISTOGRAM_GREEN_SIZE=$8029 +GL_HISTOGRAM_BLUE_SIZE=$802A +GL_HISTOGRAM_ALPHA_SIZE=$802B +GL_HISTOGRAM_LUMINANCE_SIZE=$802C +GL_HISTOGRAM_SINK=$802D +GL_MINMAX=$802E +GL_MINMAX_FORMAT=$802F +GL_MINMAX_SINK=$8030 +;Buffers +GL_NONE=0 +GL_FRONT_LEFT=$0400 +GL_FRONT_RIGHT=$0401 +GL_BACK_LEFT=$0402 +GL_BACK_RIGHT=$0403 +GL_FRONT=$0404 +GL_BACK=$0405 +GL_LEFT=$0406 +GL_RIGHT=$0407 +GL_FRONT_AND_BACK=$0408 +GL_AUX0=$0409 +GL_AUX1=$040A +GL_AUX2=$040B +GL_AUX3=$040C +GL_AUX_BUFFERS=$0C00 +GL_DRAW_BUFFER=$0C01 +GL_READ_BUFFER=$0C02 +GL_DOUBLEBUFFER=$0C32 +GL_STEREO=$0C33 +;Depthbuffer +GL_DEPTH_RANGE=$0B70 +GL_DEPTH_TEST=$0B71 +GL_DEPTH_WRITEMASK=$0B72 +GL_DEPTH_CLEAR_VALUE=$0B73 +GL_DEPTH_FUNC=$0B74 +GL_NEVER=$0200 +GL_LESS=$0201 +GL_ equ AL=$0202 +GL_L equ AL=$0203 +GL_GREATER=$0204 +GL_NOT equ AL=$0205 +GL_G equ AL=$0206 +GL_ALWAYS=$0207 +;Accumulationbuffer +GL_ACCUM=$0100 +GL_LOAD=$0101 +GL_RETURN=$0102 +GL_MULT=$0103 +GL_ADD=$0104 +GL_ACCUM_CLEAR_VALUE=$0B80 +;Feedbackbuffer +GL_FEEDBACK_BUFFER_POINTER=$0DF0 +GL_FEEDBACK_BUFFER_SIZE=$0DF1 +GL_FEEDBACK_BUFFER_TYPE=$0DF2 +;Feedbacktypes +GL_2D=$0600 +GL_3D=$0601 +GL_3D_COLOR=$0602 +GL_3D_COLOR_TEXTURE=$0603 +GL_4D_COLOR_TEXTURE=$0604 +;Feedbacktokens +GL_PASS_THROUGH_TOKEN=$0700 +GL_POINT_TOKEN=$0701 +GL_LINE_TOKEN=$0702 +GL_POLYGON_TOKEN=$0703 +GL_BITMAP_TOKEN=$0704 +GL_DRAW_PIXEL_TOKEN=$0705 +GL_COPY_PIXEL_TOKEN=$0706 +GL_LINE_RESET_TOKEN=$0707 +;Fog +GL_EXP=$0800 +GL_EXP2=$0801 +GL_FOG=$0B60 +GL_FOG_INDEX=$0B61 +GL_FOG_DENSITY=$0B62 +GL_FOG_START=$0B63 +GL_FOG_END=$0B64 +GL_FOG_MODE=$0B65 +GL_FOG_COLOR=$0B66 +;Pixelmode,transfer +GL_PIXEL_MAP_I_TO_I=$0C70 +GL_PIXEL_MAP_S_TO_S=$0C71 +GL_PIXEL_MAP_I_TO_R=$0C72 +GL_PIXEL_MAP_I_TO_G=$0C73 +GL_PIXEL_MAP_I_TO_B=$0C74 +GL_PIXEL_MAP_I_TO_A=$0C75 +GL_PIXEL_MAP_R_TO_R=$0C76 +GL_PIXEL_MAP_G_TO_G=$0C77 +GL_PIXEL_MAP_B_TO_B=$0C78 +GL_PIXEL_MAP_A_TO_A=$0C79 +;Vertexarrays +GL_VERTEX_ARRAY_POINTER=$808E +GL_NORMAL_ARRAY_POINTER=$808F +GL_COLOR_ARRAY_POINTER=$8090 +GL_INDEX_ARRAY_POINTER=$8091 +GL_TEXTURE_COORD_ARRAY_POINTER=$8092 +GL_EDGE_FLAG_ARRAY_POINTER=$8093 +;Stenciling +GL_STENCIL_TEST=$0B90 +GL_STENCIL_CLEAR_VALUE=$0B91 +GL_STENCIL_FUNC=$0B92 +GL_STENCIL_VALUE_MASK=$0B93 +GL_STENCIL_FAIL=$0B94 +GL_STENCIL_PASS_DEPTH_FAIL=$0B95 +GL_STENCIL_PASS_DEPTH_PASS=$0B96 +GL_STENCIL_REF=$0B97 +GL_STENCIL_WRITEMASK=$0B98 +GL_KEEP=$1E00 +GL_REPLACE=$1E01 +GL_INCR=$1E02 +GL_DECR=$1E03 +;Colormaterial +GL_COLOR_MATERIAL_FACE=$0B55 +GL_COLOR_MATERIAL_PARAMETER=$0B56 +GL_COLOR_MATERIAL=$0B57 +;Points +GL_POINT_SMOOTH=$0B10 +GL_POINT_SIZE=$0B11 +GL_POINT_SIZE_RANGE=$0B12 +GL_POINT_SIZE_GRANULARITY=$0B13 +;Lines +GL_LINE_SMOOTH=$0B20 +GL_LINE_WIDTH=$0B21 +GL_LINE_WIDTH_RANGE=$0B22 +GL_LINE_WIDTH_GRANULARITY=$0B23 +GL_LINE_STIPPLE=$0B24 +GL_LINE_STIPPLE_PATTERN=$0B25 +GL_LINE_STIPPLE_REPEAT=$0B26 +;Polygons +GL_POLYGON_MODE=$0B40 +GL_POLYGON_SMOOTH=$0B41 +GL_POLYGON_STIPPLE=$0B42 +GL_EDGE_FLAG=$0B43 +GL_CULL_FACE=$0B44 +GL_CULL_FACE_MODE=$0B45 +GL_FRONT_FACE=$0B46 +GL_CW=$0900 +GL_CCW=$0901 +GL_POINT=$1B00 +GL_LINE=$1B01 +GL_FILL=$1B02 +;Displaylists +GL_LIST_MODE=$0B30 +GL_LIST_BASE=$0B32 +GL_LIST_INDEX=$0B33 +GL_COMPILE=$1300 +GL_COMPILE_AND_EXECUTE=$1301 +;Lighting +GL_LIGHTING=$0B50 +GL_LIGHT_MODEL_LOCAL_VIEWER=$0B51 +GL_LIGHT_MODEL_TWO_SIDE=$0B52 +GL_LIGHT_MODEL_AMBIENT=$0B53 +GL_LIGHT_MODEL_COLOR_CONTROL=$81F8 +GL_SHADE_MODEL=$0B54 +GL_NORMALIZE=$0BA1 +GL_AMBIENT=$1200 +GL_DIFFUSE=$1201 +GL_SPECULAR=$1202 +GL_POSITION=$1203 +GL_SPOT_DIRECTION=$1204 +GL_SPOT_EXPONENT=$1205 +GL_SPOT_CUTOFF=$1206 +GL_CONSTANT_ATTENUATION=$1207 +GL_LINEAR_ATTENUATION=$1208 +GL_QUADRATIC_ATTENUATION=$1209 +GL_EMISSION=$1600 +GL_SHININESS=$1601 +GL_AMBIENT_AND_DIFFUSE=$1602 +GL_COLOR_INDEXES=$1603 +GL_FLAT=$1D00 +GL_SMOOTH=$1D01 +GL_LIGHT0=$4000 +GL_LIGHT1=$4001 +GL_LIGHT2=$4002 +GL_LIGHT3=$4003 +GL_LIGHT4=$4004 +GL_LIGHT5=$4005 +GL_LIGHT6=$4006 +GL_LIGHT7=$4007 +;Matrixmodes +GL_MATRIX_MODE=$0BA0 +GL_MODELVIEW=$1700 +GL_PROJECTION=$1701 +GL_TEXTURE=$1702 +;Gets +GL_CURRENT_COLOR=$0B00 +GL_CURRENT_INDEX=$0B01 +GL_CURRENT_NORMAL=$0B02 +GL_CURRENT_TEXTURE_COORDS=$0B03 +GL_CURRENT_RASTER_COLOR=$0B04 +GL_CURRENT_RASTER_INDEX=$0B05 +GL_CURRENT_RASTER_TEXTURE_COORDS=$0B06 +GL_CURRENT_RASTER_POSITION=$0B07 +GL_CURRENT_RASTER_POSITION_VALID=$0B08 +GL_CURRENT_RASTER_DISTANCE=$0B09 +GL_MAX_LIST_NESTING=$0B31 +GL_VIEWPORT=$0BA2 +GL_MODELVIEW_STACK_DEPTH=$0BA3 +GL_PROJECTION_STACK_DEPTH=$0BA4 +GL_TEXTURE_STACK_DEPTH=$0BA5 +GL_MODELVIEW_MATRIX=$0BA6 +GL_PROJECTION_MATRIX=$0BA7 +GL_TEXTURE_MATRIX=$0BA8 +GL_ATTRIB_STACK_DEPTH=$0BB0 +GL_CLIENT_ATTRIB_STACK_DEPTH=$0BB1 +GL_SINGLE_COLOR=$81F9 +GL_SEPARATE_SPECULAR_COLOR=$81FA +;Alphatesting +GL_ALPHA_TEST=$0BC0 +GL_ALPHA_TEST_FUNC=$0BC1 +GL_ALPHA_TEST_REF=$0BC2 +GL_LOGIC_OP_MODE=$0BF0 +GL_INDEX_LOGIC_OP=$0BF1 +GL_LOGIC_OP=$0BF1 +GL_COLOR_LOGIC_OP=$0BF2 +GL_SCISSOR_BOX=$0C10 +GL_SCISSOR_TEST=$0C11 +GL_INDEX_CLEAR_VALUE=$0C20 +GL_INDEX_WRITEMASK=$0C21 +GL_COLOR_CLEAR_VALUE=$0C22 +GL_COLOR_WRITEMASK=$0C23 +GL_INDEX_MODE=$0C30 +GL_RGBA_MODE=$0C31 +GL_RENDER_MODE=$0C40 +GL_PERSPECTIVE_CORRECTION_HINT=$0C50 +GL_POINT_SMOOTH_HINT=$0C51 +GL_LINE_SMOOTH_HINT=$0C52 +GL_POLYGON_SMOOTH_HINT=$0C53 +GL_FOG_HINT=$0C54 +GL_TEXTURE_GEN_S=$0C60 +GL_TEXTURE_GEN_T=$0C61 +GL_TEXTURE_GEN_R=$0C62 +GL_TEXTURE_GEN_Q=$0C63 +GL_PIXEL_MAP_I_TO_I_SIZE=$0CB0 +GL_PIXEL_MAP_S_TO_S_SIZE=$0CB1 +GL_PIXEL_MAP_I_TO_R_SIZE=$0CB2 +GL_PIXEL_MAP_I_TO_G_SIZE=$0CB3 +GL_PIXEL_MAP_I_TO_B_SIZE=$0CB4 +GL_PIXEL_MAP_I_TO_A_SIZE=$0CB5 +GL_PIXEL_MAP_R_TO_R_SIZE=$0CB6 +GL_PIXEL_MAP_G_TO_G_SIZE=$0CB7 +GL_PIXEL_MAP_B_TO_B_SIZE=$0CB8 +GL_PIXEL_MAP_A_TO_A_SIZE=$0CB9 +GL_UNPACK_SWAP_BYTES=$0CF0 +GL_UNPACK_LSB_FIRST=$0CF1 +GL_UNPACK_ROW_LENGTH=$0CF2 +GL_UNPACK_SKIP_ROWS=$0CF3 +GL_UNPACK_SKIP_PIXELS=$0CF4 +GL_UNPACK_ALIGNMENT=$0CF5 +GL_PACK_SWAP_BYTES=$0D00 +GL_PACK_LSB_FIRST=$0D01 +GL_PACK_ROW_LENGTH=$0D02 +GL_PACK_SKIP_ROWS=$0D03 +GL_PACK_SKIP_PIXELS=$0D04 +GL_PACK_ALIGNMENT=$0D05 +GL_PACK_SKIP_IMAGES=$806B +GL_PACK_IMAGE_HEIGHT=$806C +GL_UNPACK_SKIP_IMAGES=$806D +GL_UNPACK_IMAGE_HEIGHT=$806E +GL_MAP_COLOR=$0D10 +GL_MAP_STENCIL=$0D11 +GL_INDEX_SHIFT=$0D12 +GL_INDEX_OFFSET=$0D13 +GL_RED_SCALE=$0D14 +GL_RED_BIAS=$0D15 +GL_ZOOM_X=$0D16 +GL_ZOOM_Y=$0D17 +GL_GREEN_SCALE=$0D18 +GL_GREEN_BIAS=$0D19 +GL_BLUE_SCALE=$0D1A +GL_BLUE_BIAS=$0D1B +GL_ALPHA_SCALE=$0D1C +GL_ALPHA_BIAS=$0D1D +GL_DEPTH_SCALE=$0D1E +GL_DEPTH_BIAS=$0D1F +GL_MAX_EVAL_ORDER=$0D30 +GL_MAX_LIGHTS=$0D31 +GL_MAX_CLIP_PLANES=$0D32 +GL_MAX_TEXTURE_SIZE=$0D33 +GL_MAX_3D_TEXTURE_SIZE=$8073 +GL_MAX_PIXEL_MAP_TABLE=$0D34 +GL_MAX_ATTRIB_STACK_DEPTH=$0D35 +GL_MAX_MODELVIEW_STACK_DEPTH=$0D36 +GL_MAX_NAME_STACK_DEPTH=$0D37 +GL_MAX_PROJECTION_STACK_DEPTH=$0D38 +GL_MAX_TEXTURE_STACK_DEPTH=$0D39 +GL_MAX_VIEWPORT_DIMS=$0D3A +GL_MAX_CLIENT_ATTRIB_STACK_DEPTH=$0D3B +GL_MAX_ELEMENTS_VERTICES=$80E8 +GL_MAX_ELEMENTS_INDICES=$80E9 +GL_RESCALE_NORMAL=$803A +GL_SUBPIXEL_BITS=$0D50 +GL_INDEX_BITS=$0D51 +GL_RED_BITS=$0D52 +GL_GREEN_BITS=$0D53 +GL_BLUE_BITS=$0D54 +GL_ALPHA_BITS=$0D55 +GL_DEPTH_BITS=$0D56 +GL_STENCIL_BITS=$0D57 +GL_ACCUM_RED_BITS=$0D58 +GL_ACCUM_GREEN_BITS=$0D59 +GL_ACCUM_BLUE_BITS=$0D5A +GL_ACCUM_ALPHA_BITS=$0D5B +GL_NAME_STACK_DEPTH=$0D70 +GL_AUTO_NORMAL=$0D80 +GL_MAP1_COLOR_4=$0D90 +GL_MAP1_INDEX=$0D91 +GL_MAP1_NORMAL=$0D92 +GL_MAP1_TEXTURE_COORD_1=$0D93 +GL_MAP1_TEXTURE_COORD_2=$0D94 +GL_MAP1_TEXTURE_COORD_3=$0D95 +GL_MAP1_TEXTURE_COORD_4=$0D96 +GL_MAP1_VERTEX_3=$0D97 +GL_MAP1_VERTEX_4=$0D98 +GL_MAP2_COLOR_4=$0DB0 +GL_MAP2_INDEX=$0DB1 +GL_MAP2_NORMAL=$0DB2 +GL_MAP2_TEXTURE_COORD_1=$0DB3 +GL_MAP2_TEXTURE_COORD_2=$0DB4 +GL_MAP2_TEXTURE_COORD_3=$0DB5 +GL_MAP2_TEXTURE_COORD_4=$0DB6 +GL_MAP2_VERTEX_3=$0DB7 +GL_MAP2_VERTEX_4=$0DB8 +GL_MAP1_GRID_DOMAIN=$0DD0 +GL_MAP1_GRID_SEGMENTS=$0DD1 +GL_MAP2_GRID_DOMAIN=$0DD2 +GL_MAP2_GRID_SEGMENTS=$0DD3 +GL_TEXTURE_1D=$0DE0 +GL_TEXTURE_2D=$0DE1 +GL_TEXTURE_3D=$806F +GL_SELECTION_BUFFER_POINTER=$0DF3 +GL_SELECTION_BUFFER_SIZE=$0DF4 +GL_POLYGON_OFFSET_UNITS=$2A00 +GL_POLYGON_OFFSET_POINT=$2A01 +GL_POLYGON_OFFSET_LINE=$2A02 +GL_POLYGON_OFFSET_FILL=$8037 +GL_POLYGON_OFFSET_FACTOR=$8038 +GL_TEXTURE_BINDING_1D=$8068 +GL_TEXTURE_BINDING_2D=$8069 +GL_VERTEX_ARRAY=$8074 +GL_NORMAL_ARRAY=$8075 +GL_COLOR_ARRAY=$8076 +GL_INDEX_ARRAY=$8077 +GL_TEXTURE_COORD_ARRAY=$8078 +GL_EDGE_FLAG_ARRAY=$8079 +GL_VERTEX_ARRAY_SIZE=$807A +GL_VERTEX_ARRAY_TYPE=$807B +GL_VERTEX_ARRAY_STRIDE=$807C +GL_NORMAL_ARRAY_TYPE=$807E +GL_NORMAL_ARRAY_STRIDE=$807F +GL_COLOR_ARRAY_SIZE=$8081 +GL_COLOR_ARRAY_TYPE=$8082 +GL_COLOR_ARRAY_STRIDE=$8083 +GL_INDEX_ARRAY_TYPE=$8085 +GL_INDEX_ARRAY_STRIDE=$8086 +GL_TEXTURE_COORD_ARRAY_SIZE=$8088 +GL_TEXTURE_COORD_ARRAY_TYPE=$8089 +GL_TEXTURE_COORD_ARRAY_STRIDE=$808A +GL_EDGE_FLAG_ARRAY_STRIDE=$808C +GL_COLOR_MATRIX=$80B1 +GL_COLOR_MATRIX_STACK_DEPTH=$80B2 +GL_MAX_COLOR_MATRIX_STACK_DEPTH=$80B3 +GL_POST_COLOR_MATRIX_RED_SCALE=$80B4 +GL_POST_COLOR_MATRIX_GREEN_SCALE=$80B5 +GL_POST_COLOR_MATRIX_BLUE_SCALE=$80B6 +GL_POST_COLOR_MATRIX_ALPHA_SCALE=$80B7 +GL_POST_COLOR_MATRIX_RED_BIAS=$80B8 +GL_POST_COLOR_MATRIX_GREEN_BIAS=$80B9 +GL_POST_COLOR_MATRIX_BLUE_BIAS=$80BA +GL_POST_COLOR_MATRIX_ALPHA_BIAS=$80BB +;Evaluators +GL_COEFF=$0A00 +GL_ORDER=$0A01 +GL_DOMAIN=$0A02 +;Texturemapping +GL_TEXTURE_WIDTH=$1000 +GL_TEXTURE_HEIGHT=$1001 +GL_TEXTURE_INTERNAL_FORMAT=$1003 +GL_TEXTURE_COMPONENTS=$1003 +GL_TEXTURE_BORDER_COLOR=$1004 +GL_TEXTURE_BORDER=$1005 +GL_TEXTURE_RED_SIZE=$805C +GL_TEXTURE_GREEN_SIZE=$805D +GL_TEXTURE_BLUE_SIZE=$805E +GL_TEXTURE_ALPHA_SIZE=$805F +GL_TEXTURE_LUMINANCE_SIZE=$8060 +GL_TEXTURE_INTENSITY_SIZE=$8061 +GL_TEXTURE_PRIORITY=$8066 +GL_TEXTURE_RESIDENT=$8067 +GL_BGR=$80E0 +GL_BGRA=$80E1 +GL_S=$2000 +GL_T=$2001 +GL_R=$2002 +GL_Q=$2003 +GL_MODULATE=$2100 +GL_DECAL=$2101 +GL_TEXTURE_ENV_MODE=$2200 +GL_TEXTURE_ENV_COLOR=$2201 +GL_TEXTURE_ENV=$2300 +GL_EYE_LINEAR=$2400 +GL_OBJECT_LINEAR=$2401 +GL_SPHERE_MAP=$2402 +GL_TEXTURE_GEN_MODE=$2500 +GL_OBJECT_PLANE=$2501 +GL_EYE_PLANE=$2502 +GL_NEAREST=$2600 +GL_LINEAR=$2601 +GL_NEAREST_MIPMAP_NEAREST=$2700 +GL_LINEAR_MIPMAP_NEAREST=$2701 +GL_NEAREST_MIPMAP_LINEAR=$2702 +GL_LINEAR_MIPMAP_LINEAR=$2703 +GL_TEXTURE_MAG_FILTER=$2800 +GL_TEXTURE_MIN_FILTER=$2801 +GL_TEXTURE_WRAP_R=$8072 +GL_TEXTURE_WRAP_S=$2802 +GL_TEXTURE_WRAP_T=$2803 +GL_CLAMP_TO_EDGE=$812F +GL_TEXTURE_MIN_LOD=$813A +GL_TEXTURE_MAX_LOD=$813B +GL_TEXTURE_BASE_LEVEL=$813C +GL_TEXTURE_MAX_LEVEL=$813D +GL_TEXTURE_DEPTH=$8071 +GL_PROXY_TEXTURE_1D=$8063 +GL_PROXY_TEXTURE_2D=$8064 +GL_PROXY_TEXTURE_3D=$8070 +GL_CLAMP=$2900 +GL_REPEAT=$2901 +;Hints +GL_DONT_CARE=$1100 +GL_FASTEST=$1101 +GL_NICEST=$1102 +;Datatypes +GL_BYTE=$1400 +GL_UNSIGNED_BYTE=$1401 +GL_SHORT=$1402 +GL_UNSIGNED_SHORT=$1403 +GL_INT=$1404 +GL_UNSIGNED_INT=$1405 +GL_FLOAT=$1406 +GL_2_BYTES=$1407 +GL_3_BYTES=$1408 +GL_4_BYTES=$1409 +GL_DOUBLE=$140A +GL_DOUBLE_EXT=$140A +;Logicoperations +GL_CLEAR=$1500 +GL_AND=$1501 +GL_AND_REVERSE=$1502 +GL_COPY=$1503 +GL_AND_INVERTED=$1504 +GL_NOOP=$1505 +GL_XOR=$1506 +GL_OR=$1507 +GL_NOR=$1508 +GL_ equ IV=$1509 +GL_INVERT=$150A +GL_OR_REVERSE=$150B +GL_COPY_INVERTED=$150C +GL_OR_INVERTED=$150D +GL_NAND=$150E +GL_SET=$150F +;PixelCopyType +GL_COLOR=$1800 +GL_DEPTH=$1801 +GL_STENCIL=$1802 +;Pixelformats +GL_COLOR_INDEX=$1900 +GL_STENCIL_INDEX=$1901 +GL_DEPTH_COMPONENT=$1902 +GL_RED=$1903 +GL_GREEN=$1904 +GL_BLUE=$1905 +GL_ALPHA=$1906 +GL_RGB=$1907 +GL_RGBA=$1908 +GL_LUMINANCE=$1909 +GL_LUMINANCE_ALPHA=$190A +;Pixeltype +GL_BITMAP=$1A00 +;Renderingmodes +GL_RENDER=$1C00 +GL_FEEDBACK=$1C01 +GL_SELECT=$1C02 +;Implementationstrings +GL_VENDOR=$1F00 +GL_RENDERER=$1F01 +GL_VERSION=$1F02 +GL_EXTENSIONS=$1F03 +;Pixelformats +GL_R3_G3_B2=$2A10 +GL_ALPHA4=$803B +GL_ALPHA8=$803C +GL_ALPHA12=$803D +GL_ALPHA16=$803E +GL_LUMINANCE4=$803F +GL_LUMINANCE8=$8040 +GL_LUMINANCE12=$8041 +GL_LUMINANCE16=$8042 +GL_LUMINANCE4_ALPHA4=$8043 +GL_LUMINANCE6_ALPHA2=$8044 +GL_LUMINANCE8_ALPHA8=$8045 +GL_LUMINANCE12_ALPHA4=$8046 +GL_LUMINANCE12_ALPHA12=$8047 +GL_LUMINANCE16_ALPHA16=$8048 +GL_INTENSITY=$8049 +GL_INTENSITY4=$804A +GL_INTENSITY8=$804B +GL_INTENSITY12=$804C +GL_INTENSITY16=$804D +GL_RGB4=$804F +GL_RGB5=$8050 +GL_RGB8=$8051 +GL_RGB10=$8052 +GL_RGB12=$8053 +GL_RGB16=$8054 +GL_RGBA2=$8055 +GL_RGBA4=$8056 +GL_RGB5_A1=$8057 +GL_RGBA8=$8058 +GL_RGB10_A2=$8059 +GL_RGBA12=$805A +GL_RGBA16=$805B +UNSIGNED_BYTE_3_3_2=$8032 +UNSIGNED_BYTE_2_3_3_REV=$8362 +UNSIGNED_SHORT_5_6_5=$8363 +UNSIGNED_SHORT_5_6_5_REV=$8364 +UNSIGNED_SHORT_4_4_4_4=$8033 +UNSIGNED_SHORT_4_4_4_4_REV=$8365 +UNSIGNED_SHORT_5_5_5_1=$8034 +UNSIGNED_SHORT_1_5_5_5_REV=$8366 +UNSIGNED_INT_8_8_8_8=$8035 +UNSIGNED_INT_8_8_8_8_REV=$8367 +UNSIGNED_INT_10_10_10_2=$8036 +UNSIGNED_INT_2_10_10_10_REV=$8368 +;Interleavedarraysformats +GL_V2F=$2A20 +GL_V3F=$2A21 +GL_C4UB_V2F=$2A22 +GL_C4UB_V3F=$2A23 +GL_C3F_V3F=$2A24 +GL_N3F_V3F=$2A25 +GL_C4F_N3F_V3F=$2A26 +GL_T2F_V3F=$2A27 +GL_T4F_V4F=$2A28 +GL_T2F_C4UB_V3F=$2A29 +GL_T2F_C3F_V3F=$2A2A +GL_T2F_N3F_V3F=$2A2B +GL_T2F_C4F_N3F_V3F=$2A2C +GL_T4F_C4F_N3F_V4F=$2A2D +;Clipplanes +GL_CLIP_PLANE0=$3000 +GL_CLIP_PLANE1=$3001 +GL_CLIP_PLANE2=$3002 +GL_CLIP_PLANE3=$3003 +GL_CLIP_PLANE4=$3004 +GL_CLIP_PLANE5=$3005 +;Miscellaneous +GL_DITHER=$0BD0 +;EXT_abgr +GL_ABGR_EXT=$8000 +;EXT_packed_pixels +GL_UNSIGNED_BYTE_3_3_2_EXT=$8032 +GL_UNSIGNED_SHORT_4_4_4_4_EXT=$8033 +GL_UNSIGNED_SHORT_5_5_5_1_EXT=$8034 +GL_UNSIGNED_INT_8_8_8_8_EXT=$8035 +GL_UNSIGNED_INT_10_10_10_2_EXT=$8036 +;EXT_vertex_array +GL_VERTEX_ARRAY_EXT=$8074 +GL_NORMAL_ARRAY_EXT=$8075 +GL_COLOR_ARRAY_EXT=$8076 +GL_INDEX_ARRAY_EXT=$8077 +GL_TEXTURE_COORD_ARRAY_EXT=$8078 +GL_EDGE_FLAG_ARRAY_EXT=$8079 +GL_VERTEX_ARRAY_SIZE_EXT=$807A +GL_VERTEX_ARRAY_TYPE_EXT=$807B +GL_VERTEX_ARRAY_STRIDE_EXT=$807C +GL_VERTEX_ARRAY_COUNT_EXT=$807D +GL_NORMAL_ARRAY_TYPE_EXT=$807E +GL_NORMAL_ARRAY_STRIDE_EXT=$807F +GL_NORMAL_ARRAY_COUNT_EXT=$8080 +GL_COLOR_ARRAY_SIZE_EXT=$8081 +GL_COLOR_ARRAY_TYPE_EXT=$8082 +GL_COLOR_ARRAY_STRIDE_EXT=$8083 +GL_COLOR_ARRAY_COUNT_EXT=$8084 +GL_INDEX_ARRAY_TYPE_EXT=$8085 +GL_INDEX_ARRAY_STRIDE_EXT=$8086 +GL_INDEX_ARRAY_COUNT_EXT=$8087 +GL_TEXTURE_COORD_ARRAY_SIZE_EXT=$8088 +GL_TEXTURE_COORD_ARRAY_TYPE_EXT=$8089 +GL_TEXTURE_COORD_ARRAY_STRIDE_EXT=$808A +GL_TEXTURE_COORD_ARRAY_COUNT_EXT=$808B +GL_EDGE_FLAG_ARRAY_STRIDE_EXT=$808C +GL_EDGE_FLAG_ARRAY_COUNT_EXT=$808D +GL_VERTEX_ARRAY_POINTER_EXT=$808E +GL_NORMAL_ARRAY_POINTER_EXT=$808F +GL_COLOR_ARRAY_POINTER_EXT=$8090 +GL_INDEX_ARRAY_POINTER_EXT=$8091 +GL_TEXTURE_COORD_ARRAY_POINTER_EXT=$8092 +GL_EDGE_FLAG_ARRAY_POINTER_EXT=$8093 +;EXT_color_table +GL_TABLE_TOO_LARGE_EXT=$8031 +GL_COLOR_TABLE_EXT=$80D0 +GL_POST_CONVOLUTION_COLOR_TABLE_EXT=$80D1 +GL_POST_COLOR_MATRIX_COLOR_TABLE_EXT=$80D2 +GL_PROXY_COLOR_TABLE_EXT=$80D3 +GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_EXT=$80D4 +GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_EXT=$80D5 +GL_COLOR_TABLE_SCALE_EXT=$80D6 +GL_COLOR_TABLE_BIAS_EXT=$80D7 +GL_COLOR_TABLE_FORMAT_EXT=$80D8 +GL_COLOR_TABLE_WIDTH_EXT=$80D9 +GL_COLOR_TABLE_RED_SIZE_EXT=$80DA +GL_COLOR_TABLE_GREEN_SIZE_EXT=$80DB +GL_COLOR_TABLE_BLUE_SIZE_EXT=$80DC +GL_COLOR_TABLE_ALPHA_SIZE_EXT=$80DD +GL_COLOR_TABLE_LUMINANCE_SIZE_EXT=$80DE +GL_COLOR_TABLE_INTENSITY_SIZE_EXT=$80DF +;EXT_bgra +GL_BGR_EXT=$80E0 +GL_BGRA_EXT=$80E1 +;EXT_paletted_texture +GL_COLOR_INDEX1_EXT=$80E2 +GL_COLOR_INDEX2_EXT=$80E3 +GL_COLOR_INDEX4_EXT=$80E4 +GL_COLOR_INDEX8_EXT=$80E5 +GL_COLOR_INDEX12_EXT=$80E6 +GL_COLOR_INDEX16_EXT=$80E7 +;EXT_blend_color +GL_CONSTANT_COLOR_EXT=$8001 +GL_ONE_MINUS_CONSTANT_COLOR_EXT=$8002 +GL_CONSTANT_ALPHA_EXT=$8003 +GL_ONE_MINUS_CONSTANT_ALPHA_EXT=$8004 +GL_BLEND_COLOR_EXT=$8005 +;EXT_blend_minmax +GL_FUNC_ADD_EXT=$8006 +GL_MIN_EXT=$8007 +GL_MAX_EXT=$8008 +GL_BLEND_ equ ATION_EXT=$8009 +;EXT_blend_subtract +GL_FUNC_SUBTRACT_EXT=$800A +GL_FUNC_REVERSE_SUBTRACT_EXT=$800B +;EXT_convolution +GL_CONVOLUTION_1D_EXT=$8010 +GL_CONVOLUTION_2D_EXT=$8011 +GL_SEPARABLE_2D_EXT=$8012 +GL_CONVOLUTION_BORDER_MODE_EXT=$8013 +GL_CONVOLUTION_FILTER_SCALE_EXT=$8014 +GL_CONVOLUTION_FILTER_BIAS_EXT=$8015 +GL_REDUCE_EXT=$8016 +GL_CONVOLUTION_FORMAT_EXT=$8017 +GL_CONVOLUTION_WIDTH_EXT=$8018 +GL_CONVOLUTION_HEIGHT_EXT=$8019 +GL_MAX_CONVOLUTION_WIDTH_EXT=$801A +GL_MAX_CONVOLUTION_HEIGHT_EXT=$801B +GL_POST_CONVOLUTION_RED_SCALE_EXT=$801C +GL_POST_CONVOLUTION_GREEN_SCALE_EXT=$801D +GL_POST_CONVOLUTION_BLUE_SCALE_EXT=$801E +GL_POST_CONVOLUTION_ALPHA_SCALE_EXT=$801F +GL_POST_CONVOLUTION_RED_BIAS_EXT=$8020 +GL_POST_CONVOLUTION_GREEN_BIAS_EXT=$8021 +GL_POST_CONVOLUTION_BLUE_BIAS_EXT=$8022 +GL_POST_CONVOLUTION_ALPHA_BIAS_EXT=$8023 +;EXT_histogram +GL_HISTOGRAM_EXT=$8024 +GL_PROXY_HISTOGRAM_EXT=$8025 +GL_HISTOGRAM_WIDTH_EXT=$8026 +GL_HISTOGRAM_FORMAT_EXT=$8027 +GL_HISTOGRAM_RED_SIZE_EXT=$8028 +GL_HISTOGRAM_GREEN_SIZE_EXT=$8029 +GL_HISTOGRAM_BLUE_SIZE_EXT=$802A +GL_HISTOGRAM_ALPHA_SIZE_EXT=$802B +GL_HISTOGRAM_LUMINANCE_SIZE_EXT=$802C +GL_HISTOGRAM_SINK_EXT=$802D +GL_MINMAX_EXT=$802E +GL_MINMAX_FORMAT_EXT=$802F +GL_MINMAX_SINK_EXT=$8030 +;EXT_polygon_offset +GL_POLYGON_OFFSET_EXT=$8037 +GL_POLYGON_OFFSET_FACTOR_EXT=$8038 +GL_POLYGON_OFFSET_BIAS_EXT=$8039 +;EXT_texture +GL_ALPHA4_EXT=$803B +GL_ALPHA8_EXT=$803C +GL_ALPHA12_EXT=$803D +GL_ALPHA16_EXT=$803E +GL_LUMINANCE4_EXT=$803F +GL_LUMINANCE8_EXT=$8040 +GL_LUMINANCE12_EXT=$8041 +GL_LUMINANCE16_EXT=$8042 +GL_LUMINANCE4_ALPHA4_EXT=$8043 +GL_LUMINANCE6_ALPHA2_EXT=$8044 +GL_LUMINANCE8_ALPHA8_EXT=$8045 +GL_LUMINANCE12_ALPHA4_EXT=$8046 +GL_LUMINANCE12_ALPHA12_EXT=$8047 +GL_LUMINANCE16_ALPHA16_EXT=$8048 +GL_INTENSITY_EXT=$8049 +GL_INTENSITY4_EXT=$804A +GL_INTENSITY8_EXT=$804B +GL_INTENSITY12_EXT=$804C +GL_INTENSITY16_EXT=$804D +GL_RGB2_EXT=$804E +GL_RGB4_EXT=$804F +GL_RGB5_EXT=$8050 +GL_RGB8_EXT=$8051 +GL_RGB10_EXT=$8052 +GL_RGB12_EXT=$8053 +GL_RGB16_EXT=$8054 +GL_RGBA2_EXT=$8055 +GL_RGBA4_EXT=$8056 +GL_RGB5_A1_EXT=$8057 +GL_RGBA8_EXT=$8058 +GL_RGB10_A2_EXT=$8059 +GL_RGBA12_EXT=$805A +GL_RGBA16_EXT=$805B +GL_TEXTURE_RED_SIZE_EXT=$805C +GL_TEXTURE_GREEN_SIZE_EXT=$805D +GL_TEXTURE_BLUE_SIZE_EXT=$805E +GL_TEXTURE_ALPHA_SIZE_EXT=$805F +GL_TEXTURE_LUMINANCE_SIZE_EXT=$8060 +GL_TEXTURE_INTENSITY_SIZE_EXT=$8061 +GL_REPLACE_EXT=$8062 +GL_PROXY_TEXTURE_1D_EXT=$8063 +GL_PROXY_TEXTURE_2D_EXT=$8064 +GL_TEXTURE_TOO_LARGE_EXT=$8065 +;EXT_texture_object +GL_TEXTURE_PRIORITY_EXT=$8066 +GL_TEXTURE_RESIDENT_EXT=$8067 +GL_TEXTURE_1D_BINDING_EXT=$8068 +GL_TEXTURE_2D_BINDING_EXT=$8069 +GL_TEXTURE_3D_BINDING_EXT=$806A +;EXT_texture3D +GL_PACK_SKIP_IMAGES_EXT=$806B +GL_PACK_IMAGE_HEIGHT_EXT=$806C +GL_UNPACK_SKIP_IMAGES_EXT=$806D +GL_UNPACK_IMAGE_HEIGHT_EXT=$806E +GL_TEXTURE_3D_EXT=$806F +GL_PROXY_TEXTURE_3D_EXT=$8070 +GL_TEXTURE_DEPTH_EXT=$8071 +GL_TEXTURE_WRAP_R_EXT=$8072 +GL_MAX_3D_TEXTURE_SIZE_EXT=$8073 +;SGI_color_matrix +GL_COLOR_MATRIX_SGI=$80B1 +GL_COLOR_MATRIX_STACK_DEPTH_SGI=$80B2 +GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI=$80B3 +GL_POST_COLOR_MATRIX_RED_SCALE_SGI=$80B4 +GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI=$80B5 +GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI=$80B6 +GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI=$80B7 +GL_POST_COLOR_MATRIX_RED_BIAS_SGI=$80B8 +GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI=$80B9 +GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI=$80BA +GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI=$80BB +;SGI_texture_color_table +GL_TEXTURE_COLOR_TABLE_SGI=$80BC +GL_PROXY_TEXTURE_COLOR_TABLE_SGI=$80BD +GL_TEXTURE_COLOR_TABLE_BIAS_SGI=$80BE +GL_TEXTURE_COLOR_TABLE_SCALE_SGI=$80BF +;SGI_color_table +GL_COLOR_TABLE_SGI=$80D0 +GL_POST_CONVOLUTION_COLOR_TABLE_SGI=$80D1 +GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI=$80D2 +GL_PROXY_COLOR_TABLE_SGI=$80D3 +GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI=$80D4 +GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI=$80D5 +GL_COLOR_TABLE_SCALE_SGI=$80D6 +GL_COLOR_TABLE_BIAS_SGI=$80D7 +GL_COLOR_TABLE_FORMAT_SGI=$80D8 +GL_COLOR_TABLE_WIDTH_SGI=$80D9 +GL_COLOR_TABLE_RED_SIZE_SGI=$80DA +GL_COLOR_TABLE_GREEN_SIZE_SGI=$80DB +GL_COLOR_TABLE_BLUE_SIZE_SGI=$80DC +GL_COLOR_TABLE_ALPHA_SIZE_SGI=$80DD +GL_COLOR_TABLE_LUMINANCE_SIZE_SGI=$80DE +GL_COLOR_TABLE_INTENSITY_SIZE_SGI=$80DF +;EXT_cmyka +GL_CMYK_EXT=$800C +GL_CMYKA_EXT=$800D +GL_PACK_CMYK_HINT_EXT=$800E +GL_UNPACK_CMYK_HINT_EXT=$800F +;EXT_rescale_normal +GL_RESCALE_NORMAL_EXT=$803A +;EXT_clip_volume_hint +GL_CLIP_VOLUME_CLIPPING_HINT_EXT=$80F0 +;EXT_cull_vertex +GL_CULL_VERTEX_EXT=$81AA +GL_CULL_VERTEX_EYE_POSITION_EXT=$81AB +GL_CULL_VERTEX_OBJECT_POSITION_EXT=$81AC +;EXT_index_array_formats +GL_IUI_V2F_EXT=$81AD +GL_IUI_V3F_EXT=$81AE +GL_IUI_N3F_V2F_EXT=$81AF +GL_IUI_N3F_V3F_EXT=$81B0 +GL_T2F_IUI_V2F_EXT=$81B1 +GL_T2F_IUI_V3F_EXT=$81B2 +GL_T2F_IUI_N3F_V2F_EXT=$81B3 +GL_T2F_IUI_N3F_V3F_EXT=$81B4 +;EXT_index_func +GL_INDEX_TEST_EXT=$81B5 +GL_INDEX_TEST_FUNC_EXT=$81B6 +GL_INDEX_TEST_REF_EXT=$81B7 +;EXT_index_material +GL_INDEX_MATERIAL_EXT=$81B8 +GL_INDEX_MATERIAL_PARAMETER_EXT=$81B9 +GL_INDEX_MATERIAL_FACE_EXT=$81BA +;EXT_shared_texture_palette +GL_SHARED_TEXTURE_PALETTE_EXT=$81FB +;EXT_nurbs_tessellator +GLU_NURBS_MODE_EXT=100160 +GLU_NURBS_TESSELLATOR_EXT=100161 +GLU_NURBS_RENDERER_EXT=100162 +GLU_NURBS_BEGIN_EXT=100164 +GLU_NURBS_VERTEX_EXT=100165 +GLU_NURBS_NORMAL_EXT=100166 +GLU_NURBS_COLOR_EXT=100167 +GLU_NURBS_TEX_COORD_EXT=100168 +GLU_NURBS_END_EXT=100169 +GLU_NURBS_BEGIN_DATA_EXT=100170 +GLU_NURBS_VERTEX_DATA_EXT=100171 +GLU_NURBS_NORMAL_DATA_EXT=100172 +GLU_NURBS_COLOR_DATA_EXT=100173 +GLU_NURBS_TEX_COORD_DATA_EXT=100174 +GLU_NURBS_END_DATA_EXT=100175 +;EXT_object_space_tess +GLU_OBJECT_PARAMETRIC_ERROR_EXT=100208 +GLU_OBJECT_PATH_LENGTH_EXT=100209 +;EXT_point_parameters +GL_POINT_SIZE_MIN_EXT=$8126 +GL_POINT_SIZE_MAX_EXT=$8127 +GL_POINT_FADE_THRESHOLD_SIZE_EXT=$8128 +GL_DISTANCE_ATTENUATION_EXT=$8129 +;EXT_compiled_vertex_array +GL_ARRAY_ELEMENT_LOCK_FIRST_EXT=$81A8 +GL_ARRAY_ELEMENT_LOCK_COUNT_EXT=$81A9 +;ARB_multitexture +GL_ACTIVE_TEXTURE_ARB=$84E0 +GL_CLIENT_ACTIVE_TEXTURE_ARB=$84E1 +GL_MAX_TEXTURE_UNITS_ARB=$84E2 +GL_TEXTURE0_ARB=$84C0 +GL_TEXTURE1_ARB=$84C1 +GL_TEXTURE2_ARB=$84C2 +GL_TEXTURE3_ARB=$84C3 +GL_TEXTURE4_ARB=$84C4 +GL_TEXTURE5_ARB=$84C5 +GL_TEXTURE6_ARB=$84C6 +GL_TEXTURE7_ARB=$84C7 +GL_TEXTURE8_ARB=$84C8 +GL_TEXTURE9_ARB=$84C9 +GL_TEXTURE10_ARB=$84CA +GL_TEXTURE11_ARB=$84CB +GL_TEXTURE12_ARB=$84CC +GL_TEXTURE13_ARB=$84CD +GL_TEXTURE14_ARB=$84CE +GL_TEXTURE15_ARB=$84CF +GL_TEXTURE16_ARB=$84D0 +GL_TEXTURE17_ARB=$84D1 +GL_TEXTURE18_ARB=$84D2 +GL_TEXTURE19_ARB=$84D3 +GL_TEXTURE20_ARB=$84D4 +GL_TEXTURE21_ARB=$84D5 +GL_TEXTURE22_ARB=$84D6 +GL_TEXTURE23_ARB=$84D7 +GL_TEXTURE24_ARB=$84D8 +GL_TEXTURE25_ARB=$84D9 +GL_TEXTURE26_ARB=$84DA +GL_TEXTURE27_ARB=$84DB +GL_TEXTURE28_ARB=$84DC +GL_TEXTURE29_ARB=$84DD +GL_TEXTURE30_ARB=$84DE +GL_TEXTURE31_ARB=$84DF +;EXT_stencil_wrap +GL_INCR_WRAP_EXT=$8507 +GL_DECR_WRAP_EXT=$8508 +;NV_texgen_reflection +GL_NORMAL_MAP_NV=$8511 +GL_REFLECTION_MAP_NV=$8512 +;EXT_texture_env_combine +GL_COMBINE_EXT=$8570 +GL_COMBINE_RGB_EXT=$8571 +GL_COMBINE_ALPHA_EXT=$8572 +GL_RGB_SCALE_EXT=$8573 +GL_ADD_SIGNED_EXT=$8574 +GL_INTERPOLATE_EXT=$8575 +GL_CONSTANT_EXT=$8576 +GL_PRIMARY_COLOR_EXT=$8577 +GL_PREVIOUS_EXT=$8578 +GL_SOURCE0_RGB_EXT=$8580 +GL_SOURCE1_RGB_EXT=$8581 +GL_SOURCE2_RGB_EXT=$8582 +GL_SOURCE0_ALPHA_EXT=$8588 +GL_SOURCE1_ALPHA_EXT=$8589 +GL_SOURCE2_ALPHA_EXT=$858A +GL_OPERAND0_RGB_EXT=$8590 +GL_OPERAND1_RGB_EXT=$8591 +GL_OPERAND2_RGB_EXT=$8592 +GL_OPERAND0_ALPHA_EXT=$8598 +GL_OPERAND1_ALPHA_EXT=$8599 +GL_OPERAND2_ALPHA_EXT=$859A +;NV_texture_env_combine4 +GL_COMBINE4_NV=$8503 +GL_SOURCE3_RGB_NV=$8583 +GL_SOURCE3_ALPHA_NV=$858B +GL_OPERAND3_RGB_NV=$8593 +GL_OPERAND3_ALPHA_NV=$859B +GL_BLEND_ equ ATION=$8009 +GL_TABLE_TOO_LARGE=$8031 +GL_UNSIGNED_BYTE_3_3_2=$8032 +GL_UNSIGNED_SHORT_4_4_4_4=$8033 +GL_UNSIGNED_SHORT_5_5_5_1=$8034 +GL_UNSIGNED_INT_8_8_8_8=$8035 +GL_UNSIGNED_INT_10_10_10_2=$8036 +GL_UNSIGNED_BYTE_2_3_3_REV=$8362 +GL_UNSIGNED_SHORT_5_6_5=$8363 +GL_UNSIGNED_SHORT_5_6_5_REV=$8364 +GL_UNSIGNED_SHORT_4_4_4_4_REV=$8365 +GL_UNSIGNED_SHORT_1_5_5_5_REV=$8366 +GL_UNSIGNED_INT_8_8_8_8_REV=$8367 +GL_UNSIGNED_INT_2_10_10_10_REV=$8368 +;GL_ARB_transpose_matrix +GL_TRANSPOSE_MODELVIEW_MATRIX_ARB=$84E3 +GL_TRANSPOSE_PROJECTION_MATRIX_ARB=$84E4 +GL_TRANSPOSE_TEXTURE_MATRIX_ARB=$84E5 +GL_TRANSPOSE_COLOR_MATRIX_ARB=$84E6 +;GL_ARB_multisample +GL_MULTISAMPLE_ARB=$809D +GL_SAMPLE_ALPHA_TO_COVERAGE_ARB=$809E +GL_SAMPLE_ALPHA_TO_ONE_ARB=$809F +GL_SAMPLE_COVERAGE_ARB=$80A0 +GL_SAMPLE_BUFFERS_ARB=$80A8 +GL_SAMPLES_ARB=$80A9 +GL_SAMPLE_COVERAGE_VALUE_ARB=$80AA +GL_SAMPLE_COVERAGE_INVERT_ARB=$80AB +GL_MULTISAMPLE_BIT_ARB=$20000000 +;GL_ARB_texture_cube_map +GL_NORMAL_MAP_ARB=$8511 +GL_REFLECTION_MAP_ARB=$8512 +GL_TEXTURE_CUBE_MAP_ARB=$8513 +GL_TEXTURE_BINDING_CUBE_MAP_ARB=$8514 +GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB=$8515 +GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB=$8516 +GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB=$8517 +GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB=$8518 +GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB=$8519 +GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB=$851A +GL_PROXY_TEXTURE_CUBE_MAP_ARB=$851B +GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB=$851C +;GL_ARB_texture_compression +GL_COMPRESSED_ALPHA_ARB=$84E9 +GL_COMPRESSED_LUMINANCE_ARB=$84EA +GL_COMPRESSED_LUMINANCE_ALPHA_ARB=$84EB +GL_COMPRESSED_INTENSITY_ARB=$84EC +GL_COMPRESSED_RGB_ARB=$84ED +GL_COMPRESSED_RGBA_ARB=$84EE +GL_TEXTURE_COMPRESSION_HINT_ARB=$84EF +GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB=$86A0 +GL_TEXTURE_COMPRESSED_ARB=$86A1 +GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB=$86A2 +GL_COMPRESSED_TEXTURE_FORMATS_ARB=$86A3 +;GL_ARB_vertex_blend +GL_MAX_VERTEX_UNITS_ARB=$86A4 +GL_ACTIVE_VERTEX_UNITS_ARB=$86A5 +GL_WEIGHT_SUM_UNITY_ARB=$86A6 +GL_VERTEX_BLEND_ARB=$86A7 +GL_CURRENT_WEIGHT_ARB=$86A8 +GL_WEIGHT_ARRAY_TYPE_ARB=$86A9 +GL_WEIGHT_ARRAY_STRIDE_ARB=$86AA +GL_WEIGHT_ARRAY_SIZE_ARB=$86AB +GL_WEIGHT_ARRAY_POINTER_ARB=$86AC +GL_WEIGHT_ARRAY_ARB=$86AD +GL_MODELVIEW0_ARB=$1700 +GL_MODELVIEW1_ARB=$850A +GL_MODELVIEW2_ARB=$8722 +GL_MODELVIEW3_ARB=$8723 +GL_MODELVIEW4_ARB=$8724 +GL_MODELVIEW5_ARB=$8725 +GL_MODELVIEW6_ARB=$8726 +GL_MODELVIEW7_ARB=$8727 +GL_MODELVIEW8_ARB=$8728 +GL_MODELVIEW9_ARB=$8729 +GL_MODELVIEW10_ARB=$872A +GL_MODELVIEW11_ARB=$872B +GL_MODELVIEW12_ARB=$872C +GL_MODELVIEW13_ARB=$872D +GL_MODELVIEW14_ARB=$872E +GL_MODELVIEW15_ARB=$872F +GL_MODELVIEW16_ARB=$8730 +GL_MODELVIEW17_ARB=$8731 +GL_MODELVIEW18_ARB=$8732 +GL_MODELVIEW19_ARB=$8733 +GL_MODELVIEW20_ARB=$8734 +GL_MODELVIEW21_ARB=$8735 +GL_MODELVIEW22_ARB=$8736 +GL_MODELVIEW23_ARB=$8737 +GL_MODELVIEW24_ARB=$8738 +GL_MODELVIEW25_ARB=$8739 +GL_MODELVIEW26_ARB=$873A +GL_MODELVIEW27_ARB=$873B +GL_MODELVIEW28_ARB=$873C +GL_MODELVIEW29_ARB=$873D +GL_MODELVIEW30_ARB=$873E +GL_MODELVIEW31_ARB=$873F +;GL_SGIS_texture_filter4 +GL_FILTER4_SGIS=$8146 +GL_TEXTURE_FILTER4_SIZE_SGIS=$8147 +;GL_SGIS_pixel_texture +GL_PIXEL_TEXTURE_SGIS=$8353 +GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS=$8354 +GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS=$8355 +GL_PIXEL_GROUP_COLOR_SGIS=$8356 +;GL_SGIX_pixel_texture +GL_PIXEL_TEX_GEN_SGIX=$8139 +GL_PIXEL_TEX_GEN_MODE_SGIX=$832B +;GL_SGIS_texture4D +GL_PACK_SKIP_VOLUMES_SGIS=$8130 +GL_PACK_IMAGE_DEPTH_SGIS=$8131 +GL_UNPACK_SKIP_VOLUMES_SGIS=$8132 +GL_UNPACK_IMAGE_DEPTH_SGIS=$8133 +GL_TEXTURE_4D_SGIS=$8134 +GL_PROXY_TEXTURE_4D_SGIS=$8135 +GL_TEXTURE_4DSIZE_SGIS=$8136 +GL_TEXTURE_WRAP_Q_SGIS=$8137 +GL_MAX_4D_TEXTURE_SIZE_SGIS=$8138 +GL_TEXTURE_4D_BINDING_SGIS=$814F +;GL_SGIS_detail_texture +GL_DETAIL_TEXTURE_2D_SGIS=$8095 +GL_DETAIL_TEXTURE_2D_BINDING_SGIS=$8096 +GL_LINEAR_DETAIL_SGIS=$8097 +GL_LINEAR_DETAIL_ALPHA_SGIS=$8098 +GL_LINEAR_DETAIL_COLOR_SGIS=$8099 +GL_DETAIL_TEXTURE_LEVEL_SGIS=$809A +GL_DETAIL_TEXTURE_MODE_SGIS=$809B +GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS=$809C +;GL_SGIS_sharpen_texture +GL_LINEAR_SHARPEN_SGIS=$80AD +GL_LINEAR_SHARPEN_ALPHA_SGIS=$80AE +GL_LINEAR_SHARPEN_COLOR_SGIS=$80AF +GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS=$80B0 +;GL_SGIS_texture_lod +GL_TEXTURE_MIN_LOD_SGIS=$813A +GL_TEXTURE_MAX_LOD_SGIS=$813B +GL_TEXTURE_BASE_LEVEL_SGIS=$813C +GL_TEXTURE_MAX_LEVEL_SGIS=$813D +;GL_SGIS_multisample +GL_MULTISAMPLE_SGIS=$809D +GL_SAMPLE_ALPHA_TO_MASK_SGIS=$809E +GL_SAMPLE_ALPHA_TO_ONE_SGIS=$809F +GL_SAMPLE_MASK_SGIS=$80A0 +GL_1PASS_SGIS=$80A1 +GL_2PASS_0_SGIS=$80A2 +GL_2PASS_1_SGIS=$80A3 +GL_4PASS_0_SGIS=$80A4 +GL_4PASS_1_SGIS=$80A5 +GL_4PASS_2_SGIS=$80A6 +GL_4PASS_3_SGIS=$80A7 +GL_SAMPLE_BUFFERS_SGIS=$80A8 +GL_SAMPLES_SGIS=$80A9 +GL_SAMPLE_MASK_VALUE_SGIS=$80AA +GL_SAMPLE_MASK_INVERT_SGIS=$80AB +GL_SAMPLE_PATTERN_SGIS=$80AC +;GL_SGIS_generate_mipmap +GL_GENERATE_MIPMAP_SGIS=$8191 +GL_GENERATE_MIPMAP_HINT_SGIS=$8192 +;GL_SGIX_clipmap +GL_LINEAR_CLIPMAP_LINEAR_SGIX=$8170 +GL_TEXTURE_CLIPMAP_CENTER_SGIX=$8171 +GL_TEXTURE_CLIPMAP_FRAME_SGIX=$8172 +GL_TEXTURE_CLIPMAP_OFFSET_SGIX=$8173 +GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX=$8174 +GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX=$8175 +GL_TEXTURE_CLIPMAP_DEPTH_SGIX=$8176 +GL_MAX_CLIPMAP_DEPTH_SGIX=$8177 +GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX=$8178 +GL_NEAREST_CLIPMAP_NEAREST_SGIX=$844D +GL_NEAREST_CLIPMAP_LINEAR_SGIX=$844E +GL_LINEAR_CLIPMAP_NEAREST_SGIX=$844F +;GL_SGIX_shadow +GL_TEXTURE_COMPARE_SGIX=$819A +GL_TEXTURE_COMPARE_OPERATOR_SGIX=$819B +GL_TEXTURE_L equ AL_R_SGIX=$819C +GL_TEXTURE_G equ AL_R_SGIX=$819D +;GL_SGIS_texture_edge_clamp +GL_CLAMP_TO_EDGE_SGIS=$812F +;GL_SGIS_texture_border_clamp +GL_CLAMP_TO_BORDER_SGIS=$812D +;GL_SGIX_interlace +GL_INTERLACE_SGIX=$8094 +;GL_SGIX_pixel_tiles +GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX=$813E +GL_PIXEL_TILE_CACHE_INCREMENT_SGIX=$813F +GL_PIXEL_TILE_WIDTH_SGIX=$8140 +GL_PIXEL_TILE_HEIGHT_SGIX=$8141 +GL_PIXEL_TILE_GRID_WIDTH_SGIX=$8142 +GL_PIXEL_TILE_GRID_HEIGHT_SGIX=$8143 +GL_PIXEL_TILE_GRID_DEPTH_SGIX=$8144 +GL_PIXEL_TILE_CACHE_SIZE_SGIX=$8145 +;GL_SGIS_texture_select +GL_DUAL_ALPHA4_SGIS=$8110 +GL_DUAL_ALPHA8_SGIS=$8111 +GL_DUAL_ALPHA12_SGIS=$8112 +GL_DUAL_ALPHA16_SGIS=$8113 +GL_DUAL_LUMINANCE4_SGIS=$8114 +GL_DUAL_LUMINANCE8_SGIS=$8115 +GL_DUAL_LUMINANCE12_SGIS=$8116 +GL_DUAL_LUMINANCE16_SGIS=$8117 +GL_DUAL_INTENSITY4_SGIS=$8118 +GL_DUAL_INTENSITY8_SGIS=$8119 +GL_DUAL_INTENSITY12_SGIS=$811A +GL_DUAL_INTENSITY16_SGIS=$811B +GL_DUAL_LUMINANCE_ALPHA4_SGIS=$811C +GL_DUAL_LUMINANCE_ALPHA8_SGIS=$811D +GL_QUAD_ALPHA4_SGIS=$811E +GL_QUAD_ALPHA8_SGIS=$811F +GL_QUAD_LUMINANCE4_SGIS=$8120 +GL_QUAD_LUMINANCE8_SGIS=$8121 +GL_QUAD_INTENSITY4_SGIS=$8122 +GL_QUAD_INTENSITY8_SGIS=$8123 +GL_DUAL_TEXTURE_SELECT_SGIS=$8124 +GL_QUAD_TEXTURE_SELECT_SGIS=$8125 +;GL_SGIX_sprite +GL_SPRITE_SGIX=$8148 +GL_SPRITE_MODE_SGIX=$8149 +GL_SPRITE_AXIS_SGIX=$814A +GL_SPRITE_TRANSLATION_SGIX=$814B +GL_SPRITE_AXIAL_SGIX=$814C +GL_SPRITE_OBJECT_ALIGNED_SGIX=$814D +GL_SPRITE_EYE_ALIGNED_SGIX=$814E +;GL_SGIX_texture_multi_buffer +GL_TEXTURE_MULTI_BUFFER_HINT_SGIX=$812E +;GL_SGIS_point_parameters +GL_POINT_SIZE_MIN_SGIS=$8126 +GL_POINT_SIZE_MAX_SGIS=$8127 +GL_POINT_FADE_THRESHOLD_SIZE_SGIS=$8128 +GL_DISTANCE_ATTENUATION_SGIS=$8129 +;GL_SGIX_instruments +GL_INSTRUMENT_BUFFER_POINTER_SGIX=$8180 +GL_INSTRUMENT_MEASUREMENTS_SGIX=$8181 +;GL_SGIX_texture_scale_bias +GL_POST_TEXTURE_FILTER_BIAS_SGIX=$8179 +GL_POST_TEXTURE_FILTER_SCALE_SGIX=$817A +GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX=$817B +GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX=$817C +;GL_SGIX_framezoom +GL_FRAMEZOOM_SGIX=$818B +GL_FRAMEZOOM_FACTOR_SGIX=$818C +GL_MAX_FRAMEZOOM_FACTOR_SGIX=$818D +;GL_FfdMaskSGIX +GL_TEXTURE_DEFORMATION_BIT_SGIX=$00000001 +GL_GEOMETRY_DEFORMATION_BIT_SGIX=$00000002 +;GL_SGIX_polynomial_ffd +GL_GEOMETRY_DEFORMATION_SGIX=$8194 +GL_TEXTURE_DEFORMATION_SGIX=$8195 +GL_DEFORMATIONS_MASK_SGIX=$8196 +GL_MAX_DEFORMATION_ORDER_SGIX=$8197 +;GL_SGIX_reference_plane +GL_REFERENCE_PLANE_SGIX=$817D +GL_REFERENCE_PLANE_ equ ATION_SGIX=$817E +;GL_SGIX_depth_texture +GL_DEPTH_COMPONENT16_SGIX=$81A5 +GL_DEPTH_COMPONENT24_SGIX=$81A6 +GL_DEPTH_COMPONENT32_SGIX=$81A7 +;GL_SGIS_fog_function +GL_FOG_FUNC_SGIS=$812A +GL_FOG_FUNC_POINTS_SGIS=$812B +GL_MAX_FOG_FUNC_POINTS_SGIS=$812C +;GL_SGIX_fog_offset +GL_FOG_OFFSET_SGIX=$8198 +GL_FOG_OFFSET_VALUE_SGIX=$8199 +;GL_HP_image_transform +GL_IMAGE_SCALE_X_HP=$8155 +GL_IMAGE_SCALE_Y_HP=$8156 +GL_IMAGE_TRANSLATE_X_HP=$8157 +GL_IMAGE_TRANSLATE_Y_HP=$8158 +GL_IMAGE_ROTATE_ANGLE_HP=$8159 +GL_IMAGE_ROTATE_ORIGIN_X_HP=$815A +GL_IMAGE_ROTATE_ORIGIN_Y_HP=$815B +GL_IMAGE_MAG_FILTER_HP=$815C +GL_IMAGE_MIN_FILTER_HP=$815D +GL_IMAGE_CUBIC_WEIGHT_HP=$815E +GL_CUBIC_HP=$815F +GL_AVERAGE_HP=$8160 +GL_IMAGE_TRANSFORM_2D_HP=$8161 +GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP=$8162 +GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP=$8163 +;GL_HP_convolution_border_modes +GL_IGNORE_BORDER_HP=$8150 +GL_CONSTANT_BORDER_HP=$8151 +GL_REPLICATE_BORDER_HP=$8153 +GL_CONVOLUTION_BORDER_COLOR_HP=$8154 +;GL_SGIX_texture_add_env +GL_TEXTURE_ENV_BIAS_SGIX=$80BE +;GL_PGI_vertex_hints +GL_VERTEX_DATA_HINT_PGI=$1A22A +GL_VERTEX_CONSISTENT_HINT_PGI=$1A22B +GL_MATERIAL_SIDE_HINT_PGI=$1A22C +GL_MAX_VERTEX_HINT_PGI=$1A22D +GL_COLOR3_BIT_PGI=$00010000 +GL_COLOR4_BIT_PGI=$00020000 +GL_EDGEFLAG_BIT_PGI=$00040000 +GL_INDEX_BIT_PGI=$00080000 +GL_MAT_AMBIENT_BIT_PGI=$00100000 +GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI=$00200000 +GL_MAT_DIFFUSE_BIT_PGI=$00400000 +GL_MAT_EMISSION_BIT_PGI=$00800000 +GL_MAT_COLOR_INDEXES_BIT_PGI=$01000000 +GL_MAT_SHININESS_BIT_PGI=$02000000 +GL_MAT_SPECULAR_BIT_PGI=$04000000 +GL_NORMAL_BIT_PGI=$08000000 +GL_TEXCOORD1_BIT_PGI=$10000000 +GL_TEXCOORD2_BIT_PGI=$20000000 +GL_TEXCOORD3_BIT_PGI=$40000000 +GL_TEXCOORD4_BIT_PGI=$80000000 +GL_VERTEX23_BIT_PGI=$00000004 +GL_VERTEX4_BIT_PGI=$00000008 +;GL_PGI_misc_hints +GL_PREFER_DOUBLEBUFFER_HINT_PGI=$1A1F8 +GL_CONSERVE_MEMORY_HINT_PGI=$1A1FD +GL_RECLAIM_MEMORY_HINT_PGI=$1A1FE +GL_NATIVE_GRAPHICS_HANDLE_PGI=$1A202 +GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI=$1A203 +GL_NATIVE_GRAPHICS_END_HINT_PGI=$1A204 +GL_ALWAYS_FAST_HINT_PGI=$1A20C +GL_ALWAYS_SOFT_HINT_PGI=$1A20D +GL_ALLOW_DRAW_OBJ_HINT_PGI=$1A20E +GL_ALLOW_DRAW_WIN_HINT_PGI=$1A20F +GL_ALLOW_DRAW_FRG_HINT_PGI=$1A210 +GL_ALLOW_DRAW_MEM_HINT_PGI=$1A211 +GL_STRICT_DEPTHFUNC_HINT_PGI=$1A216 +GL_STRICT_LIGHTING_HINT_PGI=$1A217 +GL_STRICT_SCISSOR_HINT_PGI=$1A218 +GL_FULL_STIPPLE_HINT_PGI=$1A219 +GL_CLIP_NEAR_HINT_PGI=$1A220 +GL_CLIP_FAR_HINT_PGI=$1A221 +GL_WIDE_LINE_HINT_PGI=$1A222 +GL_BACK_NORMALS_HINT_PGI=$1A223 +;GL_EXT_paletted_texture +GL_TEXTURE_INDEX_SIZE_EXT=$80ED +;GL_SGIX_list_priority +GL_LIST_PRIORITY_SGIX=$8182 +;GL_SGIX_ir_instrument1 +GL_IR_INSTRUMENT1_SGIX=$817F +;GL_SGIX_calligraphic_fragment +GL_CALLIGRAPHIC_FRAGMENT_SGIX=$8183 +;GL_SGIX_texture_lod_bias +GL_TEXTURE_LOD_BIAS_S_SGIX=$818E +GL_TEXTURE_LOD_BIAS_T_SGIX=$818F +GL_TEXTURE_LOD_BIAS_R_SGIX=$8190 +;GL_SGIX_shadow_ambient +GL_SHADOW_AMBIENT_SGIX=$80BF +;GL_SGIX_ycrcb +GL_YCRCB_422_SGIX=$81BB +GL_YCRCB_444_SGIX=$81BC +;GL_SGIX_fragment_lighting +GL_FRAGMENT_LIGHTING_SGIX=$8400 +GL_FRAGMENT_COLOR_MATERIAL_SGIX=$8401 +GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX=$8402 +GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX=$8403 +GL_MAX_FRAGMENT_LIGHTS_SGIX=$8404 +GL_MAX_ACTIVE_LIGHTS_SGIX=$8405 +GL_CURRENT_RASTER_NORMAL_SGIX=$8406 +GL_LIGHT_ENV_MODE_SGIX=$8407 +GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX=$8408 +GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX=$8409 +GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX=$840A +GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX=$840B +GL_FRAGMENT_LIGHT0_SGIX=$840C +GL_FRAGMENT_LIGHT1_SGIX=$840D +GL_FRAGMENT_LIGHT2_SGIX=$840E +GL_FRAGMENT_LIGHT3_SGIX=$840F +GL_FRAGMENT_LIGHT4_SGIX=$8410 +GL_FRAGMENT_LIGHT5_SGIX=$8411 +GL_FRAGMENT_LIGHT6_SGIX=$8412 +GL_FRAGMENT_LIGHT7_SGIX=$8413 +;GL_IBM_rasterpos_clip +GL_RASTER_POSITION_UNCLIPPED_IBM=$19262 +;GL_HP_texture_lighting +GL_TEXTURE_LIGHTING_MODE_HP=$8167 +GL_TEXTURE_POST_SPECULAR_HP=$8168 +GL_TEXTURE_PRE_SPECULAR_HP=$8169 +;GL_EXT_draw_range_elements +GL_MAX_ELEMENTS_VERTICES_EXT=$80E8 +GL_MAX_ELEMENTS_INDICES_EXT=$80E9 +;GL_WIN_phong_shading +GL_PHONG_WIN=$80EA +GL_PHONG_HINT_WIN=$80EB +;GL_WIN_specular_fog +GL_FOG_SPECULAR_TEXTURE_WIN=$80EC +;GL_EXT_light_texture +GL_FRAGMENT_MATERIAL_EXT=$8349 +GL_FRAGMENT_NORMAL_EXT=$834A +GL_FRAGMENT_COLOR_EXT=$834C +GL_ATTENUATION_EXT=$834D +GL_SHADOW_ATTENUATION_EXT=$834E +GL_TEXTURE_APPLICATION_MODE_EXT=$834F +GL_TEXTURE_LIGHT_EXT=$8350 +GL_TEXTURE_MATERIAL_FACE_EXT=$8351 +GL_TEXTURE_MATERIAL_PARAMETER_EXT=$8352 +;GL_SGIX_blend_alpha_minmax +GL_ALPHA_MIN_SGIX=$8320 +GL_ALPHA_MAX_SGIX=$8321 +;GL_SGIX_async +GL_ASYNC_MARKER_SGIX=$8329 +;GL_SGIX_async_pixel +GL_ASYNC_TEX_IMAGE_SGIX=$835C +GL_ASYNC_DRAW_PIXELS_SGIX=$835D +GL_ASYNC_READ_PIXELS_SGIX=$835E +GL_MAX_ASYNC_TEX_IMAGE_SGIX=$835F +GL_MAX_ASYNC_DRAW_PIXELS_SGIX=$8360 +GL_MAX_ASYNC_READ_PIXELS_SGIX=$8361 +;GL_SGIX_async_histogram +GL_ASYNC_HISTOGRAM_SGIX=$832C +GL_MAX_ASYNC_HISTOGRAM_SGIX=$832D +;GL_INTEL_parallel_arrays +GL_PARALLEL_ARRAYS_INTEL=$83F4 +GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL=$83F5 +GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL=$83F6 +GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL=$83F7 +GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL=$83F8 +;GL_HP_occlusion_test +GL_OCCLUSION_TEST_HP=$8165 +GL_OCCLUSION_TEST_RESULT_HP=$8166 +;GL_EXT_pixel_transform +GL_PIXEL_TRANSFORM_2D_EXT=$8330 +GL_PIXEL_MAG_FILTER_EXT=$8331 +GL_PIXEL_MIN_FILTER_EXT=$8332 +GL_PIXEL_CUBIC_WEIGHT_EXT=$8333 +GL_CUBIC_EXT=$8334 +GL_AVERAGE_EXT=$8335 +GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT=$8336 +GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT=$8337 +GL_PIXEL_TRANSFORM_2D_MATRIX_EXT=$8338 +;GL_EXT_separate_specular_color +GL_LIGHT_MODEL_COLOR_CONTROL_EXT=$81F8 +GL_SINGLE_COLOR_EXT=$81F9 +GL_SEPARATE_SPECULAR_COLOR_EXT=$81FA +;GL_EXT_secondary_color +GL_COLOR_SUM_EXT=$8458 +GL_CURRENT_SECONDARY_COLOR_EXT=$8459 +GL_SECONDARY_COLOR_ARRAY_SIZE_EXT=$845A +GL_SECONDARY_COLOR_ARRAY_TYPE_EXT=$845B +GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT=$845C +GL_SECONDARY_COLOR_ARRAY_POINTER_EXT=$845D +GL_SECONDARY_COLOR_ARRAY_EXT=$845E +;GL_EXT_texture_perturb_normal +GL_PERTURB_EXT=$85AE +GL_TEXTURE_NORMAL_EXT=$85AF +;GL_EXT_fog_coord +GL_FOG_COORDINATE_SOURCE_EXT=$8450 +GL_FOG_COORDINATE_EXT=$8451 +GL_FRAGMENT_DEPTH_EXT=$8452 +GL_CURRENT_FOG_COORDINATE_EXT=$8453 +GL_FOG_COORDINATE_ARRAY_TYPE_EXT=$8454 +GL_FOG_COORDINATE_ARRAY_STRIDE_EXT=$8455 +GL_FOG_COORDINATE_ARRAY_POINTER_EXT=$8456 +GL_FOG_COORDINATE_ARRAY_EXT=$8457 +;GL_REND_screen_coordinates +GL_SCREEN_COORDINATES_REND=$8490 +GL_INVERTED_SCREEN_W_REND=$8491 +;GL_EXT_coordinate_frame +GL_TANGENT_ARRAY_EXT=$8439 +GL_BINORMAL_ARRAY_EXT=$843A +GL_CURRENT_TANGENT_EXT=$843B +GL_CURRENT_BINORMAL_EXT=$843C +GL_TANGENT_ARRAY_TYPE_EXT=$843E +GL_TANGENT_ARRAY_STRIDE_EXT=$843F +GL_BINORMAL_ARRAY_TYPE_EXT=$8440 +GL_BINORMAL_ARRAY_STRIDE_EXT=$8441 +GL_TANGENT_ARRAY_POINTER_EXT=$8442 +GL_BINORMAL_ARRAY_POINTER_EXT=$8443 +GL_MAP1_TANGENT_EXT=$8444 +GL_MAP2_TANGENT_EXT=$8445 +GL_MAP1_BINORMAL_EXT=$8446 +GL_MAP2_BINORMAL_EXT=$8447 +;GL_EXT_texture_env_combine +GL_SOURCE3_RGB_EXT=$8583 +GL_SOURCE4_RGB_EXT=$8584 +GL_SOURCE5_RGB_EXT=$8585 +GL_SOURCE6_RGB_EXT=$8586 +GL_SOURCE7_RGB_EXT=$8587 +GL_SOURCE3_ALPHA_EXT=$858B +GL_SOURCE4_ALPHA_EXT=$858C +GL_SOURCE5_ALPHA_EXT=$858D +GL_SOURCE6_ALPHA_EXT=$858E +GL_SOURCE7_ALPHA_EXT=$858F +GL_OPERAND3_RGB_EXT=$8593 +GL_OPERAND4_RGB_EXT=$8594 +GL_OPERAND5_RGB_EXT=$8595 +GL_OPERAND6_RGB_EXT=$8596 +GL_OPERAND7_RGB_EXT=$8597 +GL_OPERAND3_ALPHA_EXT=$859B +GL_OPERAND4_ALPHA_EXT=$859C +GL_OPERAND5_ALPHA_EXT=$859D +GL_OPERAND6_ALPHA_EXT=$859E +GL_OPERAND7_ALPHA_EXT=$859F +;GL_APPLE_specular_vector +GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE=$85B0 +;GL_APPLE_transform_hint +GL_TRANSFORM_HINT_APPLE=$85B1 +;GL_SGIX_fog_scale +GL_FOG_SCALE_SGIX=$81FC +GL_FOG_SCALE_VALUE_SGIX=$81FD +;GL_SUNX_constant_data +GL_UNPACK_CONSTANT_DATA_SUNX=$81D5 +GL_TEXTURE_CONSTANT_DATA_SUNX=$81D6 +;GL_SUN_global_alpha +GL_GLOBAL_ALPHA_SUN=$81D9 +GL_GLOBAL_ALPHA_FACTOR_SUN=$81DA +;GL_SUN_triangle_list +GL_RESTART_SUN=$01 +GL_REPLACE_MIDDLE_SUN=$02 +GL_REPLACE_OLDEST_SUN=$03 +GL_TRIANGLE_LIST_SUN=$81D7 +GL_REPLACEMENT_CODE_SUN=$81D8 +GL_REPLACEMENT_CODE_ARRAY_SUN=$85C0 +GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN=$85C1 +GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN=$85C2 +GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN=$85C3 +GL_R1UI_V3F_SUN=$85C4 +GL_R1UI_C4UB_V3F_SUN=$85C5 +GL_R1UI_C3F_V3F_SUN=$85C6 +GL_R1UI_N3F_V3F_SUN=$85C7 +GL_R1UI_C4F_N3F_V3F_SUN=$85C8 +GL_R1UI_T2F_V3F_SUN=$85C9 +GL_R1UI_T2F_N3F_V3F_SUN=$85CA +GL_R1UI_T2F_C4F_N3F_V3F_SUN=$85CB +;GL_EXT_blend_func_separate +GL_BLEND_DST_RGB_EXT=$80C8 +GL_BLEND_SRC_RGB_EXT=$80C9 +GL_BLEND_DST_ALPHA_EXT=$80CA +GL_BLEND_SRC_ALPHA_EXT=$80CB +;GL_INGR_color_clamp +GL_RED_MIN_CLAMP_INGR=$8560 +GL_GREEN_MIN_CLAMP_INGR=$8561 +GL_BLUE_MIN_CLAMP_INGR=$8562 +GL_ALPHA_MIN_CLAMP_INGR=$8563 +GL_RED_MAX_CLAMP_INGR=$8564 +GL_GREEN_MAX_CLAMP_INGR=$8565 +GL_BLUE_MAX_CLAMP_INGR=$8566 +GL_ALPHA_MAX_CLAMP_INGR=$8567 +;GL_INGR_interlace_read +GL_INTERLACE_READ_INGR=$8568 +;GL_EXT_422_pixels +GL_422_EXT=$80CC +GL_422_REV_EXT=$80CD +GL_422_AVERAGE_EXT=$80CE +GL_422_REV_AVERAGE_EXT=$80CF +;GL_EXT_texture_cube_map +GL_NORMAL_MAP_EXT=$8511 +GL_REFLECTION_MAP_EXT=$8512 +GL_TEXTURE_CUBE_MAP_EXT=$8513 +GL_TEXTURE_BINDING_CUBE_MAP_EXT=$8514 +GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT=$8515 +GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT=$8516 +GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT=$8517 +GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT=$8518 +GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT=$8519 +GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT=$851A +GL_PROXY_TEXTURE_CUBE_MAP_EXT=$851B +GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT=$851C +;GL_SUN_convolution_border_modes +GL_WRAP_BORDER_SUN=$81D4 +;GL_EXT_texture_lod_bias +GL_MAX_TEXTURE_LOD_BIAS_EXT=$84FD +GL_TEXTURE_FILTER_CONTROL_EXT=$8500 +GL_TEXTURE_LOD_BIAS_EXT=$8501 +;GL_EXT_texture_filter_anisotropic +GL_TEXTURE_MAX_ANISOTROPY_EXT=$84FE +GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT=$84FF +;GL_EXT_vertex_weighting +GL_MODELVIEW0_STACK_DEPTH_EXT=GL_MODELVIEW_STACK_DEPTH +GL_MODELVIEW1_STACK_DEPTH_EXT=$8502 +GL_MODELVIEW0_MATRIX_EXT=GL_MODELVIEW_MATRIX +GL_MODELVIEW_MATRIX1_EXT=$8506 +GL_VERTEX_WEIGHTING_EXT=$8509 +GL_MODELVIEW0_EXT=GL_MODELVIEW +GL_MODELVIEW1_EXT=$850A +GL_CURRENT_VERTEX_WEIGHT_EXT=$850B +GL_VERTEX_WEIGHT_ARRAY_EXT=$850C +GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT=$850D +GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT=$850E +GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT=$850F +GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT=$8510 +;GL_NV_light_max_exponent +GL_MAX_SHININESS_NV=$8504 +GL_MAX_SPOT_EXPONENT_NV=$8505 +;GL_NV_vertex_array_range +GL_VERTEX_ARRAY_RANGE_NV=$851D +GL_VERTEX_ARRAY_RANGE_LENGTH_NV=$851E +GL_VERTEX_ARRAY_RANGE_VALID_NV=$851F +GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV=$8520 +GL_VERTEX_ARRAY_RANGE_POINTER_NV=$8521 +;GL_NV_register_combiners +GL_REGISTER_COMBINERS_NV=$8522 +GL_VARIABLE_A_NV=$8523 +GL_VARIABLE_B_NV=$8524 +GL_VARIABLE_C_NV=$8525 +GL_VARIABLE_D_NV=$8526 +GL_VARIABLE_E_NV=$8527 +GL_VARIABLE_F_NV=$8528 +GL_VARIABLE_G_NV=$8529 +GL_CONSTANT_COLOR0_NV=$852A +GL_CONSTANT_COLOR1_NV=$852B +GL_PRIMARY_COLOR_NV=$852C +GL_SECONDARY_COLOR_NV=$852D +GL_SPARE0_NV=$852E +GL_SPARE1_NV=$852F +GL_DISCARD_NV=$8530 +GL_E_TIMES_F_NV=$8531 +GL_SPARE0_PLUS_SECONDARY_COLOR_NV=$8532 +GL_UNSIGNED_IDENTITY_NV=$8536 +GL_UNSIGNED_INVERT_NV=$8537 +GL_EXPAND_NORMAL_NV=$8538 +GL_EXPAND_NEGATE_NV=$8539 +GL_HALF_BIAS_NORMAL_NV=$853A +GL_HALF_BIAS_NEGATE_NV=$853B +GL_SIGNED_IDENTITY_NV=$853C +GL_SIGNED_NEGATE_NV=$853D +GL_SCALE_BY_TWO_NV=$853E +GL_SCALE_BY_FOUR_NV=$853F +GL_SCALE_BY_ONE_HALF_NV=$8540 +GL_BIAS_BY_NEGATIVE_ONE_HALF_NV=$8541 +GL_COMBINER_INPUT_NV=$8542 +GL_COMBINER_MAPPING_NV=$8543 +GL_COMBINER_COMPONENT_USAGE_NV=$8544 +GL_COMBINER_AB_DOT_PRODUCT_NV=$8545 +GL_COMBINER_CD_DOT_PRODUCT_NV=$8546 +GL_COMBINER_MUX_SUM_NV=$8547 +GL_COMBINER_SCALE_NV=$8548 +GL_COMBINER_BIAS_NV=$8549 +GL_COMBINER_AB_OUTPUT_NV=$854A +GL_COMBINER_CD_OUTPUT_NV=$854B +GL_COMBINER_SUM_OUTPUT_NV=$854C +GL_MAX_GENERAL_COMBINERS_NV=$854D +GL_NUM_GENERAL_COMBINERS_NV=$854E +GL_COLOR_SUM_CLAMP_NV=$854F +GL_COMBINER0_NV=$8550 +GL_COMBINER1_NV=$8551 +GL_COMBINER2_NV=$8552 +GL_COMBINER3_NV=$8553 +GL_COMBINER4_NV=$8554 +GL_COMBINER5_NV=$8555 +GL_COMBINER6_NV=$8556 +GL_COMBINER7_NV=$8557 +;GL_NV_fog_distance +GL_FOG_DISTANCE_MODE_NV=$855A +GL_EYE_RADIAL_NV=$855B +GL_EYE_PLANE_ABSOLUTE_NV=$855C +;GL_NV_texgen_emboss +GL_EMBOSS_LIGHT_NV=$855D +GL_EMBOSS_CONSTANT_NV=$855E +GL_EMBOSS_MAP_NV=$855F +;GL_EXT_texture_compression_s3tc +GL_COMPRESSED_RGB_S3TC_DXT1_EXT=$83F0 +GL_COMPRESSED_RGBA_S3TC_DXT1_EXT=$83F1 +GL_COMPRESSED_RGBA_S3TC_DXT3_EXT=$83F2 +GL_COMPRESSED_RGBA_S3TC_DXT5_EXT=$83F3 +;GL_IBM_cull_vertex +GL_CULL_VERTEX_IBM=103050 +;GL_IBM_vertex_array_lists +GL_VERTEX_ARRAY_LIST_IBM=103070 +GL_NORMAL_ARRAY_LIST_IBM=103071 +GL_COLOR_ARRAY_LIST_IBM=103072 +GL_INDEX_ARRAY_LIST_IBM=103073 +GL_TEXTURE_COORD_ARRAY_LIST_IBM=103074 +GL_EDGE_FLAG_ARRAY_LIST_IBM=103075 +GL_FOG_COORDINATE_ARRAY_LIST_IBM=103076 +GL_SECONDARY_COLOR_ARRAY_LIST_IBM=103077 +GL_VERTEX_ARRAY_LIST_STRIDE_IBM=103080 +GL_NORMAL_ARRAY_LIST_STRIDE_IBM=103081 +GL_COLOR_ARRAY_LIST_STRIDE_IBM=103082 +GL_INDEX_ARRAY_LIST_STRIDE_IBM=103083 +GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM=103084 +GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM=103085 +GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM=103086 +GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM=103087 +;GL_SGIX_subsample +GL_PACK_SUBSAMPLE_RATE_SGIX=$85A0 +GL_UNPACK_SUBSAMPLE_RATE_SGIX=$85A1 +GL_PIXEL_SUBSAMPLE_4444_SGIX=$85A2 +GL_PIXEL_SUBSAMPLE_2424_SGIX=$85A3 +GL_PIXEL_SUBSAMPLE_4242_SGIX=$85A4 +;GL_SGIX_ycrcba +GL_YCRCB_SGIX=$8318 +GL_YCRCBA_SGIX=$8319 +;GL_SGI_depth_pass_instrument +GL_DEPTH_PASS_INSTRUMENT_SGIX=$8310 +GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX=$8311 +GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX=$8312 +;GL_3DFX_texture_compression_FXT1 +GL_COMPRESSED_RGB_FXT1_3DFX=$86B0 +GL_COMPRESSED_RGBA_FXT1_3DFX=$86B1 +;GL_3DFX_multisample +GL_MULTISAMPLE_3DFX=$86B2 +GL_SAMPLE_BUFFERS_3DFX=$86B3 +GL_SAMPLES_3DFX=$86B4 +GL_MULTISAMPLE_BIT_3DFX=$20000000 +;GL_EXT_multisample +GL_MULTISAMPLE_EXT=$809D +GL_SAMPLE_ALPHA_TO_MASK_EXT=$809E +GL_SAMPLE_ALPHA_TO_ONE_EXT=$809F +GL_SAMPLE_MASK_EXT=$80A0 +GL_1PASS_EXT=$80A1 +GL_2PASS_0_EXT=$80A2 +GL_2PASS_1_EXT=$80A3 +GL_4PASS_0_EXT=$80A4 +GL_4PASS_1_EXT=$80A5 +GL_4PASS_2_EXT=$80A6 +GL_4PASS_3_EXT=$80A7 +GL_SAMPLE_BUFFERS_EXT=$80A8 +GL_SAMPLES_EXT=$80A9 +GL_SAMPLE_MASK_VALUE_EXT=$80AA +GL_SAMPLE_MASK_INVERT_EXT=$80AB +GL_SAMPLE_PATTERN_EXT=$80AC +;GL_SGIX_vertex_preclip +GL_VERTEX_PRECLIP_SGIX=$83EE +GL_VERTEX_PRECLIP_HINT_SGIX=$83EF +;GL_SGIX_convolution_accuracy +GL_CONVOLUTION_HINT_SGIX=$8316 +;GL_SGIX_resample +GL_PACK_RESAMPLE_SGIX=$842C +GL_UNPACK_RESAMPLE_SGIX=$842D +GL_RESAMPLE_REPLICATE_SGIX=$842E +GL_RESAMPLE_ZERO_FILL_SGIX=$842F +GL_RESAMPLE_DECIMATE_SGIX=$8430 +;GL_SGIS_point_line_texgen +GL_EYE_DISTANCE_TO_POINT_SGIS=$81F0 +GL_OBJECT_DISTANCE_TO_POINT_SGIS=$81F1 +GL_EYE_DISTANCE_TO_LINE_SGIS=$81F2 +GL_OBJECT_DISTANCE_TO_LINE_SGIS=$81F3 +GL_EYE_POINT_SGIS=$81F4 +GL_OBJECT_POINT_SGIS=$81F5 +GL_EYE_LINE_SGIS=$81F6 +GL_OBJECT_LINE_SGIS=$81F7 +;GL_SGIS_texture_color_mask +GL_TEXTURE_COLOR_WRITEMASK_SGIS=$81EF +;GL_NV_vertex_program +GL_VERTEX_PROGRAM_NV=$8620 +GL_VERTEX_STATE_PROGRAM_NV=$8621 +GL_ATTRIB_ARRAY_SIZE_NV=$8623 +GL_ATTRIB_ARRAY_STRIDE_NV=$8624 +GL_ATTRIB_ARRAY_TYPE_NV=$8625 +GL_CURRENT_ATTRIB_NV=$8626 +GL_PROGRAM_LENGTH_NV=$8627 +GL_PROGRAM_STRING_NV=$8628 +GL_MODELVIEW_PROJECTION_NV=$8629 +GL_IDENTITY_NV=$862A +GL_INVERSE_NV=$862B +GL_TRANSPOSE_NV=$862C +GL_INVERSE_TRANSPOSE_NV=$862D +GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV=$862E +GL_MAX_TRACK_MATRICES_NV=$862F +GL_MATRIX0_NV=$8630 +GL_MATRIX1_NV=$8631 +GL_MATRIX2_NV=$8632 +GL_MATRIX3_NV=$8633 +GL_MATRIX4_NV=$8634 +GL_MATRIX5_NV=$8635 +GL_MATRIX6_NV=$8636 +GL_MATRIX7_NV=$8637 +GL_CURRENT_MATRIX_STACK_DEPTH_NV=$8640 +GL_CURRENT_MATRIX_NV=$8641 +GL_VERTEX_PROGRAM_POINT_SIZE_NV=$8642 +GL_VERTEX_PROGRAM_TWO_SIDE_NV=$8643 +GL_PROGRAM_PARAMETER_NV=$8644 +GL_ATTRIB_ARRAY_POINTER_NV=$8645 +GL_PROGRAM_TARGET_NV=$8646 +GL_PROGRAM_RESIDENT_NV=$8647 +GL_TRACK_MATRIX_NV=$8648 +GL_TRACK_MATRIX_TRANSFORM_NV=$8649 +GL_VERTEX_PROGRAM_BINDING_NV=$864A +GL_PROGRAM_ERROR_POSITION_NV=$864B +GL_VERTEX_ATTRIB_ARRAY0_NV=$8650 +GL_VERTEX_ATTRIB_ARRAY1_NV=$8651 +GL_VERTEX_ATTRIB_ARRAY2_NV=$8652 +GL_VERTEX_ATTRIB_ARRAY3_NV=$8653 +GL_VERTEX_ATTRIB_ARRAY4_NV=$8654 +GL_VERTEX_ATTRIB_ARRAY5_NV=$8655 +GL_VERTEX_ATTRIB_ARRAY6_NV=$8656 +GL_VERTEX_ATTRIB_ARRAY7_NV=$8657 +GL_VERTEX_ATTRIB_ARRAY8_NV=$8658 +GL_VERTEX_ATTRIB_ARRAY9_NV=$8659 +GL_VERTEX_ATTRIB_ARRAY10_NV=$865A +GL_VERTEX_ATTRIB_ARRAY11_NV=$865B +GL_VERTEX_ATTRIB_ARRAY12_NV=$865C +GL_VERTEX_ATTRIB_ARRAY13_NV=$865D +GL_VERTEX_ATTRIB_ARRAY14_NV=$865E +GL_VERTEX_ATTRIB_ARRAY15_NV=$865F +GL_MAP1_VERTEX_ATTRIB0_4_NV=$8660 +GL_MAP1_VERTEX_ATTRIB1_4_NV=$8661 +GL_MAP1_VERTEX_ATTRIB2_4_NV=$8662 +GL_MAP1_VERTEX_ATTRIB3_4_NV=$8663 +GL_MAP1_VERTEX_ATTRIB4_4_NV=$8664 +GL_MAP1_VERTEX_ATTRIB5_4_NV=$8665 +GL_MAP1_VERTEX_ATTRIB6_4_NV=$8666 +GL_MAP1_VERTEX_ATTRIB7_4_NV=$8667 +GL_MAP1_VERTEX_ATTRIB8_4_NV=$8668 +GL_MAP1_VERTEX_ATTRIB9_4_NV=$8669 +GL_MAP1_VERTEX_ATTRIB10_4_NV=$866A +GL_MAP1_VERTEX_ATTRIB11_4_NV=$866B +GL_MAP1_VERTEX_ATTRIB12_4_NV=$866C +GL_MAP1_VERTEX_ATTRIB13_4_NV=$866D +GL_MAP1_VERTEX_ATTRIB14_4_NV=$866E +GL_MAP1_VERTEX_ATTRIB15_4_NV=$866F +GL_MAP2_VERTEX_ATTRIB0_4_NV=$8670 +GL_MAP2_VERTEX_ATTRIB1_4_NV=$8671 +GL_MAP2_VERTEX_ATTRIB2_4_NV=$8672 +GL_MAP2_VERTEX_ATTRIB3_4_NV=$8673 +GL_MAP2_VERTEX_ATTRIB4_4_NV=$8674 +GL_MAP2_VERTEX_ATTRIB5_4_NV=$8675 +GL_MAP2_VERTEX_ATTRIB6_4_NV=$8676 +GL_MAP2_VERTEX_ATTRIB7_4_NV=$8677 +GL_MAP2_VERTEX_ATTRIB8_4_NV=$8678 +GL_MAP2_VERTEX_ATTRIB9_4_NV=$8679 +GL_MAP2_VERTEX_ATTRIB10_4_NV=$867A +GL_MAP2_VERTEX_ATTRIB11_4_NV=$867B +GL_MAP2_VERTEX_ATTRIB12_4_NV=$867C +GL_MAP2_VERTEX_ATTRIB13_4_NV=$867D +GL_MAP2_VERTEX_ATTRIB14_4_NV=$867E +GL_MAP2_VERTEX_ATTRIB15_4_NV=$867F +;GLUerrors +GLU_INVALID_ENUM=100900 +GLU_INVALID_VALUE=100901 +GLU_OUT_OF_MEMORY=100902 +GLU_INCOMPATIBLE_GL_VERSION=100903 +;GLUbooleanvalues +GLU_TRUE=GL_TRUE +GLU_FALSE=GL_FALSE +;Quadricconstants +GLU_SMOOTH=100000 +GLU_FLAT=100001 +GLU_NONE=100002 +GLU_POINT=100010 +GLU_LINE=100011 +GLU_FILL=100012 +GLU_SILHOUETTE=100013 +GLU_OUTSIDE=100020 +GLU_INSIDE=100021 +;Tesselationconstants +GLU_TESS_MAX_COORD=1.0e150 +GLU_TESS_WINDING_RULE=100140 +GLU_TESS_BOUNDARY_ONLY=100141 +GLU_TESS_TOLERANCE=100142 +GLU_TESS_WINDING_ODD=100130 +GLU_TESS_WINDING_NONZERO=100131 +GLU_TESS_WINDING_POSITIVE=100132 +GLU_TESS_WINDING_NEGATIVE=100133 +GLU_TESS_WINDING_ABS_GEQ_TWO=100134 +GLU_TESS_BEGIN=100100 +GLU_TESS_VERTEX=100101 +GLU_TESS_END=100102 +GLU_TESS_ERROR=100103 +GLU_TESS_EDGE_FLAG=100104 +GLU_TESS_COMBINE=100105 +GLU_TESS_BEGIN_DATA=100106 +GLU_TESS_VERTEX_DATA=100107 +GLU_TESS_END_DATA=100108 +GLU_TESS_ERROR_DATA=100109 +GLU_TESS_EDGE_FLAG_DATA=100110 +GLU_TESS_COMBINE_DATA=100111 +GLU_TESS_ERROR1=100151 +GLU_TESS_ERROR2=100152 +GLU_TESS_ERROR3=100153 +GLU_TESS_ERROR4=100154 +GLU_TESS_ERROR5=100155 +GLU_TESS_ERROR6=100156 +GLU_TESS_ERROR7=100157 +GLU_TESS_ERROR8=100158 +GLU_TESS_MISSING_BEGIN_POLYGON=GLU_TESS_ERROR1 +GLU_TESS_MISSING_BEGIN_CONTOUR=GLU_TESS_ERROR2 +GLU_TESS_MISSING_END_POLYGON=GLU_TESS_ERROR3 +GLU_TESS_MISSING_END_CONTOUR=GLU_TESS_ERROR4 +GLU_TESS_COORD_TOO_LARGE=GLU_TESS_ERROR5 +GLU_TESS_NEED_COMBINE_CALLBACK=GLU_TESS_ERROR6 +;NURBSconstants +GLU_AUTO_LOAD_MATRIX=100200 +GLU_CULLING=100201 +GLU_SAMPLING_TOLERANCE=100203 +GLU_DISPLAY_MODE=100204 +GLU_PARAMETRIC_TOLERANCE=100202 +GLU_SAMPLING_METHOD=100205 +GLU_U_STEP=100206 +GLU_V_STEP=100207 +GLU_PATH_LENGTH=100215 +GLU_PARAMETRIC_ERROR=100216 +GLU_DOMAIN_DISTANCE=100217 +GLU_MAP1_TRIM_2=100210 +GLU_MAP1_TRIM_3=100211 +GLU_OUTLINE_POLYGON=100240 +GLU_OUTLINE_PATCH=100241 +GLU_NURBS_ERROR1=100251 +GLU_NURBS_ERROR2=100252 +GLU_NURBS_ERROR3=100253 +GLU_NURBS_ERROR4=100254 +GLU_NURBS_ERROR5=100255 +GLU_NURBS_ERROR6=100256 +GLU_NURBS_ERROR7=100257 +GLU_NURBS_ERROR8=100258 +GLU_NURBS_ERROR9=100259 +GLU_NURBS_ERROR10=100260 +GLU_NURBS_ERROR11=100261 +GLU_NURBS_ERROR12=100262 +GLU_NURBS_ERROR13=100263 +GLU_NURBS_ERROR14=100264 +GLU_NURBS_ERROR15=100265 +GLU_NURBS_ERROR16=100266 +GLU_NURBS_ERROR17=100267 +GLU_NURBS_ERROR18=100268 +GLU_NURBS_ERROR19=100269 +GLU_NURBS_ERROR20=100270 +GLU_NURBS_ERROR21=100271 +GLU_NURBS_ERROR22=100272 +GLU_NURBS_ERROR23=100273 +GLU_NURBS_ERROR24=100274 +GLU_NURBS_ERROR25=100275 +GLU_NURBS_ERROR26=100276 +GLU_NURBS_ERROR27=100277 +GLU_NURBS_ERROR28=100278 +GLU_NURBS_ERROR29=100279 +GLU_NURBS_ERROR30=100280 +GLU_NURBS_ERROR31=100281 +GLU_NURBS_ERROR32=100282 +GLU_NURBS_ERROR33=100283 +GLU_NURBS_ERROR34=100284 +GLU_NURBS_ERROR35=100285 +GLU_NURBS_ERROR36=100286 +GLU_NURBS_ERROR37=100287 +;Contourstypes +GLU_CW=100120 +GLU_CCW=100121 +GLU_INTERIOR=100122 +GLU_EXTERIOR=100123 +GLU_UNKNOWN=100124 \ No newline at end of file diff --git a/programs/develop/libraries/TinyGL/asm_fork/opinfo.inc b/programs/develop/libraries/TinyGL/asm_fork/opinfo.inc new file mode 100644 index 0000000000..de7893dc3a --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/opinfo.inc @@ -0,0 +1,70 @@ + +ADD_OP Color,7,'%f %f %f %f %d %d %d' +ADD_OP TexCoord,4,'%f %f %f %f' +ADD_OP EdgeFlag,1,'%d' +ADD_OP Normal,3,'%f %f %f' + +ADD_OP Begin,1,'%C' +ADD_OP Vertex,4,'%f %f %f %f' +ADD_OP End,0,'' + +ADD_OP EnableDisable,2,'%C %d' + +ADD_OP MatrixMode,1,'%C' +ADD_OP LoadMatrix,16,'' +ADD_OP LoadIdentity,0,'' +ADD_OP MultMatrix,16,'' +ADD_OP PushMatrix,0,'' +ADD_OP PopMatrix,0,'' +ADD_OP Rotate,4,'%f %f %f %f' +ADD_OP Translate,3,'%f %f %f' +ADD_OP Scale,3,'%f %f %f' + +ADD_OP Viewport,4,'%d %d %d %d' +ADD_OP Frustum,6,'%f %f %f %f %f %f' + +ADD_OP Material,6,'%C %C %f %f %f %f' +ADD_OP ColorMaterial,2,'%C %C' +ADD_OP Light,6,'%C %C %f %f %f %f' +ADD_OP LightModel,5,'%C %f %f %f %f' + +ADD_OP Clear,1,'%d' +ADD_OP ClearColor,4,'%f %f %f %f' +ADD_OP ClearDepth,1,'%f' + +ADD_OP InitNames,0,'' +ADD_OP PushName,1,'%d' +ADD_OP PopName,0,'' +ADD_OP LoadName,1,'%d' + +ADD_OP TexImage2D,9,'%d %d %d %d %d %d %d %d %d' +ADD_OP BindTexture,2,'%C %d' +ADD_OP TexEnv,7,'%C %C %C %f %f %f %f' +ADD_OP TexParameter,7,'%C %C %C %f %f %f %f' +ADD_OP PixelStore,2,'%C %C' + +ADD_OP ShadeModel,1,'%C' +ADD_OP CullFace,1,'%C' +ADD_OP FrontFace,1,'%C' +ADD_OP PolygonMode,2,'%C %C' + +ADD_OP CallList,1,'%d' +ADD_OP Hint,2,'%C %C' + +; special opcodes +ADD_OP EndList,0,'' +ADD_OP NextBuffer,1,'%p' + +; opengl 1.1 arrays +ADD_OP ArrayElement, 1, '%d' +ADD_OP EnableClientState, 1, '%C' +ADD_OP DisableClientState, 1, '%C' +ADD_OP VertexPointer, 4, '%d %C %d %p' +ADD_OP ColorPointer, 4, '%d %C %d %p' +ADD_OP NormalPointer, 3, '%C %d %p' +ADD_OP TexCoordPointer, 4, '%d %C %d %p' + +; opengl 1.1 polygon offset +ADD_OP PolygonOffset, 2, '%f %f' + +purge ADD_OP diff --git a/programs/develop/libraries/TinyGL/asm_fork/select.asm b/programs/develop/libraries/TinyGL/asm_fork/select.asm new file mode 100644 index 0000000000..7af1617279 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/select.asm @@ -0,0 +1,168 @@ + +align 4 +proc glRenderMode uses ebx ecx, mode:dword + call gl_get_context + xor ebx,ebx + + cmp dword[eax+offs_cont_render_mode],GL_RENDER + je .e_sw_1 + cmp dword[eax+offs_cont_render_mode],GL_SELECT + jne .def_1 + cmp dword[eax+offs_cont_select_overflow],0 + je @f + sub ebx,[eax+offs_cont_select_hits] + jmp .else_e + @@: + mov ebx,[eax+offs_cont_select_hits] + .else_e: + mov dword[eax+offs_cont_select_overflow],0 + mov ecx,[eax+offs_cont_select_buffer] + mov dword[eax+offs_cont_select_ptr],ecx + mov dword[eax+offs_cont_name_stack_size],0 + jmp .e_sw_1 + .def_1: +; assert(0); + .e_sw_1: + cmp dword[mode],GL_RENDER + jne @f + mov dword[eax+offs_cont_render_mode],GL_RENDER + jmp .e_sw_2 + @@: + cmp dword[mode],GL_SELECT + jne .def_2 + mov dword[eax+offs_cont_render_mode],GL_SELECT +; assert( c->select_buffer != NULL); + mov ecx,[eax+offs_cont_select_buffer] + mov dword[eax+offs_cont_select_ptr],ecx + mov dword[eax+offs_cont_select_hits],0 + mov dword[eax+offs_cont_select_overflow],0 + mov dword[eax+offs_cont_select_hit],0 ;NULL + jmp .e_sw_2 + .def_2: +; assert(0); + .e_sw_2: + mov eax,ebx + ret +endp + +align 4 +proc glSelectBuffer uses eax ebx, size:dword, buf:dword + call gl_get_context + +; assert(c->render_mode != GL_SELECT); + + mov ebx,[buf] + mov dword[eax+offs_cont_select_buffer],ebx + mov ebx,[size] + mov dword[eax+offs_cont_select_size],ebx + ret +endp + +align 4 +proc glopInitNames uses eax, context:dword, p:dword + mov eax,[context] + cmp dword[eax+offs_cont_render_mode],GL_SELECT + jne @f + mov dword[eax+offs_cont_name_stack_size],0 + mov dword[eax+offs_cont_select_hit],0 ;=NULL + @@: + ret +endp + +align 4 +proc glopPushName uses eax ebx, context:dword, p:dword + mov eax,[context] + cmp dword[eax+offs_cont_render_mode],GL_SELECT + jne @f +; assert(c->name_stack_sizename_stack_size>0); + dec dword[eax+offs_cont_name_stack_size] + mov dword[eax+offs_cont_select_hit],0 ;=NULL + @@: + ret +endp + +align 4 +proc glopLoadName uses eax ebx, context:dword, p:dword + mov eax,[context] + cmp dword[eax+offs_cont_render_mode],GL_SELECT + jne @f +; assert(c->name_stack_size>0); + mov dword[eax+offs_cont_select_hit],0 ;=NULL + mov ebx,dword[eax+offs_cont_name_stack_size] + dec ebx + shl ebx,2 + add ebx,eax + mov eax,[p] + mov eax,[eax+4] + mov dword[ebx+offs_cont_name_stack],eax ;context.name_stack[context.name_stack_size-1]=p[1] + @@: + ret +endp + +align 4 +proc gl_add_select uses eax ebx ecx edx, context:dword, zmin:dword, zmax:dword +; unsigned int *ptr; +; int i; + mov eax,[context] + + cmp dword[eax+offs_cont_select_overflow],0 + jne .end_f ;if (!context.select_overflow) + cmp dword[eax+offs_cont_select_hit],0 ;if (context.select_hit==NULL) + jne .els_0 + mov ecx,[eax+offs_cont_name_stack_size] + mov ebx,[eax+offs_cont_select_ptr] + sub ebx,[eax+offs_cont_select_buffer] + sub ebx,3 + sub ebx,ecx + cmp ebx,[eax+offs_cont_select_size] + jle .els_1 + mov dword[eax+offs_cont_select_overflow],1 + jmp .end_f + .els_1: + mov ebx,[eax+offs_cont_select_ptr] + mov [eax+offs_cont_select_hit],ebx + mov edx,[eax+offs_cont_name_stack_size] + mov [ebx],edx + add ebx,4 + mov edx,[zmin] + mov [ebx],edx + add ebx,4 + mov edx,[zmax] + mov [ebx],edx + add ebx,4 +; for(i=0;iname_stack[i]; + mov [eax+offs_cont_select_ptr],ebx + inc dword[eax+offs_cont_select_hits] + jmp .end_f + .els_0: + mov ebx,[zmin] + cmp dword[eax+offs_cont_select_hit+4],ebx + jle @f + mov dword[eax+offs_cont_select_hit+4],ebx + @@: + mov ebx,[zmax] + cmp dword[eax+offs_cont_select_hit+8],ebx + jge .end_f + mov dword[eax+offs_cont_select_hit+8],ebx + .end_f: + ret +endp + diff --git a/programs/develop/libraries/TinyGL/asm_fork/texture.asm b/programs/develop/libraries/TinyGL/asm_fork/texture.asm new file mode 100644 index 0000000000..12b4779f78 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/texture.asm @@ -0,0 +1,260 @@ +; +; Texture Manager +; + +align 4 +proc find_texture uses ebx ecx, context:dword, h:dword + mov ebx,[context] + mov ebx,[ebx+offs_cont_shared_state+4] ;ebx = &texture_hash_table + mov eax,[h] + and eax,0xff + shl eax,2 + add eax,[ebx] ;eax = &context.shared_state.texture_hash_table[h % TEXTURE_HASH_TABLE_SIZE] + + ; [eax] - указатель на текстуру, получаемую через хеш таблицу + mov ecx,[h] ; ecx - указатель на искомую текстуру + @@: + cmp dword[eax],0 + je .no_found + mov ebx,[eax] + cmp dword[ebx+offs_text_handle],ecx + je .found + mov eax,[ebx+offs_text_next] + jmp @b + .no_found: + xor eax,eax ;ret NULL + .found: + ret +endp + +;static void free_texture(GLContext *c,int h) +;{ +; GLTexture *t,**ht; +; GLImage *im; +; int i; +; +; t=find_texture(c,h); +; if (t->prev==NULL) { +; ht=&c->shared_state.texture_hash_table +; [t->handle % TEXTURE_HASH_TABLE_SIZE]; +; *ht=t->next; +; } else { +; t->prev->next=t->next; +; } +; if (t->next!=NULL) t->next->prev=t->prev; +; +; for(i=0;iimages[i]; +; if (im->pixmap != NULL) gl_free(im->pixmap); +; } +; +; gl_free(t); +;} + +;output: +; eax - указатель на память +align 4 +proc alloc_texture uses ebx ecx, context:dword, h:dword + + stdcall gl_zalloc,sizeof.GLTexture + + mov ebx,[context] + mov ebx,[ebx+offs_cont_shared_state+4] ;ebx = &texture_hash_table + mov ecx,[h] + and ecx,0xff + shl ecx,2 + 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 + je @f + mov [eax+offs_text_prev],eax + @@: + mov [ecx],eax + + mov ebx,[h] + mov [eax+offs_text_handle],ebx + + ret +endp + +align 4 +proc glInitTextures uses eax edx, context:dword + ; textures + mov edx,[context] + mov dword[edx+offs_cont_texture_2d_enabled],0 + stdcall find_texture,edx,0 + mov dword[edx+offs_cont_current_texture],eax + ret +endp + +;void glGenTextures(int n, unsigned int *textures) +;{ +; GLContext *c=gl_get_context(); +; int max,i; +; GLTexture *t; +; +; max=0; +; for(i=0;ishared_state.texture_hash_table[i]; +; while (t!=NULL) { +; if (t->handle>max) max=t->handle; +; t=t->next; +; } +; +; } +; for(i=0;icurrent_texture) { +; glBindTexture(GL_TEXTURE_2D,0); +; } +; free_texture(c,textures[i]); +; } +; } +;} + +align 4 +proc glopBindTexture uses eax ebx edx, context:dword, p:dword + mov ebx,[p] + mov edx,[context] + +; assert(p[1].i == GL_TEXTURE_2D && texture >= 0); + + ;[ebx+8] = p[2] + stdcall find_texture, edx,dword[ebx+8] + cmp eax,0 ;NULL + jne @f + stdcall alloc_texture, edx,dword[ebx+8] + @@: + mov [edx+offs_cont_current_texture],eax + ret +endp + +align 4 +proc glopTexImage2D, context:dword, p:dword +;{ +; int target=p[1].i; +; int level=p[2].i; +; int components=p[3].i; +; int width=p[4].i; +; int height=p[5].i; +; int border=p[6].i; +; int format=p[7].i; +; int type=p[8].i; +; void *pixels=p[9].p; +; GLImage *im; +; unsigned char *pixels1; +; int do_free; +; +; if (!(target == GL_TEXTURE_2D && level == 0 && components == 3 && +; border == 0 && format == GL_RGB && +; type == GL_UNSIGNED_BYTE)) { +; gl_fatal_error("glTexImage2D: combinaison of parameters not handled"); +; } +; +; do_free=0; +; if (width != 256 || height != 256) { +; pixels1 = gl_malloc(256 * 256 * 3); +; /* no interpolation is done here to respect the original image aliasing ! */ +; gl_resizeImageNoInterpolate(pixels1,256,256,pixels,width,height); +; do_free=1; +; width=256; +; height=256; +; } else { +; pixels1=pixels; +; } +; +; im=&c->current_texture->images[level]; +; im->xsize=width; +; im->ysize=height; +; if (im->pixmap!=NULL) gl_free(im->pixmap); +;#if TGL_FEATURE_RENDER_BITS == 24 +; im->pixmap=gl_malloc(width*height*3); +; if(im->pixmap) { +; memcpy(im->pixmap,pixels1,width*height*3); +; } +;#elif TGL_FEATURE_RENDER_BITS == 32 +; im->pixmap=gl_malloc(width*height*4); +; if(im->pixmap) { +; gl_convertRGB_to_8A8R8G8B(im->pixmap,pixels1,width,height); +; } +;#elif TGL_FEATURE_RENDER_BITS == 16 +; im->pixmap=gl_malloc(width*height*2); +; if(im->pixmap) { +; gl_convertRGB_to_5R6G5B(im->pixmap,pixels1,width,height); +; } +;#else +;#error TODO +;#endif +; if (do_free) gl_free(pixels1); + ret +endp + +; TODO: not all tests are done +align 4 +proc glopTexEnv, context:dword, p:dword + +; int target=p[1].i; +; int pname=p[2].i; +; int param=p[3].i; +; +; if (target != GL_TEXTURE_ENV) { +; error: +; gl_fatal_error("glTexParameter: unsupported option"); +; } +; +; if (pname != GL_TEXTURE_ENV_MODE) goto error; +; +; if (param != GL_DECAL) goto error; + ret +endp + +; TODO: not all tests are done +align 4 +proc glopTexParameter, context:dword, p:dword + +; int target=p[1].i; +; int pname=p[2].i; +; int param=p[3].i; +; +; if (target != GL_TEXTURE_2D) { +; error: +; gl_fatal_error("glTexParameter: unsupported option"); +; } +; +; switch(pname) { +; case GL_TEXTURE_WRAP_S: +; case GL_TEXTURE_WRAP_T: +; if (param != GL_REPEAT) goto error; +; break; +; } + ret +endp + +align 4 +proc glopPixelStore, context:dword, p:dword + +; int pname=p[1].i; +; int param=p[2].i; +; +; if (pname != GL_UNPACK_ALIGNMENT || +; param != 1) { +; gl_fatal_error("glPixelStore: unsupported option"); +; } + ret +endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/tinygl.asm b/programs/develop/libraries/TinyGL/asm_fork/tinygl.asm new file mode 100644 index 0000000000..db481bfaaa --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/tinygl.asm @@ -0,0 +1,204 @@ +format MS COFF +public EXPORTS +section '.flat' code readable align 16 + +include '../../../../../programs/proc32.inc' +include '../../../../../programs/macros.inc' + +DEBUG equ 0 + +include 'zgl.inc' +include 'zmath.asm' +include 'clip.asm' +include 'vertex.asm' +include 'api.asm' +include 'list.asm' +include 'init.asm' +include 'matrix.asm' +include 'texture.asm' +include 'misc.asm' +include 'clear.asm' +include 'light.asm' +include 'select.asm' +;include 'get.asm' +;include 'error.asm' +include 'zbuffer.asm' +include 'zline.asm' +;include 'zdither.asm' +include 'ztriangle.asm' +;include 'image_util.asm' +;include 'msghandling.asm' +include 'arrays.asm' + +include 'kosgl.asm' + +if DEBUG +include 'info_fun_float.inc' +end if + +; *** +glVertex2d: ;(double ,double) +glVertex2fv: ;(float *) +glVertex2dv: ;(double *) +glVertex3d: ;(double ,double ,double) +glVertex3dv: ;(double *) +glVertex4d: ;(double ,double ,double, double ) +glVertex4fv: ;(float *) +glVertex4dv: ;(double *) +glColor3d: ;(double ,double ,double) +glColor3dv: ;(double *) +glColor4d: ;(double ,double ,double, double ) +glColor4dv: ;(double *) +glNormal3d: ;(double ,double ,double) +glNormal3dv: ;(double *) +glTexCoord1f: ;(float) +glTexCoord1d: ;(double) +glTexCoord1fv: ;(float *) +glTexCoord1dv: ;(double *) +glTexCoord2d: ;(double ,double) +glTexCoord2dv: ;(double *) +glTexCoord3f: ;(float ,float ,float) +glTexCoord3d: ;(double ,double ,double) +glTexCoord3fv: ;(float *) +glTexCoord3dv: ;(double *) +glTexCoord4d: ;(double ,double ,double, double ) +glTexCoord4fv: ;(float *) +glTexCoord4dv: ;(double *) +glGenLists: ;(int range) +glNewList: ;(unsigned int list,int mode) +glEndList: ;(void) +glGenTextures: ;(int n, unsigned int *textures) +glDeleteTextures: ;(int n, const unsigned int *textures) +glGetIntegerv: ;(int pname,int *params) +glGetFloatv: ;(int pname, float *v) + +; *** +glopLight: +glopClear: +glopCallList: + +if DEBUG +align 4 +txt_nl db 13,10,0 +txt_sp db ' ',0 +txt_zp_sp db ', ',0 +m_1 db '(1)',13,10,0 +m_2 db '(2)',13,10,0 +m_3 db '(3)',13,10,0 +m_4 db '(4)',13,10,0 +m_5 db '(5)',13,10,0 + +buf_param rb 80 + +align 4 +proc str_n_cat uses eax ecx edi esi, str1:dword, str2:dword, n:dword + mov esi,dword[str2] + mov ecx,dword[n] + mov edi,dword[str1] + stdcall str_len,edi + add edi,eax + cld + repne movsb + mov byte[edi],0 + ret +endp + +;input: +; eax - число +; edi - буфер для строки +; len - длинна буфера +;output: +align 4 +proc convert_int_to_str, len:dword +pushad + mov esi,[len] + add esi,edi + dec esi + call .str +popad + ret +endp + +align 4 +.str: + mov ecx,0x0a ;задается система счисления изменяются регистры ebx,eax,ecx,edx входные параметры eax - число + ;преревод числа в ASCII строку взодные данные ecx=система счисленя edi адрес куда записывать, будем строку, причем конец переменной + cmp eax,ecx ;сравнить если в eax меньше чем в ecx то перейти на @@-1 т.е. на pop eax + jb @f + xor edx,edx ;очистить edx + div ecx ;разделить - остаток в edx + push edx ;положить в стек + ;dec edi ;смещение необходимое для записи с конца строки + call .str ;перейти на саму себя т.е. вызвать саму себя и так до того момента пока в eax не станет меньше чем в ecx + pop eax + @@: ;cmp al,10 ;проверить не меньше ли значение в al чем 10 (для системы счисленя 10 данная команда - лишная)) + cmp edi,esi + jge @f + or al,0x30 ;данная команда короче чем две выше + stosb ;записать элемент из регистра al в ячеку памяти es:edi + mov byte[edi],0 ;в конец строки ставим 0, что-бы не вылазил мусор + @@: + ret ;пока в стеке храниться кол-во вызовов то столько раз мы и будем вызываться +end if + +align 4 +f_kosgl_1 db 'kosglMakeCurrent',0 +err_0 db 'Error while initializing Z buffer',13,10,0 +f_zb_opn db ' ZB_open',0 +err_1 db 'gl_malloc(sizeof.ZBuffer)==0',13,10,0 +err_2 db 'gl_malloc(xsize*ysize*4)==0',13,10,0 +err_3 db 'bit mode not correct',13,10,0 +f_vp db ' glViewport',0 +err_4 db 'error while resizing display',13,10,0 +err_5 db 'size too small',13,10,0 +f_clipcode db ' gl_clipcode',0 +f_ttv db ' gl_transform_to_viewport',0 +f_vt db ' gl_vertex_transform',0 +f_ev db ' gl_eval_viewport',0 +f_zbz db ' ZB_line_z',0 +f_zb db ' ZB_line',0 +f_cl1 db ' ClipLine1',0 +f_m4m db 'gl_M4_Mul',0 +f_m4ml db 'gl_M4_MulLeft',0 + +align 4 +proc dbg_print, fun:dword, mes:dword +pushad + mov eax,63 + mov ebx,1 + + mov esi,[fun] + @@: + mov cl,byte[esi] + int 0x40 + inc esi + cmp byte[esi],0 + jne @b + mov cl,':' + int 0x40 + mov cl,' ' + int 0x40 + mov esi,[mes] + @@: + mov cl,byte[esi] + int 0x40 + inc esi + cmp byte[esi],0 + jne @b +popad + ret +endp + +align 16 +EXPORTS: +macro E_LIB n +{ + dd sz_#n, n +} +include 'export.inc' + dd 0,0 +macro E_LIB n +{ + sz_#n db `n,0 +} +include 'export.inc' diff --git a/programs/develop/libraries/TinyGL/asm_fork/vertex.asm b/programs/develop/libraries/TinyGL/asm_fork/vertex.asm new file mode 100644 index 0000000000..cb8b74dc6d --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/vertex.asm @@ -0,0 +1,651 @@ + +align 4 +proc glopNormal uses ecx esi edi, context:dword, p:dword + mov esi,[p] + add esi,4 + mov edi,[context] + add edi,offs_cont_current_normal + mov ecx,4 + rep movsd + mov dword[esi],0.0 ;context.current_normal.W = 0.0 + ret +endp + +align 4 +proc glopTexCoord uses ecx esi edi, context:dword, p:dword + mov esi,[p] + add esi,4 + mov edi,[context] + add edi,offs_cont_current_tex_coord + mov ecx,4 + rep movsd + ret +endp + +align 4 +proc glopEdgeFlag uses eax ebx, context:dword, p:dword + mov eax,[context] + mov ebx,[p] + mov ebx,[ebx+4] ;ebx = p[1] + mov dword[eax+offs_cont_current_edge_flag],ebx + ret +endp + +align 4 +proc glopColor uses eax ecx esi edi, context:dword, p:dword +locals + q rd 7 +endl + ;current_color[3] = p[1-4] + ;longcurrent_color[2] = p[5-7] + mov esi,[p] + add esi,4 + mov edi,[context] + add edi,offs_cont_current_color + mov ecx,7 + rep movsd + + mov eax,[context] + cmp dword[eax+offs_cont_color_material_enabled],1 + jne @f + mov dword[q],OP_Material + mov ecx,[eax+offs_cont_current_color_material_mode] + mov dword[q+4],ecx + mov ecx,[eax+offs_cont_current_color_material_type] + mov dword[q+8],ecx + mov esi,[p] + add esi,4 + mov edi,dword[q+12] ;edi = [q3] + mov ecx,4 + rep movsd + stdcall glopMaterial, eax,[q] + @@: + ret +endp + +align 4 +proc gl_eval_viewport uses eax, context:dword +locals + zsize dd ? ;float +endl + mov eax,[context] + add eax,offs_cont_viewport ;eax = (GLViewport*) v + + mov dword[zsize],(1 shl (ZB_Z_BITS + ZB_POINT_Z_FRAC_BITS)) + fild dword[zsize] + fstp dword[zsize] + + fld1 + fld1 + fadd st1,st0 ;st1 = 2.0 + fdiv st0,st1 ;st0 = 0.5 + + fild dword[eax+offs_vpor_xsize] + fsub st0,st1 + fdiv st0,st2 + fst dword[eax+offs_vpor_scale+offs_X] + fiadd dword[eax+offs_vpor_xmin] + fstp dword[eax+offs_vpor_trans+offs_X] + + fild dword[eax+offs_vpor_ysize] + fsub st0,st1 + fdiv st0,st2 + fchs + fst dword[eax+offs_vpor_scale+offs_Y] + fchs + fiadd dword[eax+offs_vpor_ymin] + fstp dword[eax+offs_vpor_trans+offs_Y] + + fld dword[zsize] + fsub st0,st1 + fdiv st0,st2 + fchs + fst dword[eax+offs_vpor_scale+offs_Z] + fchs + mov dword[zsize],(1 shl ZB_POINT_Z_FRAC_BITS) / 2 + fiadd dword[zsize] + fstp dword[eax+offs_vpor_trans+offs_Z] +if DEBUG ;gl_eval_viewport + stdcall dbg_print,f_ev,txt_nl + add eax,offs_vpor_scale + stdcall gl_print_matrix,eax,1 + add eax,8 + stdcall gl_print_matrix,eax,1 +end if + ret +endp + + +align 4 +proc glopBegin uses eax ebx ecx edx, context:dword, p:dword +locals + tmp M4 +endl +; assert(c->in_begin == 0); + + mov edx,[context] + mov ebx,[p] + mov ebx,[ebx+4] ;ebx = p[1] + mov [edx+offs_cont_begin_type],ebx + mov dword[edx+offs_cont_in_begin],1 + mov dword[edx+offs_cont_vertex_n],0 + mov dword[edx+offs_cont_vertex_cnt],0 + + bt dword[edx+offs_cont_matrix_model_projection_updated],0 + jnc .end_mmpu + + cmp dword[edx+offs_cont_lighting_enabled],0 ;if(context.lighting_enabled) + je @f + ; precompute inverse modelview + mov ebx,ebp + sub ebx,64 + stdcall gl_M4_Inv, ebx, edx+offs_cont_matrix_stack_ptr + stdcall gl_M4_Transpose, edx+offs_cont_matrix_model_view_inv, ebx + jmp .end_if_0 + @@: + mov ecx,edx + add ecx,offs_cont_matrix_model_projection + ; precompute projection matrix + stdcall gl_M4_Mul, ecx,dword[edx+offs_cont_matrix_stack_ptr+4],dword[edx+offs_cont_matrix_stack_ptr] +;if DEBUG ;glopBegin + ;stdcall gl_print_matrix,ecx,4 + ;stdcall gl_print_matrix,[edx+offs_cont_matrix_stack_ptr+4],4 + ;stdcall gl_print_matrix,[edx+offs_cont_matrix_stack_ptr],4 +;end if + ; test to accelerate computation + mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],0 + fldz + fld dword[ecx+12*4] + fcomp st1 + fstsw ax + sahf + jne .end_if_0 + fld dword[ecx+13*4] + fcomp st1 + fstsw ax + sahf + jne .end_if_0 + fld dword[ecx+14*4] + fcomp st1 + fstsw ax + sahf + jne .end_if_0 + mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],1 + .end_if_0: + + ; test if the texture matrix is not Identity + stdcall gl_M4_IsId,edx+offs_cont_matrix_stack_ptr+8 + xor edx,1 + mov ebx,[context] + mov dword[ebx+offs_cont_apply_texture_matrix],edx + + mov edx,[context] + mov dword[edx+offs_cont_matrix_model_projection_updated],0 + .end_mmpu: + + ; viewport + cmp dword[edx+offs_cont_viewport+offs_vpor_updated],0 ;if (context.viewport.updated) + je @f + stdcall gl_eval_viewport,edx + mov dword[edx+offs_cont_viewport+offs_vpor_updated],0 + @@: + ; triangle drawing functions + cmp dword[edx+offs_cont_render_mode],GL_SELECT + jne @f + mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_select + mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_select + jmp .end_if_2 + @@: + + cmp dword[edx+offs_cont_polygon_mode_front],GL_POINT + jne @f + mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_point + jmp .end_if_1 + @@: + cmp dword[edx+offs_cont_polygon_mode_front],GL_LINE + jne @f + mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_line + jmp .end_if_1 + @@: ;default: + mov dword[edx+offs_cont_draw_triangle_front],gl_draw_triangle_fill + .end_if_1: + + cmp dword[edx+offs_cont_polygon_mode_back],GL_POINT + jne @f + mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_point + jmp .end_if_2 + @@: + cmp dword[edx+offs_cont_polygon_mode_back],GL_LINE + jne @f + mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_line + jmp .end_if_2 + @@: ;default: + mov dword[edx+offs_cont_draw_triangle_back],gl_draw_triangle_fill + .end_if_2: + ret +endp + +; coords, tranformation , clip code and projection +; TODO : handle all cases +align 4 +proc gl_vertex_transform, context:dword, v:dword +pushad + mov eax,[context] + mov edx,[v] + cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled) + je .els_0 + ; eye coordinates needed for lighting + mov ebx,dword[eax+offs_cont_matrix_stack_ptr] + ;;;mov edx,[v] + finit + fld dword[edx+offs_vert_coord+offs_X] + fld dword[edx+offs_vert_coord+offs_Y] + fld dword[edx+offs_vert_coord+offs_Z] + + mov ecx,4 + .cycle_0: + fld dword[ebx] ;st0 = m[0] + fmul st0,st3 ;st0 *= v.coord.X + fld dword[ebx+4] ;st0 = m[1] + fmul st0,st3 ;st0 *= v.coord.Y + fld dword[ebx+8] ;st0 = m[2] + fmul st0,st3 ;st0 *= v.coord.Z + fadd dword[ebx+12] ;st0 += m[3] + fadd st0,st1 ;st0 += v.coord.Z * m[2] + fadd st0,st2 ;st0 += v.coord.Y * m[1] + fstp dword[edx+offs_vert_ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3] + ffree st0 + fincstp + ffree st0 + fincstp + add ebx,16 ;следущая строка матрицы + add edx,4 ;следущая координата вектора + loop .cycle_0 + + ; projection coordinates + mov ebx,dword[eax+offs_cont_matrix_stack_ptr+4] + mov edx,[v] + finit + fld dword[edx+offs_vert_ec+offs_X] + fld dword[edx+offs_vert_ec+offs_Y] + fld dword[edx+offs_vert_ec+offs_Z] + + mov ecx,4 + .cycle_1: + fld dword[ebx] ;st0 = m[0] + fmul st0,st3 ;st0 *= v.ec.X + fld dword[ebx+4] ;st0 = m[1] + fmul st0,st3 ;st0 *= v.ec.Y + fld dword[ebx+8] ;st0 = m[2] + fmul st0,st3 ;st0 *= v.ec.Z + fadd dword[ebx+12] ;st0 += m[3] + fadd st0,st1 ;st0 += v.ec.Z * m[2] + fadd st0,st2 ;st0 += v.ec.Y * m[1] + fstp dword[edx+offs_vert_pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + m[3] + ffree st0 + fincstp + ffree st0 + fincstp + add ebx,16 ;следущая строка матрицы + add edx,4 ;следущая координата вектора + loop .cycle_1 + + mov ebx,eax + add ebx,offs_cont_matrix_model_view_inv + mov edi,eax + add edi,offs_cont_current_normal + mov edx,[v] + finit + fld dword[edi+offs_X] + fld dword[edi+offs_Y] + fld dword[edi+offs_Z] + + mov ecx,3 + .cycle_2: + fld dword[ebx] ;st0 = m[0] + fmul st0,st3 ;st0 *= n.X + fld dword[ebx+4] ;st0 = m[1] + fmul st0,st3 ;st0 *= n.Y + fld dword[ebx+8] ;st0 = m[2] + fmul st0,st3 ;st0 *= n.Z + fadd st0,st1 ;st0 += n.Z * m[2] + fadd st0,st2 ;st0 += n.Y * m[1] + fstp dword[edx+offs_vert_normal] ;v.normal.X = n.X * m[0] + n.Y * m[1] + n.Z * m[2] + ffree st0 + fincstp + ffree st0 + fincstp + add ebx,16 ;следущая строка матрицы + add edx,4 ;следущая координата вектора + loop .cycle_2 + + cmp dword[eax+offs_cont_normalize_enabled],0 + je .end_els +;stdcall gl_V3_Norm(&v->normal) + jmp .end_els + .els_0: + ; no eye coordinates needed, no normal + ; NOTE: W = 1 is assumed + mov ebx,eax + add ebx,offs_cont_matrix_model_projection + + ;;;mov edx,[v] + finit + fld dword[edx+offs_vert_coord+offs_X] + fld dword[edx+offs_vert_coord+offs_Y] + fld dword[edx+offs_vert_coord+offs_Z] + + mov esi,edx + add esi,offs_vert_pc + + fld dword[ebx] ;st0 = m[0] + fmul st0,st3 ;st0 *= v.coord.X + fld dword[ebx+4] ;st0 = m[1] + fmul st0,st3 ;st0 *= v.coord.Y + fld dword[ebx+8] ;st0 = m[2] + fmul st0,st3 ;st0 *= v.coord.Z + fadd dword[ebx+12] ;st0 += m[3] + fadd st0,st1 ;st0 += v.coord.Z * m[2] + fadd st0,st2 ;st0 += v.coord.Y * m[1] + fstp dword[esi] ;v.pc.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3] + ffree st0 + fincstp + ffree st0 + fincstp + fld dword[ebx+16] ;st0 = m[4] + fmul st0,st3 ;st0 *= v.coord.X + fld dword[ebx+20] ;st0 = m[5] + fmul st0,st3 ;st0 *= v.coord.Y + fld dword[ebx+24] ;st0 = m[6] + fmul st0,st3 ;st0 *= v.coord.Z + fadd dword[ebx+28] ;st0 += m[7] + fadd st0,st1 ;st0 += v.coord.Z * m[6] + fadd st0,st2 ;st0 += v.coord.Y * m[5] + fstp dword[esi+4] ;v.pc.X = v.coord.X * m[4] + v.coord.Y * m[5] + v.coord.Z * m[6] + m[7] + ffree st0 + fincstp + ffree st0 + fincstp + fld dword[ebx+32] ;st0 = m[8] + fmul st0,st3 ;st0 *= v.coord.X + fld dword[ebx+36] ;st0 = m[9] + fmul st0,st3 ;st0 *= v.coord.Y + fld dword[ebx+40] ;st0 = m[10] + fmul st0,st3 ;st0 *= v.coord.Z + fadd dword[ebx+44] ;st0 += m[11] + fadd st0,st1 ;st0 += v.coord.Z * m[10] + fadd st0,st2 ;st0 += v.coord.Y * m[9] + fstp dword[esi+8] ;v.pc.X = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11] + + cmp dword[eax+offs_cont_matrix_model_projection_no_w_transform],0 + je .els_1 + ;if (context.matrix_model_projection_no_w_transform) + mov ebx,dword[ebx+60] ;ebx = m[15] + mov dword[esi+12],ebx ;v.pc.W = m[15] + jmp .end_els + .els_1: + ffree st0 + fincstp + ffree st0 + fincstp + fld dword[ebx+48] ;st0 = m[12] + fmul st0,st3 ;st0 *= v.coord.X + fld dword[ebx+52] ;st0 = m[13] + fmul st0,st3 ;st0 *= v.coord.Y + fld dword[ebx+56] ;st0 = m[14] + fmul st0,st3 ;st0 *= v.coord.Z + fadd dword[ebx+60] ;st0 += m[15] + fadd st0,st1 ;st0 += v.coord.Z * m[14] + fadd st0,st2 ;st0 += v.coord.Y * m[13] + fstp dword[esi+12] ;v.pc.W = v.coord.X * m[12] + v.coord.Y * m[13] + v.coord.Z * m[14] + m[15] + .end_els: +if DEBUG ;gl_vertex_transform + stdcall dbg_print,f_vt,txt_nl + mov edx,[v] + add edx,offs_vert_pc + stdcall gl_print_matrix,edx,1 +end if + mov edx,[v] + stdcall gl_clipcode, dword[edx+offs_vert_pc+offs_X], dword[edx+offs_vert_pc+offs_Y],\ + dword[edx+offs_vert_pc+offs_Z], dword[edx+offs_vert_pc+offs_W] + mov dword[edx+offs_vert_clip_code],eax +popad + ret +endp + +align 4 +proc glopVertex, context:dword, p:dword +locals + ;ebx = GLVertex * v + n dd ? ;ebp-4 +endl +pushad + mov edx,[context] + +; assert(c->in_begin != 0); + + mov ecx,[edx+offs_cont_vertex_n] + mov [n],ecx + inc dword[edx+offs_cont_vertex_cnt] + + ; quick fix to avoid crashes on large polygons + mov ecx,[edx+offs_cont_vertex_max] + cmp dword[n],ecx + jl @f + shl dword[edx+offs_cont_vertex_max],1 ; just double size + imul ecx,2*sizeof.GLVertex + stdcall gl_malloc,ecx + cmp eax,0 + jne .no_err +;gl_fatal_error("unable to allocate GLVertex array.\n"); + .no_err: + mov edi,eax + mov ebx,eax + mov esi,[edx+offs_cont_vertex] + mov ecx,[n] + imul ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb + rep movsd + stdcall gl_free,dword[edx+offs_cont_vertex] + mov dword[edx+offs_cont_vertex],ebx + @@: + ; new vertex entry + mov ebx,[n] + imul ebx,sizeof.GLVertex + add ebx,[edx+offs_cont_vertex] + inc dword[n] + + mov esi,[p] + add esi,4 + mov edi,ebx + add edi,offs_vert_coord ;edi = &v.coord + mov ecx,4 + rep movsd + + stdcall gl_vertex_transform, edx, ebx + + ; color + + cmp dword[edx+offs_cont_lighting_enabled],0 + je .els_0 + stdcall gl_shade_vertex, edx,ebx + jmp @f + .els_0: + mov eax,[edx+offs_cont_current_color] + mov [ebx+offs_vert_color],eax + @@: + + ; tex coords + cmp dword[edx+offs_cont_texture_2d_enabled],0 + je @f + cmp dword[edx+offs_cont_apply_texture_matrix],0 + je .els_1 +; gl_M4_MulV4(&v->tex_coord, c->matrix_stack_ptr[2], &c->current_tex_coord); + jmp @f + .els_1: + mov eax,[edx+offs_cont_current_tex_coord] + mov [ebx+offs_vert_tex_coord],eax + @@: + + ; precompute the mapping to the viewport + cmp dword[ebx+offs_vert_clip_code],0 + jne @f + stdcall gl_transform_to_viewport, edx,ebx + @@: + + ; edge flag + mov eax,[edx+offs_cont_current_edge_flag] + mov dword[ebx+offs_vert_edge_flag],eax ;v.edge_flag = context.current_edge_flag + + cmp dword[edx+offs_cont_begin_type],GL_POINTS + jne @f + stdcall gl_draw_point, edx, dword[edx+offs_cont_vertex] ;dword[edx+...] = &context.vertex[0] + mov dword[n],0 + jmp .end_f + @@: + cmp dword[edx+offs_cont_begin_type],GL_LINES + jne @f + cmp dword[n],2 + jne .end_f + mov eax,[edx+offs_cont_vertex] + push eax + add eax,sizeof.GLVertex + push eax + stdcall gl_draw_line, edx + xor eax,eax + mov dword[n],eax + jmp .end_f + @@: + cmp dword[edx+offs_cont_begin_type],GL_LINE_STRIP + je .li_loop + cmp dword[edx+offs_cont_begin_type],GL_LINE_LOOP + jne @f + .li_loop: + cmp dword[n],1 + jne .els_2 + mov esi,[edx+offs_cont_vertex] + mov edi,esi + add edi,2*sizeof.GLVertex + mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb + rep movsd ;context.vertex[2] = context.vertex[0] + jmp .end_f + .els_2: + cmp dword[n],2 + jne .end_f ;else if (n == 2) + mov eax,[edx+offs_cont_vertex] + push eax + add eax,sizeof.GLVertex + push eax + stdcall gl_draw_line, edx + mov edi,[edx+offs_cont_vertex] + mov esi,edi + add esi,sizeof.GLVertex + mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb + rep movsd ;context.vertex[0] = context.vertex[1] + mov dword[n],1 + jmp .end_f + @@: + cmp dword[edx+offs_cont_begin_type],GL_TRIANGLES + jne @f + cmp dword[n],3 + jne .end_f +; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); + xor eax,eax + mov dword[n],eax + jmp .end_f + @@: + cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_STRIP + jne @f +; if (c->vertex_cnt >= 3) { +; if (n == 3) +; n = 0; +; /* needed to respect triangle orientation */ +; switch(c->vertex_cnt & 1) { +; case 0: +; gl_draw_triangle(c,&c->vertex[2],&c->vertex[1],&c->vertex[0]); +; break; +; default: +; case 1: +; gl_draw_triangle(c,&c->vertex[0],&c->vertex[1],&c->vertex[2]); +; break; +; } +; } + jmp .end_f + @@: + cmp dword[edx+offs_cont_begin_type],GL_TRIANGLE_FAN + jne @f + cmp dword[n],2 + jne .end_f +; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); +; c->vertex[1] = c->vertex[2]; + mov dword[n],2 + jmp .end_f + @@: + cmp dword[edx+offs_cont_begin_type],GL_QUADS + jne @f + cmp dword[n],4 + jne .end_f +; c->vertex[2].edge_flag = 0; +; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); +; c->vertex[2].edge_flag = 1; +; c->vertex[0].edge_flag = 0; +; gl_draw_triangle(c, &c->vertex[0], &c->vertex[2], &c->vertex[3]); + xor eax,eax + mov dword[n],eax + jmp .end_f + @@: + cmp dword[edx+offs_cont_begin_type],GL_QUAD_STRIP + jne @f + cmp dword[n],2 + jne .end_f +; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); +; gl_draw_triangle(c, &c->vertex[1], &c->vertex[3], &c->vertex[2]); +; for (i = 0; i < 2; i++) +; c->vertex[i] = c->vertex[i + 2]; + mov dword[n],2 + jmp .end_f + @@: + cmp dword[edx+offs_cont_begin_type],GL_POLYGON + jne @f + ;... + jmp .end_f + @@: +; default: +; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type); +; } + .end_f: + + mov ecx,[n] + mov [edx+offs_cont_vertex_n],ecx +popad + ret +endp + +align 4 +proc glopEnd uses eax ebx, context:dword, p:dword + mov eax,[context] +; assert(c->in_begin == 1); + + cmp dword[eax+offs_cont_begin_type],GL_LINE_LOOP + jne .else_i + cmp dword[eax+offs_cont_vertex_cnt],3 + jl .end_i + mov ebx,[eax+offs_cont_vertex] + push ebx + add ebx,2*sizeof.GLVertex + push ebx + stdcall gl_draw_line, eax + jmp .end_i + .else_i: + cmp dword[eax+offs_cont_begin_type],GL_POLYGON + jne .end_i + mov ebx,dword[eax+offs_cont_vertex_cnt] + @@: ;while (ebx >= 3) + cmp ebx,3 + jl .end_i + dec ebx +; gl_draw_triangle(c, &c->vertex[i], &c->vertex[0], &c->vertex[i - 1]); + jmp @b + .end_i: + mov dword[eax+offs_cont_in_begin],0 + ret +endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/zbuffer.asm b/programs/develop/libraries/TinyGL/asm_fork/zbuffer.asm new file mode 100644 index 0000000000..85a799e5e3 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zbuffer.asm @@ -0,0 +1,545 @@ +; +; +; Z buffer: 16 bits Z / 16 bits color +; +; +;include 'zbuffer.inc' + +;output: +; eax - указатель на ZBuffer (0 если не удача) +align 4 +proc ZB_open uses ecx edi, xsize:dword, ysize:dword, mode:dword,\ + nb_colors:dword, color_indexes:dword, color_table:dword, frame_buffer:dword + + stdcall gl_malloc, sizeof.ZBuffer + cmp eax,0 + jne @f + stdcall dbg_print,f_zb_opn,err_1 + jmp .end_f + @@: + mov edi,eax + + mov eax,[ysize] + mov [edi+offs_zbuf_ysize],eax + mov eax,[xsize] + mov [edi+offs_zbuf_xsize],eax + imul eax,PSZB + add eax,3 + and eax,not 3 + mov [edi+offs_zbuf_linesize],eax + mov eax,[mode] + mov [edi+offs_zbuf_mode],eax + +if TGL_FEATURE_8_BITS eq 1 + cmp eax,ZB_MODE_INDEX + jne @f +;ZB_initDither(edi, nb_colors, color_indexes, color_table); + jmp .end_s + @@: +end if +if TGL_FEATURE_32_BITS eq 1 + cmp eax,ZB_MODE_RGBA + je .correct +end if +if TGL_FEATURE_24_BITS eq 1 + cmp eax,ZB_MODE_RGB24 + je .correct +end if + cmp eax,ZB_MODE_5R6G5B + jne @f + .correct: + mov dword[edi+offs_zbuf_nb_colors],0 + jmp .end_s + @@: ;default: + stdcall dbg_print,f_zb_opn,err_3 + jmp .error + .end_s: + + mov ecx,[edi+offs_zbuf_xsize] + imul ecx,[edi+offs_zbuf_ysize] + shl ecx,2 ;*= sizeof(unsigned short) + + stdcall gl_malloc, ecx + mov [edi+offs_zbuf_zbuf],eax + cmp eax,0 + jne @f + stdcall dbg_print,f_zb_opn,err_2 + jmp .error + @@: + + mov dword[edi+offs_zbuf_frame_buffer_allocated],0 + mov dword[edi+offs_zbuf_pbuf],0 ;NULL + + mov dword[edi+offs_zbuf_current_texture],0 ;NULL + + mov eax,edi + jmp .end_f + .error: + stdcall gl_free,edi + xor eax,eax + .end_f: + ret +endp + +;void ZB_close(ZBuffer * zb) +;{ +if TGL_FEATURE_8_BITS eq 1 +; if (zb->mode == ZB_MODE_INDEX) +; ZB_closeDither(zb); +end if +; +; if (zb->frame_buffer_allocated) +; gl_free(zb->pbuf); +; +; gl_free(zb->zbuf); +; gl_free(zb); +;} + +align 4 +proc ZB_resize uses eax ebx ecx edi esi, zb:dword, frame_buffer:dword, xsize:dword, ysize:dword + mov ebx,[zb] + + ; xsize must be a multiple of 4 + mov edi,[xsize] + and edi,not 3 + mov esi,[ysize] + + mov [ebx+offs_zbuf_xsize], edi + mov [ebx+offs_zbuf_ysize], esi + + mov eax,edi + imul eax,PSZB + add eax,3 + and eax,not 3 + mov [ebx+offs_zbuf_linesize],eax ;zb.linesize = (xsize * PSZB + 3) & ~3 + + mov ecx,edi + imul ecx,esi + shl ecx,2 ;*= sizeof(unsigned short) + + stdcall gl_free,dword[ebx+offs_zbuf_zbuf] + stdcall gl_malloc,ecx + mov [ebx+offs_zbuf_zbuf],eax + + cmp dword[ebx+offs_zbuf_frame_buffer_allocated],0 + je @f + stdcall gl_free,dword[ebx+offs_zbuf_pbuf] + @@: + + cmp dword[frame_buffer],0 + jne .els_0 + inc esi + imul esi,dword[ebx+offs_zbuf_linesize] + stdcall gl_malloc,esi + mov dword[ebx+offs_zbuf_pbuf],eax + mov dword[ebx+offs_zbuf_frame_buffer_allocated],1 + jmp @f + .els_0: + mov eax,[frame_buffer] + mov dword[ebx+offs_zbuf_pbuf],eax + mov dword[ebx+offs_zbuf_frame_buffer_allocated],0 + @@: + ret +endp + +;static void ZB_copyBuffer(ZBuffer * zb, +; void *buf, +; int linesize) +;{ +; unsigned char *p1; +; PIXEL *q; +; int y, n; +; +; q = zb->pbuf; +; p1 = buf; +; n = zb->xsize * PSZB; +; for (y = 0; y < zb->ysize; y++) { +; memcpy(p1, q, n); +; p1 += linesize; +; q = (PIXEL *) ((char *) q + zb->linesize); +; } +;} +; +;#if TGL_FEATURE_RENDER_BITS == 16 + +;/* 32 bpp copy */ + +;#ifdef TGL_FEATURE_32_BITS + +;#define RGB16_TO_RGB32(p0,p1,v)\ +;{\ +; unsigned int g,b,gb;\ +; g = (v & 0x07E007E0) << 5;\ +; b = (v & 0x001F001F) << 3;\ +; gb = g | b;\ +; p0 = (gb & 0x0000FFFF) | ((v & 0x0000F800) << 8);\ +; p1 = (gb >> 16) | ((v & 0xF8000000) >> 8);\ +;} + +;static void ZB_copyFrameBufferRGB32(ZBuffer * zb, +; void *buf, +; int linesize) +;{ +; unsigned short *q; +; unsigned int *p, *p1, v, w0, w1; +; int y, n; +; +; q = zb->pbuf; +; p1 = (unsigned int *) buf; +; +; for (y = 0; y < zb->ysize; y++) { +; p = p1; +; n = zb->xsize >> 2; +; do { +; v = *(unsigned int *) q; +;#if BYTE_ORDER == BIG_ENDIAN +; RGB16_TO_RGB32(w1, w0, v); +;#else +; RGB16_TO_RGB32(w0, w1, v); +;#endif +; p[0] = w0; +; p[1] = w1; +; +; v = *(unsigned int *) (q + 2); +;#if BYTE_ORDER == BIG_ENDIAN +; RGB16_TO_RGB32(w1, w0, v); +;#else +; RGB16_TO_RGB32(w0, w1, v); +;#endif +; p[2] = w0; +; p[3] = w1; +; +; q += 4; +; p += 4; +; } while (--n > 0); +; +; p1 += linesize; +; } +;} + +;#endif + +;/* 24 bit packed pixel handling */ + +;#ifdef TGL_FEATURE_24_BITS + +;/* order: RGBR GBRG BRGB */ + +;/* XXX: packed pixel 24 bit support not tested */ +;/* XXX: big endian case not optimised */ + +;#if BYTE_ORDER == BIG_ENDIAN + +;#define RGB16_TO_RGB24(p0,p1,p2,v1,v2)\ +;{\ +; unsigned int r1,g1,b1,gb1,g2,b2,gb2;\ +; v1 = (v1 << 16) | (v1 >> 16);\ +; v2 = (v2 << 16) | (v2 >> 16);\ +; r1 = (v1 & 0xF800F800);\ +; g1 = (v1 & 0x07E007E0) << 5;\ +; b1 = (v1 & 0x001F001F) << 3;\ +; gb1 = g1 | b1;\ +; p0 = ((gb1 & 0x0000FFFF) << 8) | (r1 << 16) | (r1 >> 24);\ +; g2 = (v2 & 0x07E007E0) << 5;\ +; b2 = (v2 & 0x001F001F) << 3;\ +; gb2 = g2 | b2;\ +; p1 = (gb1 & 0xFFFF0000) | (v2 & 0xF800) | ((gb2 >> 8) & 0xff);\ +; p2 = (gb2 << 24) | ((v2 & 0xF8000000) >> 8) | (gb2 >> 16);\ +;} + +;#else + +;#define RGB16_TO_RGB24(p0,p1,p2,v1,v2)\ +;{\ +; unsigned int r1,g1,b1,gb1,g2,b2,gb2;\ +; r1 = (v1 & 0xF800F800);\ +; g1 = (v1 & 0x07E007E0) << 5;\ +; b1 = (v1 & 0x001F001F) << 3;\ +; gb1 = g1 | b1;\ +; p0 = ((gb1 & 0x0000FFFF) << 8) | (r1 << 16) | (r1 >> 24);\ +; g2 = (v2 & 0x07E007E0) << 5;\ +; b2 = (v2 & 0x001F001F) << 3;\ +; gb2 = g2 | b2;\ +; p1 = (gb1 & 0xFFFF0000) | (v2 & 0xF800) | ((gb2 >> 8) & 0xff);\ +; p2 = (gb2 << 24) | ((v2 & 0xF8000000) >> 8) | (gb2 >> 16);\ +;} + +;#endif + +;static void ZB_copyFrameBufferRGB24(ZBuffer * zb, +; void *buf, int linesize) +;{ +; unsigned short *q; +; unsigned int *p, *p1, w0, w1, w2, v0, v1; +; int y, n; +; +; q = zb->pbuf; +; p1 = (unsigned int *) buf; +; linesize = linesize * 3; +; +; for (y = 0; y < zb->ysize; y++) { +; p = p1; +; n = zb->xsize >> 2; +; do { +; v0 = *(unsigned int *) q; +; v1 = *(unsigned int *) (q + 2); +; RGB16_TO_RGB24(w0, w1, w2, v0, v1); +; p[0] = w0; +; p[1] = w1; +; p[2] = w2; + +; q += 4; +; p += 3; +; } while (--n > 0); +; +; (char *) p1 += linesize; +; } +;} + +;#endif + +;void ZB_copyFrameBuffer(ZBuffer * zb, void *buf, +; int linesize) +;{ +; switch (zb->mode) { +;#ifdef TGL_FEATURE_8_BITS +; case ZB_MODE_INDEX: +; ZB_ditherFrameBuffer(zb, buf, linesize >> 1); +; break; +;#endif +;#ifdef TGL_FEATURE_16_BITS +; case ZB_MODE_5R6G5B: +; ZB_copyBuffer(zb, buf, linesize); +; break; +;#endif +;#ifdef TGL_FEATURE_32_BITS +; case ZB_MODE_RGBA: +; ZB_copyFrameBufferRGB32(zb, buf, linesize >> 1); +; break; +;#endif +;#ifdef TGL_FEATURE_24_BITS +; case ZB_MODE_RGB24: +; ZB_copyFrameBufferRGB24(zb, buf, linesize >> 1); +; break; +;#endif +; default: +; assert(0); +; } +;} + +;#endif /* TGL_FEATURE_RENDER_BITS == 16 */ + +;#if TGL_FEATURE_RENDER_BITS == 24 + +;#define RGB24_TO_RGB16(r, g, b) \ +; ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3)) + +;/* XXX: not optimized */ +;static void ZB_copyFrameBuffer5R6G5B(ZBuffer * zb, +; void *buf, int linesize) +;{ +; PIXEL *q; +; unsigned short *p, *p1; +; int y, n; +; +; q = zb->pbuf; +; p1 = (unsigned short *) buf; +; +; for (y = 0; y < zb->ysize; y++) { +; p = p1; +; n = zb->xsize >> 2; +; do { +; p[0] = RGB24_TO_RGB16(q[0], q[1], q[2]); +; p[1] = RGB24_TO_RGB16(q[3], q[4], q[5]); +; p[2] = RGB24_TO_RGB16(q[6], q[7], q[8]); +; p[3] = RGB24_TO_RGB16(q[9], q[10], q[11]); +; q = (PIXEL *)((char *)q + 4 * PSZB); +; p += 4; +; } while (--n > 0); +; p1 = (unsigned short *)((char *)p1 + linesize); +; } +;} + +;void ZB_copyFrameBuffer(ZBuffer * zb, void *buf, +; int linesize) +;{ +; switch (zb->mode) { +;#ifdef TGL_FEATURE_16_BITS +; case ZB_MODE_5R6G5B: +; ZB_copyFrameBuffer5R6G5B(zb, buf, linesize); +; break; +;#endif +;#ifdef TGL_FEATURE_24_BITS +; case ZB_MODE_RGB24: +; ZB_copyBuffer(zb, buf, linesize); +; break; +;#endif +; default: +; assert(0); +; } +;} + +;#endif /* TGL_FEATURE_RENDER_BITS == 24 */ + +;#if TGL_FEATURE_RENDER_BITS == 32 + +;#define RGB32_TO_RGB16(v) \ +; (((v >> 8) & 0xf800) | (((v) >> 5) & 0x07e0) | (((v) & 0xff) >> 3)) + +;/* XXX: not optimized */ +;static void ZB_copyFrameBuffer5R6G5B(ZBuffer * zb, +; void *buf, int linesize) +;{ +; PIXEL *q; +; unsigned short *p, *p1; +; int y, n; +; +; q = zb->pbuf; +; p1 = (unsigned short *) buf; +; +; for (y = 0; y < zb->ysize; y++) { +; p = p1; +; n = zb->xsize >> 2; +; do { +; p[0] = RGB32_TO_RGB16(q[0]); +; p[1] = RGB32_TO_RGB16(q[1]); +; p[2] = RGB32_TO_RGB16(q[2]); +; p[3] = RGB32_TO_RGB16(q[3]); +; q += 4; +; p += 4; +; } while (--n > 0); +; p1 = (unsigned short *)((char *)p1 + linesize); +; } +;} +; +;void ZB_copyFrameBuffer(ZBuffer * zb, void *buf, +; int linesize) +;{ +; switch (zb->mode) { +;#ifdef TGL_FEATURE_16_BITS +; case ZB_MODE_5R6G5B: +; ZB_copyFrameBuffer5R6G5B(zb, buf, linesize); +; break; +;#endif +;#ifdef TGL_FEATURE_32_BITS +; case ZB_MODE_RGBA: +; ZB_copyBuffer(zb, buf, linesize); +; break; +;#endif +; default: +; assert(0); +; } +;} +; +;#endif /* TGL_FEATURE_RENDER_BITS == 32 */ +; +; +;/* +; * adr must be aligned on an 'int' +; */ +;void memset_s(void *adr, int val, int count) +;{ +; int i, n, v; +; unsigned int *p; +; unsigned short *q; +; +; p = adr; +; v = val | (val << 16); +; +; n = count >> 3; +; for (i = 0; i < n; i++) { +; p[0] = v; +; p[1] = v; +; p[2] = v; +; p[3] = v; +; p += 4; +; } +; +; q = (unsigned short *) p; +; n = count & 7; +; for (i = 0; i < n; i++) +; *q++ = val; +;} +; +;void memset_l(void *adr, int val, int count) +;{ +; int i, n, v; +; unsigned int *p; +; +; p = adr; +; v = val; +; n = count >> 2; +; for (i = 0; i < n; i++) { +; p[0] = v; +; p[1] = v; +; p[2] = v; +; p[3] = v; +; p += 4; +; } +; +; n = count & 3; +; for (i = 0; i < n; i++) +; *p++ = val; +;} +; +;/* count must be a multiple of 4 and >= 4 */ +;void memset_RGB24(void *adr,int r, int v, int b,long count) +;{ +; long i, n; +; register long v1,v2,v3,*pt=(long *)(adr); +; unsigned char *p,R=(unsigned char)r,V=(unsigned char)v,B=(unsigned char)b; +; +; p=(unsigned char *)adr; +; *p++=R; +; *p++=V; +; *p++=B; +; *p++=R; +; *p++=V; +; *p++=B; +; *p++=R; +; *p++=V; +; *p++=B; +; *p++=R; +; *p++=V; +; *p++=B; +; v1=*pt++; +; v2=*pt++; +; v3=*pt++; +; n = count >> 2; +; for(i=1;izbuf, z, zb->xsize * zb->ysize); +; } +; if (clear_color) { +; pp = zb->pbuf; +; for (y = 0; y < zb->ysize; y++) { +;#if TGL_FEATURE_RENDER_BITS == 15 || TGL_FEATURE_RENDER_BITS == 16 +; color = RGB_TO_PIXEL(r, g, b); +; memset_s(pp, color, zb->xsize); +;#elif TGL_FEATURE_RENDER_BITS == 32 +; color = RGB_TO_PIXEL(r, g, b); +; memset_l(pp, color, zb->xsize); +;#elif TGL_FEATURE_RENDER_BITS == 24 +; memset_RGB24(pp,r>>8,g>>8,b>>8,zb->xsize); +;#else +;#error TODO +;#endif +; pp = (PIXEL *) ((char *) pp + zb->linesize); +; } +; } +;} diff --git a/programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc b/programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc new file mode 100644 index 0000000000..f32aad54fd --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc @@ -0,0 +1,178 @@ +; +; Z buffer +; + +include 'zfeatures.inc' + +ZB_Z_BITS equ 16 + +ZB_POINT_Z_FRAC_BITS equ 14 + +ZB_POINT_S_MIN equ ( (1 shl 13) ) +ZB_POINT_S_MAX equ ( (1 shl 22)-(1 shl 13) ) +ZB_POINT_T_MIN equ ( (1 shl 21) ) +ZB_POINT_T_MAX equ ( (1 shl 30)-(1 shl 21) ) + +ZB_POINT_RED_MIN equ ( (1 shl 10) ) +ZB_POINT_RED_MAX equ ( (1 shl 16)-(1 shl 10) ) +ZB_POINT_GREEN_MIN equ ( (1 shl 9) ) +ZB_POINT_GREEN_MAX equ ( (1 shl 16)-(1 shl 9) ) +ZB_POINT_BLUE_MIN equ ( (1 shl 10) ) +ZB_POINT_BLUE_MAX equ ( (1 shl 16)-(1 shl 10) ) + +; display modes +ZB_MODE_5R6G5B equ 1 ; true color 16 bits +ZB_MODE_INDEX equ 2 ; color index 8 bits +ZB_MODE_RGBA equ 3 ; 32 bit rgba mode +ZB_MODE_RGB24 equ 4 ; 24 bit rgb mode +ZB_NB_COLORS equ 225 ; number of colors for 8 bit display + +if TGL_FEATURE_RENDER_BITS eq 15 + +;#define RGB_TO_PIXEL(r,g,b) \ +; ((((r) >> 1) & 0x7c00) | (((g) >> 6) & 0x03e0) | ((b) >> 11)) +;typedef unsigned short PIXEL; +;/* bytes per pixel */ +;PSZB equ 2 +;/* bits per pixel = (1 << PSZH) */ +;PSZSH equ 4 + +else if TGL_FEATURE_RENDER_BITS eq 16 + +;/* 16 bit mode */ +;#define RGB_TO_PIXEL(r,g,b) \ +; (((r) & 0xF800) | (((g) >> 5) & 0x07E0) | ((b) >> 11)) +;typedef unsigned short PIXEL; +;PSZB equ 2 +;PSZSH equ 4 + +else if TGL_FEATURE_RENDER_BITS eq 24 + +macro RGB_TO_PIXEL r,g,b +{ + mov eax,b + shr eax,8 + push eax + mov eax,g + and eax,0xff00 + or dword[esp],eax + mov eax,r + shl eax,8 + or dword[esp],eax + pop eax +} + +;typedef unsigned char PIXEL; +PSZB equ 3 +PSZSH equ 5 + +else if TGL_FEATURE_RENDER_BITS eq 32 + +;#define RGB_TO_PIXEL(r,g,b) \ +; ((((r) << 8) & 0xff0000) | ((g) & 0xff00) | ((b) >> 8)) +;typedef unsigned int PIXEL; +;PSZB equ 4 +;PSZSH equ 5 + +else + +;#error Incorrect number of bits per pixel + +end if + +struct ZBuffer + xsize dd ? ;int + ysize dd ? ;int + linesize dd ? ;int ;line size, in bytes + mode dd ? ;int + + zbuf dd ? ;*unsigned short + pbuf dd ? ;*PIXEL + frame_buffer_allocated dd ? ;int + + nb_colors dd ? ;int + dctable dd ? ;*unsigned char + ctable dd ? ;*int + current_texture dd ? ;*PIXEL +ends + +offs_zbuf_xsize equ 0 +offs_zbuf_ysize equ 4 +offs_zbuf_linesize equ 8 +offs_zbuf_mode equ 16 +offs_zbuf_zbuf equ 20 +offs_zbuf_pbuf equ 24 +offs_zbuf_frame_buffer_allocated equ 28 +offs_zbuf_nb_colors equ 32 +offs_zbuf_dctable equ 36 +offs_zbuf_ctable equ 40 +offs_zbuf_current_texture equ 44 + +struct ZBufferPoint + x dd ? ;int ;integer coordinates in the zbuffer + y dd ? ;int + z dd ? ;int + s dd ? ;int ;coordinates for the mapping + t dd ? ;int + r dd ? ;int ;color indexes + g dd ? ;int + b dd ? ;int + + fsz dd ? ;float ;temporary coordinates for mapping + tz dd ? ;float +ends + +offs_zbup_x equ 0 +offs_zbup_y equ 4 +offs_zbup_z equ 8 +offs_zbup_s equ 12 +offs_zbup_t equ 16 +offs_zbup_r equ 20 +offs_zbup_g equ 24 +offs_zbup_b equ 28 +offs_zbup_sz equ 32 +offs_zbup_tz equ 36 + +; ztriangle.c + +; +; Memory allocator for TinyGL +; + +; modify these functions so that they suit your needs + +align 4 +proc gl_free uses ebx ecx, mptr:dword + mov ecx,[mptr] + or ecx,ecx + jz @f + @@: + mcall 68, 13 + ret +endp + +;description: +; выделение памяти +align 4 +proc gl_malloc uses ebx ecx, size:dword + mcall 68, 12, [size] + ret +endp + +;description: +; выделение очищеной памяти +align 4 +proc gl_zalloc uses ebx ecx edi, size:dword + mov ecx,[size] + stdcall gl_malloc,ecx + cmp eax,0 + je @f + mov ebx,eax + mov edi,eax + xor eax,eax + shr ecx,2 + rep stosd ;очистка памяти (пишем везде 0) + mov eax,ebx + @@: + ret +endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/zfeatures.inc b/programs/develop/libraries/TinyGL/asm_fork/zfeatures.inc new file mode 100644 index 0000000000..7d35a704e0 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zfeatures.inc @@ -0,0 +1,43 @@ +; +; If not debugging, assert does nothing. +; +;#define assert(x) ((void)0) /* debugging disabled */ +;#include /* debugging enabled */ + +; It is possible to enable/disable (compile time) features in this +; header file. + +;TGL_FEATURE_ARRAYS equ 1 +;TGL_FEATURE_DISPLAYLISTS equ 1 +;TGL_FEATURE_POLYGON_OFFSET equ 1 + +; +; Matrix of internal and external pixel formats supported. 'Y' means +; supported. +; +; External 8 16 24 32 +; Internal +; 15 . . . . +; 16 Y Y Y Y +; 24 . Y Y . +; 32 . Y . Y +; +; +; 15 bpp does not work yet (although it is easy to add it - ask me if +; you need it). +; +; Internal pixel format: see TGL_FEATURE_RENDER_BITS +; External pixel format: see TGL_FEATURE_xxx_BITS +; + +; enable various convertion code from internal pixel format (usually +; 16 bits per pixel) to any external format */ +;TGL_FEATURE_16_BITS equ 1 +;TGL_FEATURE_8_BITS equ 1 +TGL_FEATURE_24_BITS equ 1 +;TGL_FEATURE_32_BITS equ 1 + +;TGL_FEATURE_RENDER_BITS equ 15 +;TGL_FEATURE_RENDER_BITS equ 16 +TGL_FEATURE_RENDER_BITS equ 24 +;TGL_FEATURE_RENDER_BITS equ 32 diff --git a/programs/develop/libraries/TinyGL/asm_fork/zgl.inc b/programs/develop/libraries/TinyGL/asm_fork/zgl.inc new file mode 100644 index 0000000000..f4cef1ceac --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zgl.inc @@ -0,0 +1,515 @@ +include 'opengl_const.inc' +include 'zbuffer.inc' +include 'zmath.inc' + +;#define fputc(...) /*nothing*/ +;#define fprintf(...) /*nothing*/ +;#define vfprintf(...) /*nothing*/ +;#undef stderr +;#define stderr ((FILE*)-1) + + +;enum { OP_ ## a , ... } +s1 equ 0 +macro ADD_OP a,b,c +{ + OP_#a equ s1 + s1 equ (s1+1) +} +include 'opinfo.inc' + + +;initially # of allocated GLVertexes (will grow when necessary) +POLYGON_MAX_VERTEX equ 16 + +;Max # of specular light pow buffers +MAX_SPECULAR_BUFFERS equ 8 +;# of entries in specular buffer +SPECULAR_BUFFER_SIZE equ 1024 +;specular buffer granularity +SPECULAR_BUFFER_RESOLUTION equ 1024 + + +MAX_MODELVIEW_STACK_DEPTH equ 32 +MAX_PROJECTION_STACK_DEPTH equ 8 +MAX_TEXTURE_STACK_DEPTH equ 8 +MAX_NAME_STACK_DEPTH equ 64 +MAX_TEXTURE_LEVELS equ 11 +MAX_LIGHTS equ 16 + +VERTEX_HASH_SIZE equ 1031 + +MAX_DISPLAY_LISTS equ 1024 +OP_BUFFER_MAX_SIZE equ 512 + +TGL_OFFSET_FILL equ 0x1 +TGL_OFFSET_LINE equ 0x2 +TGL_OFFSET_POINT equ 0x4 + +struct GLSpecBuf + shininess_i dd ? ;int + last_used dd ? ;int + buf rd SPECULAR_BUFFER_SIZE+1 ;float[SPECULAR_BUFFER_SIZE+1] + next dd ? ;struct GLSpecBuf* +ends + +struct GLLight + ambient V4 + diffuse V4 + specular V4 + position V4 + spot_direction V3 + spot_exponent dd ? ;float + spot_cutoff dd ? ;float + attenuation rd 3 ;float[3] + ; precomputed values + cos_spot_cutoff dd ? ;float + norm_spot_direction V3 + norm_position V3 + ; we use a linked list to know which are the enabled lights + enabled dd ? ;int + next dd ? ;struct GLLight* + prev dd ? ;struct GLLight* +ends + +offs_ligh_ambient equ 0 ;V4 +offs_ligh_diffuse equ 16 ;V4 +offs_ligh_specular equ 32 ;V4 +offs_ligh_position equ 48 ;V4 +offs_ligh_spot_direction equ 64 ;V3 +offs_ligh_spot_exponent equ 76 ;dd ? +offs_ligh_spot_cutoff equ 80 ;dd ? +offs_ligh_attenuation equ 84 ;rd 3 +offs_ligh_cos_spot_cutoff equ 96 ;dd ? +offs_ligh_norm_spot_direction equ 100 ;V3 +offs_ligh_norm_position equ 112 ;V3 +offs_ligh_enabled equ 124 ;dd ? +offs_ligh_next equ 128 ;dd ? +offs_ligh_prev equ 132 ;dd ? + +struct GLMaterial + emission V4 + ambient V4 + diffuse V4 + specular V4 + shininess dd ? ;float + + ; computed values + shininess_i dd ? ;int + do_specular dd ? ;int +ends + +offs_mate_emission equ 0 ;V4 +offs_mate_ambient equ 16 ;V4 +offs_mate_diffuse equ 32 ;V4 +offs_mate_specular equ 48 ;V4 +offs_mate_shininess equ 64 ;dd +offs_mate_shininess_i equ 68 ;dd +offs_mate_do_specular equ 72 ;dd + +struct GLViewport + xmin dd ? ;int + ymin dd ? ;int + xsize dd ? ;int + ysize dd ? ;int + scale V3 + trans V3 + updated dd ? ;int +ends + +offs_vpor_xmin equ 0 +offs_vpor_ymin equ 4 +offs_vpor_xsize equ 8 +offs_vpor_ysize equ 12 +offs_vpor_scale equ 16 +offs_vpor_trans equ 28 +offs_vpor_updated equ 40 + +struct GLParamBuffer + ops rd OP_BUFFER_MAX_SIZE ;GLParam[OP_BUFFER_MAX_SIZE] + next dd ? ;struct GLParamBuffer* +ends + +struct GLList + first_op_buffer dd ? ;GLParamBuffer* +; /* TODO: extensions for an hash table or a better allocating scheme */ +ends + +struct GLVertex + edge_flag dd ? ;int + normal V3 + coord V4 + tex_coord V4 + color V4 + + ; computed values + ec V4 ; eye coordinates + pc V4 ; coordinates in the normalized volume + clip_code dd ? ;int ; clip code + zp ZBufferPoint ; integer coordinates for the rasterization +ends + +offs_vert_edge_flag equ 0 +offs_vert_normal equ 4 +offs_vert_coord equ 16 +offs_vert_tex_coord equ 32 +offs_vert_color equ 48 +offs_vert_ec equ 64 +offs_vert_pc equ 80 +offs_vert_clip_code equ 96 +offs_vert_zp equ 100 + +struct GLImage + pixmap dd ? ;void* + xsize dd ? ;int + ysize dd ? ;int +ends + +offs_imag_pixmap equ 0 + +; textures + +TEXTURE_HASH_TABLE_SIZE equ 256 ;должно быть кратное 2, в коде берется остаток от деления (через and быстрее чем div) + +struct GLTexture + images rb sizeof.GLImage * MAX_TEXTURE_LEVELS ;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 + lists dd ? ;GLList** + texture_hash_table dd ? ;GLTexture** +ends + + +; display context + +struct GLContext + ; Z buffer + zb dd ? ;ZBuffer* + + ; lights + lights rb sizeof.GLLight * MAX_LIGHTS ;GLLight[MAX_LIGHTS] + first_light dd ? ;GLLight* + ambient_light_model V4 + local_light_model dd ? ;int + lighting_enabled dd ? ;int + light_model_two_side dd ? ;int + + ; materials + materials rb sizeof.GLMaterial * 2 ;GLMaterial[2] + color_material_enabled dd ? ;int + current_color_material_mode dd ? ;int + current_color_material_type dd ? ;int + + ; textures + current_texture dd ? ;GLTexture* + texture_2d_enabled dd ? ;int + + ; shared state + shared_state GLSharedState + + ; current list + current_op_buffer dd ? ;GLParamBuffer* + current_op_buffer_index dd ? ;int + exec_flag dd ? ;int + compile_flag dd ? ;int + print_flag dd ? ;int + + ; matrix + + matrix_mode dd ? ;int режим активного вида матрицы (один из 3-х: GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE) + matrix_stack rd 3 ;*M4[3] указатель на начало массива матриц + matrix_stack_ptr rd 3 ;*M4[3] указатель на активную матрицу из массива + matrix_stack_depth_max rd 3 ;int[3] максимальное число матриц в массивах matrix_stack + + matrix_model_view_inv M4 + matrix_model_projection M4 + matrix_model_projection_updated dd ? ;int + matrix_model_projection_no_w_transform dd ? ;int + apply_texture_matrix dd ? ;int + + ; viewport + viewport GLViewport + + ; current state + polygon_mode_back dd ? ;int + polygon_mode_front dd ? ;int + + current_front_face dd ? ;int + current_shade_model dd ? ;int + current_cull_face dd ? ;int + cull_face_enabled dd ? ;int + normalize_enabled dd ? ;int + draw_triangle_front dd ? ;gl_draw_triangle_func + draw_triangle_back dd ? ;gl_draw_triangle_func + + ; selection + render_mode dd ? ;int + select_buffer dd ? ;unsigned int* + select_size dd ? ;int + select_ptr dd ? ;unsigned int* + select_hit dd ? ;unsigned int* + select_overflow dd ? ;int + select_hits dd ? ;int + + ; names + name_stack rd MAX_NAME_STACK_DEPTH ;unsigned int[MAX_NAME_STACK_DEPTH] + name_stack_size dd ? ;int + + ; clear + clear_depth dd ? ;float + clear_color V4 + + ; current vertex state + current_color V4 + longcurrent_color rd 3 ;unsigned int[3] ;precomputed integer color + current_normal V4 + current_tex_coord V4 + current_edge_flag dd ? ;int + + ; glBegin / glEnd + in_begin dd ? ;int + begin_type dd ? ;int + vertex_n dd ? ;int + vertex_cnt dd ? ;int + vertex_max dd ? ;int + vertex dd ? ;GLVertex* + + ; opengl 1.1 arrays + vertex_array dd ? ;float* + vertex_array_size dd ? ;int + vertex_array_stride dd ? ;int + normal_array dd ? ;float* + normal_array_stride dd ? ;int + color_array dd ? ;float* + color_array_size dd ? ;int + color_array_stride dd ? ;int + texcoord_array dd ? ;float* + texcoord_array_size dd ? ;int + texcoord_array_stride dd ? ;int + client_states dd ? ;int + + ; opengl 1.1 polygon offset + offset_factor dd ? ;float + offset_units dd ? ;float + offset_states dd ? ;int + + ; specular buffer. could probably be shared between contexts, + ; but that wouldn't be 100% thread safe + specbuf_first dd ? ;GLSpecBuf* + specbuf_used_counter dd ? ;int + specbuf_num_buffers dd ? ;int + + ; opaque structure for user's use + opaque dd ? ;void* + ; resize viewport function + gl_resize_viewport dd ? ;(struct GLContext *c,int *xsize,int *ysize) + + ; depth test + depth_test dd ? ;int +ends + +offs_cont_s0 equ (4 + sizeof.GLLight * MAX_LIGHTS) +offs_cont_s1 equ (32 + offs_cont_s0 + sizeof.GLMaterial * 2) +offs_cont_s2 equ (228 + offs_cont_s1 + sizeof.GLViewport) +offs_cont_s3 equ (64 + offs_cont_s2 + MAX_NAME_STACK_DEPTH * 4) + +offs_cont_zb equ 0 ;ZBuffer* +offs_cont_lights equ 4 ;GLLight[MAX_LIGHTS] +offs_cont_first_light equ offs_cont_s0 ;GLLight* +offs_cont_ambient_light_model equ 4+offs_cont_s0 ;V4 +offs_cont_local_light_model equ 20+offs_cont_s0 ;int +offs_cont_lighting_enabled equ 24+offs_cont_s0 ;int +offs_cont_light_model_two_side equ 28+offs_cont_s0 ;int +offs_cont_materials equ 32+offs_cont_s0 ;GLMaterial[2] +offs_cont_color_material_enabled equ offs_cont_s1 ;int +offs_cont_current_color_material_mode equ 4+offs_cont_s1 ;int +offs_cont_current_color_material_type equ 8+offs_cont_s1 ;int +offs_cont_current_texture equ 12+offs_cont_s1 ;GLTexture* +offs_cont_texture_2d_enabled equ 16+offs_cont_s1 ;int +offs_cont_shared_state equ 20+offs_cont_s1 ;GLSharedState +offs_cont_current_op_buffer equ 28+offs_cont_s1 ;GLParamBuffer* +offs_cont_current_op_buffer_index equ 32+offs_cont_s1 ;int +offs_cont_exec_flag equ 36+offs_cont_s1 ;int +offs_cont_compile_flag equ 40+offs_cont_s1 ;int +offs_cont_print_flag equ 44+offs_cont_s1 ;int +offs_cont_matrix_mode equ 48+offs_cont_s1 ;int +offs_cont_matrix_stack equ 52+offs_cont_s1 ;*M4[3] +offs_cont_matrix_stack_ptr equ 64+offs_cont_s1 ;*M4[3] +offs_cont_matrix_stack_depth_max equ 76+offs_cont_s1 ;int[3] +offs_cont_matrix_model_view_inv equ 88+offs_cont_s1 ;M4 +offs_cont_matrix_model_projection equ 152+offs_cont_s1 ;M4 +offs_cont_matrix_model_projection_updated equ 216+offs_cont_s1 ;int +offs_cont_matrix_model_projection_no_w_transform equ 220+offs_cont_s1 ;int +offs_cont_apply_texture_matrix equ 224+offs_cont_s1 ;int +offs_cont_viewport equ 228+offs_cont_s1 ;GLViewport +offs_cont_polygon_mode_back equ offs_cont_s2 ;int +offs_cont_polygon_mode_front equ 4+offs_cont_s2 ;int +offs_cont_current_front_face equ 8+offs_cont_s2 ;int +offs_cont_current_shade_model equ 12+offs_cont_s2 ;int +offs_cont_current_cull_face equ 16+offs_cont_s2 ;int +offs_cont_cull_face_enabled equ 20+offs_cont_s2 ;int +offs_cont_normalize_enabled equ 24+offs_cont_s2 ;int +offs_cont_draw_triangle_front equ 28+offs_cont_s2 ;gl_draw_triangle_func +offs_cont_draw_triangle_back equ 32+offs_cont_s2 ;gl_draw_triangle_func +offs_cont_render_mode equ 36+offs_cont_s2 ;int +offs_cont_select_buffer equ 40+offs_cont_s2 ;unsigned int* +offs_cont_select_size equ 44+offs_cont_s2 ;int +offs_cont_select_ptr equ 48+offs_cont_s2 ;unsigned int* +offs_cont_select_hit equ 52+offs_cont_s2 ;unsigned int* +offs_cont_select_overflow equ 56+offs_cont_s2 ;int +offs_cont_select_hits equ 60+offs_cont_s2 ;int +offs_cont_name_stack equ 64+offs_cont_s2 ;unsigned int[MAX_NAME_STACK_DEPTH] +offs_cont_name_stack_size equ offs_cont_s3 ;int +offs_cont_clear_depth equ 4+offs_cont_s3 ;float +offs_cont_clear_color equ 8+offs_cont_s3 ;V4 +offs_cont_current_color equ 24+offs_cont_s3 ;V4 +offs_cont_longcurrent_color equ 40+offs_cont_s3 ;unsigned int[3] +offs_cont_current_normal equ 52+offs_cont_s3 ;V4 +offs_cont_current_tex_coord equ 68+offs_cont_s3 ;V4 +offs_cont_current_edge_flag equ 84+offs_cont_s3 ;int +offs_cont_in_begin equ 88+offs_cont_s3 ;int +offs_cont_begin_type equ 92+offs_cont_s3 ;int +offs_cont_vertex_n equ 96+offs_cont_s3 ;int +offs_cont_vertex_cnt equ 100+offs_cont_s3 ;int +offs_cont_vertex_max equ 104+offs_cont_s3 ;int +offs_cont_vertex equ 108+offs_cont_s3 ;GLVertex* +offs_cont_vertex_array equ 112+offs_cont_s3 ;float* +offs_cont_vertex_array_size equ 116+offs_cont_s3 ;int +offs_cont_vertex_array_stride equ 120+offs_cont_s3 ;int +offs_cont_normal_array equ 124+offs_cont_s3 ;float* +offs_cont_normal_array_stride equ 128+offs_cont_s3 ;int +offs_cont_color_array equ 132+offs_cont_s3 ;float* +offs_cont_color_array_size equ 136+offs_cont_s3 ;int +offs_cont_color_array_stride equ 140+offs_cont_s3 ;int +offs_cont_texcoord_array equ 144+offs_cont_s3 ;float* +offs_cont_texcoord_array_size equ 148+offs_cont_s3 ;int +offs_cont_texcoord_array_stride equ 152+offs_cont_s3 ;int +offs_cont_client_states equ 156+offs_cont_s3 ;int +offs_cont_offset_factor equ 160+offs_cont_s3 ;float +offs_cont_offset_units equ 164+offs_cont_s3 ;float +offs_cont_offset_states equ 168+offs_cont_s3 ;int +offs_cont_specbuf_first equ 172+offs_cont_s3 ;GLSpecBuf* +offs_cont_specbuf_used_counter equ 176+offs_cont_s3 ;int +offs_cont_specbuf_num_buffers equ 180+offs_cont_s3 ;int +offs_cont_opaque equ 184+offs_cont_s3 ;void* +offs_cont_gl_resize_viewport equ 188+offs_cont_s3 ;(struct GLContext *c,int *xsize,int *ysize) +offs_cont_depth_test equ 192+offs_cont_s3 ;int + +align 16 +gl_ctx dd ? ;extern GLContext* + +align 16 +proc gl_get_context + mov eax,[gl_ctx] + ret +endp + +; this clip epsilon is needed to avoid some rounding errors after +; several clipping stages + +CLIP_EPSILON dd 1.0e-5 + +align 4 +proc gl_clipcode uses ebx, x:dword, y:dword, z:dword, w1:dword + xor ebx,ebx + + ;ffree st0 + ;fincstp + fld1 + fadd dword[CLIP_EPSILON] + fmul dword[w1] + + fcom dword[x] + fstsw ax + sahf + ja @f + or ebx,2 + @@: + fcom dword[y] + fstsw ax + sahf + ja @f + or ebx,8 + @@: + fcom dword[z] + fstsw ax + sahf + ja @f + or ebx,32 + @@: + + fchs + fcom dword[x] + fstsw ax + sahf + jbe @f + or ebx,1 + @@: + fcom dword[y] + fstsw ax + sahf + jbe @f + or ebx,4 + @@: + fcom dword[z] + fstsw ax + sahf + jbe @f + or ebx,16 + @@: + + mov eax,ebx +if DEBUG ;gl_clipcode +push edi + mov ecx,80 + lea edi,[buf_param] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_nl,2 + stdcall dbg_print,f_clipcode,buf_param +pop edi +end if + ret +endp + +;input: +; rf,gf,bf - значения float +; ri,gi,bi - адреса куда будут записаны rf,gf,bf преобразованые в int +align 4 +proc RGBFtoRGBI uses eax, rf:dword,gf:dword,bf:dword, ri:dword,gi:dword,bi:dword +locals + s dd ? +endl + mov dword[s],(ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) + fild dword[s] + fmul dword[rf] + mov eax,[ri] + fistp dword[eax] + add dword[eax],ZB_POINT_RED_MIN + + mov dword[s],(ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) + fild dword[s] + fmul dword[gf] + mov eax,[gi] + fistp dword[eax] + add dword[eax],ZB_POINT_GREEN_MIN + + ;bi = (unsigned int) (bf * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) + ZB_POINT_BLUE_MIN); + mov dword[s],(ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) + fild dword[s] + fmul dword[bf] + mov eax,[bi] + fistp dword[eax] + add dword[eax],ZB_POINT_BLUE_MIN + ret +endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/zline.asm b/programs/develop/libraries/TinyGL/asm_fork/zline.asm new file mode 100644 index 0000000000..2c9b57a592 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zline.asm @@ -0,0 +1,164 @@ + +align 4 +proc ZB_plot uses eax ebx ecx edx edi, zb:dword, p:dword + mov eax,[zb] + mov ebx,[p] + mov ecx,[ebx+offs_zbup_y] + imul ecx,[eax+offs_zbuf_xsize] + add ecx,[ebx+offs_zbup_x] + add ecx,[eax+offs_zbuf_zbuf] + mov edx,[eax+offs_zbuf_linesize] + imul edx,[ebx+offs_zbup_y] + mov edi,[ebx+offs_zbup_x] + imul edi,PSZB + add edx,edi + add edx,[eax+offs_zbuf_pbuf] + mov edi,[ebx+offs_zbup_z] + shr edi,ZB_POINT_Z_FRAC_BITS + cmp edi,[ecx] + jl .end_f +if TGL_FEATURE_RENDER_BITS eq 24 + mov eax,[ebx+offs_zbup_r] + mov byte[edx],ah + mov eax,[ebx+offs_zbup_g] + mov byte[edx+1],ah + mov eax,[ebx+offs_zbup_b] + mov byte[edx+2],ah +else +; *pp = RGB_TO_PIXEL(p->r, p->g, p->b); +end if + mov [ecx],edi + .end_f: + ret +endp + +INTERP_Z equ 1 +align 4 +proc ZB_line_flat_z, zb:dword, p1:dword, p2:dword, color:dword +include 'zline.inc' + +; line with color interpolation +INTERP_Z equ 1 +align 4 +proc ZB_line_interp_z, zb:dword, p1:dword, p2:dword +include 'zline_r.inc' + +; no Z interpolation + +align 4 +proc ZB_line_flat, zb:dword, p1:dword, p2:dword, color:dword +include 'zline.inc' + +align 4 +proc ZB_line_interp, zb:dword, p1:dword, p2:dword +include 'zline_r.inc' + +align 4 +proc ZB_line_z uses eax ebx ecx, zb:dword, p1:dword, p2:dword +if DEBUG ;ZB_line_z +push edi + mov ecx,80 + mov eax,[p1] + mov eax,[eax+offs_zbup_x] + lea edi,[buf_param] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[p1] + mov eax,[eax+offs_zbup_y] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[p2] + mov eax,[eax+offs_zbup_x] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[p2] + mov eax,[eax+offs_zbup_y] + stdcall convert_int_to_str,ecx + + stdcall str_n_cat,edi,txt_nl,2 + stdcall dbg_print,f_zbz,buf_param +pop edi +end if + mov ebx,[p1] + RGB_TO_PIXEL dword[ebx+offs_zbup_r],dword[ebx+offs_zbup_g],dword[ebx+offs_zbup_b] + mov ecx,eax + mov ebx,[p2] + RGB_TO_PIXEL dword[ebx+offs_zbup_r],dword[ebx+offs_zbup_g],dword[ebx+offs_zbup_b] + + ; choose if the line should have its color interpolated or not + cmp ecx,eax + jne .els + stdcall ZB_line_flat_z, dword[zb], dword[p1], ebx, ecx + jmp @f + .els: + stdcall ZB_line_interp_z, dword[zb], dword[p1], ebx + @@: + ret +endp + +align 4 +proc ZB_line uses eax ebx ecx, zb:dword, p1:dword, p2:dword +if DEBUG ;ZB_line +push edi + mov ecx,80 + mov eax,[p1] + mov eax,[eax+offs_zbup_x] + lea edi,[buf_param] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[p1] + mov eax,[eax+offs_zbup_y] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[p2] + mov eax,[eax+offs_zbup_x] + stdcall convert_int_to_str,ecx + stdcall str_n_cat,edi,txt_zp_sp,2 + stdcall str_len,edi + add edi,eax + sub ecx,eax + + mov eax,[p2] + mov eax,[eax+offs_zbup_y] + stdcall convert_int_to_str,ecx + + stdcall str_n_cat,edi,txt_nl,2 + stdcall dbg_print,f_zb,buf_param +pop edi +end if + mov ebx,[p1] + RGB_TO_PIXEL dword[ebx+offs_zbup_r],dword[ebx+offs_zbup_g],dword[ebx+offs_zbup_b] + mov ecx,eax + mov ebx,[p2] + RGB_TO_PIXEL dword[ebx+offs_zbup_r],dword[ebx+offs_zbup_g],dword[ebx+offs_zbup_b] + + ; choose if the line should have its color interpolated or not + cmp ecx,eax + jne .els + stdcall ZB_line_flat, dword[zb], dword[p1], ebx, ecx + jmp @f + .els: + stdcall ZB_line_interp, dword[zb], dword[p1], ebx + @@: + ret +endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/zline.inc b/programs/develop/libraries/TinyGL/asm_fork/zline.inc new file mode 100644 index 0000000000..dc23d52b0a --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zline.inc @@ -0,0 +1,226 @@ +;PUTPIXEL -> RGBPIXEL + +locals + n dd ? + d_x dd ? + d_y dd ? + sx dd ? ;ширина буфера в пикселях + pp_inc_1 dd ? + pp_inc_2 dd ? + a dd ? ;register int +if TGL_FEATURE_RENDER_BITS eq 24 + r dd ? ;register unsigned int + g dd ? + b dd ? +end if +if INTERP_Z eq 1 + pz dd ? ;register unsigned short * + zinc dd ? + z dd ? ;register int + zz dd ? +end if +endl +pushad + + mov eax,[p1] + mov ebx,[p2] + mov ecx,[ebx+offs_zbup_y] + cmp [eax+offs_zbup_y], ecx ;if (p1.y > p2.y) + jg @f + jl .end_0 ;if (p1.y != p2.y) + mov ecx,[ebx+offs_zbup_x] + cmp [eax+offs_zbup_x], ecx ;if (p1.x > p2.x) + jle .end_0 ;if (p1.x <= p2.x) + @@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x)) + mov [p1],ebx + mov [p2],eax + .end_0: + + mov eax,[zb] + mov edx,[eax+offs_zbuf_xsize] + mov [sx],edx + mov ecx,[p1] + mov edi,[eax+offs_zbuf_linesize] + imul edi,[ecx+offs_zbup_y] + mov edx,[ecx+offs_zbup_x] + imul edx,PSZB + add edi,edx + add edi,[eax+offs_zbuf_pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB) +if INTERP_Z eq 1 + mov edx,[ecx+offs_zbup_y] + imul edx,[sx] + add edx,[ecx+offs_zbup_x] + add edx,[eax+offs_zbuf_zbuf] + mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x) + mov edx,[ecx+offs_zbup_z] + mov [z],edx ;z = p1.z +end if + + mov ebx,[p2] + mov eax,[ebx+offs_zbup_x] + sub eax,[ecx+offs_zbup_x] + mov [d_x],eax ;d_x = p2.x - p1.x + mov eax,[ebx+offs_zbup_y] + sub eax,[ecx+offs_zbup_y] + mov [d_y],eax ;d_y = p2.y - p1.y +if TGL_FEATURE_RENDER_BITS eq 24 + ; for 24 bits, we store the colors in different variables + mov eax,[ebx+offs_zbup_r] + shr eax,8 + mov [r],eax ;r = p2.r >> 8 + mov eax,[ebx+offs_zbup_g] + shr eax,8 + mov [g],eax ;g = p2.g >> 8 + mov eax,[ebx+offs_zbup_b] + shr eax,8 + mov [b],eax ;b = p2.b >> 8 +end if + +macro RGBPIXEL +{ +if TGL_FEATURE_RENDER_BITS eq 24 + mov eax,[r] + mov byte[edi],al + mov eax,[g] + mov byte[edi+1],al + mov eax,[b] + mov byte[edi+2],al +;;; else +;;; mov eax,[color] +;;; mov [edi],eax +end if +} + +macro PUTPIXEL +{ +if INTERP_Z eq 1 +local .end_0 + mov eax,[z] + shr eax, ZB_POINT_Z_FRAC_BITS + mov [zz],eax + cmp eax,[pz] + jl .end_0 + RGBPIXEL + mov eax,dword[zz] + mov [pz],eax + .end_0: +else ; INTERP_Z + RGBPIXEL +end if ; INTERP_Z +} + +macro DRAWLINE d_x,d_y,inc_1,inc_2 +{ + mov eax,d_x + mov [n],eax +if INTERP_Z eq 1 + mov ebx,[p1] + mov eax,[p2] + mov eax,[eax+offs_zbup_z] + sub eax,[ebx+offs_zbup_z] + xor edx,edx + div dword[n] + mov [zinc],eax ;zinc=(p2.z-p1.z)/n +end if + shl dword d_y,1 + mov eax, d_y + sub eax, d_x + mov [a],eax ;a=2*d_y-d_x + shl dword d_x,1 + mov eax, d_y + sub d_x,eax + mov eax,inc_1 + imul eax,PSZB + mov [pp_inc_1],eax ;pp_inc_1 = inc_1*PSZB + mov eax,inc_2 + imul eax,PSZB + mov [pp_inc_2],eax ;pp_inc_2 = inc_2*PSZB + +local .do_cycle +local .els_0 +local .end_0 + +align 4 +.do_cycle: + + PUTPIXEL +if INTERP_Z eq 1 + mov eax,[zinc] + add [z],eax +end if + + cmp dword[a],0 + jle .els_0 + add edi,[pp_inc_1] +if INTERP_Z eq 1 + mov eax,inc_1 + add [pz],eax +end if + mov eax,d_x + sub [a],eax + jmp .end_0 + +.els_0: + add edi,[pp_inc_2] +if INTERP_Z eq 1 + mov eax,inc_2 + add [pz],eax +end if + mov eax,d_y + add [a],eax + +.end_0: + dec dword[n] + cmp dword[n],0 + jge .do_cycle +} + +; fin macro + + mov eax,[d_x] + cmp eax,0 + jne .els_0 + cmp dword[d_y],0 + jne .els_0 + ;if (d_x==0 && d_y==0) + PUTPIXEL + jmp .end_2 + .els_0: + cmp eax,0 + jle .els_3 + ;if (d_x > 0) + mov esi,[sx] + inc esi + cmp eax,[d_y] + jl .els_2 + ;if (d_x >= d_y) + DRAWLINE [d_x], [d_y], esi, 1 + jmp .end_2 + .els_2: + DRAWLINE [d_y], [d_x], esi, [sx] + jmp .end_2 + .els_3: + xor eax,eax + sub eax,[d_x] + mov [d_x],eax + mov esi,[sx] + dec esi + cmp eax,[d_y] + jl .els_4 + ;if (d_x >= d_y) + DRAWLINE [d_x], [d_y], esi, -1 + jmp .end_2 + .els_4: + DRAWLINE [d_y], [d_x], esi, [sx] + .end_2: + +popad + ret +endp + +restore INTERP_Z + +; internal defines +purge DRAWLINE +purge PUTPIXEL +purge RGBPIXEL diff --git a/programs/develop/libraries/TinyGL/asm_fork/zline_r.inc b/programs/develop/libraries/TinyGL/asm_fork/zline_r.inc new file mode 100644 index 0000000000..add148ea04 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zline_r.inc @@ -0,0 +1,257 @@ +;PUTPIXEL -> RGBPIXEL + +locals + n dd ? + d_x dd ? + d_y dd ? + sx dd ? ;ширина буфера в пикселях + pp_inc_1 dd ? + pp_inc_2 dd ? + a dd ? ;register int + r dd ? ;register unsigned int + g dd ? + b dd ? + rinc dd ? ;register unsigned int + ginc dd ? + binc dd ? +if INTERP_Z eq 1 + pz dd ? ;register unsigned short * + zinc dd ? + z dd ? ;register int + zz dd ? +end if +endl +pushad + + mov eax,[p1] + mov ebx,[p2] + mov ecx,[ebx+offs_zbup_y] + cmp [eax+offs_zbup_y], ecx ;if (p1.y > p2.y) + jg @f + jl .end_0 ;if (p1.y != p2.y) + mov ecx,[ebx+offs_zbup_x] + cmp [eax+offs_zbup_x], ecx ;if (p1.x > p2.x) + jle .end_0 ;if (p1.x <= p2.x) + @@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x)) + mov [p1],ebx + mov [p2],eax + .end_0: + + mov eax,[zb] + mov edx,[eax+offs_zbuf_xsize] + mov [sx],edx + mov ecx,[p1] + mov edi,[eax+offs_zbuf_linesize] + imul edi,[ecx+offs_zbup_y] + mov edx,[ecx+offs_zbup_x] + imul edx,PSZB + add edi,edx + add edi,[eax+offs_zbuf_pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB) +if INTERP_Z eq 1 + mov edx,[ecx+offs_zbup_y] + imul edx,[sx] + add edx,[ecx+offs_zbup_x] + add edx,[eax+offs_zbuf_zbuf] + mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x) + mov edx,[ecx+offs_zbup_z] + mov [z],edx ;z = p1.z +end if + + mov ebx,[p2] + mov eax,[ebx+offs_zbup_x] + sub eax,[ecx+offs_zbup_x] + mov [d_x],eax ;d_x = p2.x - p1.x + mov eax,[ebx+offs_zbup_y] + sub eax,[ecx+offs_zbup_y] + mov [d_y],eax ;d_y = p2.y - p1.y + + mov eax,[ecx+offs_zbup_r] + shl eax,8 + mov [r],eax ;r = p1.r << 8 + mov eax,[ecx+offs_zbup_g] + shl eax,8 + mov [g],eax ;g = p1.g << 8 + mov eax,[ecx+offs_zbup_b] + shl eax,8 + mov [b],eax ;b = p1.b << 8 + +macro RGBPIXEL +{ +if TGL_FEATURE_RENDER_BITS eq 24 + mov eax,[r] + shr eax,16 + mov byte[edi],al + mov eax,[g] + shr eax,16 + mov byte[edi+1],al + mov eax,[b] + shr eax,16 + mov byte[edi+2],al +;;; else +;*pp = RGB_TO_PIXEL(r >> 8,g >> 8,b >> 8) +end if +} + +macro PUTPIXEL +{ +if INTERP_Z eq 1 +local .end_0 + mov eax,[z] + shr eax, ZB_POINT_Z_FRAC_BITS + mov [zz],eax + cmp eax,[pz] + jl .end_0 + RGBPIXEL + mov eax,dword[zz] + mov [pz],eax + .end_0: +else ; INTERP_Z + RGBPIXEL +end if ; INTERP_Z +} + +macro DRAWLINE d_x,d_y,inc_1,inc_2 +{ + mov eax,d_x + mov [n],eax + + mov ebx,[p1] + mov ecx,[p2] +if INTERP_Z eq 1 + mov eax,[ecx+offs_zbup_z] + sub eax,[ebx+offs_zbup_z] + xor edx,edx + div dword[n] + mov [zinc],eax ;zinc=(p2.z-p1.z)/n +end if + + ;ebx=&p1, ecx=&p2 + mov eax,[ecx+offs_zbup_r] + sub eax,[ebx+offs_zbup_r] + shl eax,8 + xor edx,edx + div dword[n] + mov [rinc],eax ;rinc=((p2.r-p1.r)<<8)/n + + mov eax,[ecx+offs_zbup_g] + sub eax,[ebx+offs_zbup_g] + shl eax,8 + xor edx,edx + div dword[n] + mov [ginc],eax ;ginc=((p2.g-p1.g)<<8)/n + + mov eax,[ecx+offs_zbup_b] + sub eax,[ebx+offs_zbup_b] + shl eax,8 + xor edx,edx + div dword[n] + mov [binc],eax ;binc=((p2.b-p1.b)<<8)/n + + shl dword d_y,1 + mov eax, d_y + sub eax, d_x + mov [a],eax ;a=2*d_y-d_x + shl dword d_x,1 + mov eax, d_y + sub d_x,eax + mov eax,inc_1 + imul eax,PSZB + mov [pp_inc_1],eax ;pp_inc_1 = inc_1*PSZB + mov eax,inc_2 + imul eax,PSZB + mov [pp_inc_2],eax ;pp_inc_2 = inc_2*PSZB + +local .do_cycle +local .els_0 +local .end_0 + +align 4 +.do_cycle: + + PUTPIXEL +if INTERP_Z eq 1 + mov eax,[zinc] + add [z],eax +end if + mov eax,[rinc] + add [r],eax + mov eax,[ginc] + add [g],eax + mov eax,[binc] + add [b],eax + + cmp dword[a],0 + jle .els_0 + add edi,[pp_inc_1] +if INTERP_Z eq 1 + mov eax,inc_1 + add [pz],eax +end if + mov eax,d_x + sub [a],eax + jmp .end_0 + +.els_0: + add edi,[pp_inc_2] +if INTERP_Z eq 1 + mov eax,inc_2 + add [pz],eax +end if + mov eax,d_y + add [a],eax + +.end_0: + dec dword[n] + cmp dword[n],0 + jge .do_cycle +} + +; fin macro + + mov eax,[d_x] + cmp eax,0 + jne .els_0 + cmp dword[d_y],0 + jne .els_0 + ;if (d_x==0 && d_y==0) + PUTPIXEL + jmp .end_2 + .els_0: + cmp eax,0 + jle .els_3 + ;if (d_x > 0) + mov esi,[sx] + inc esi + cmp eax,[d_y] + jl .els_2 + ;if (d_x >= d_y) + DRAWLINE [d_x], [d_y], esi, 1 + jmp .end_2 + .els_2: + DRAWLINE [d_y], [d_x], esi, [sx] + jmp .end_2 + .els_3: + xor eax,eax + sub eax,[d_x] + mov [d_x],eax + mov esi,[sx] + dec esi + cmp eax,[d_y] + jl .els_4 + ;if (d_x >= d_y) + DRAWLINE [d_x], [d_y], esi, -1 + jmp .end_2 + .els_4: + DRAWLINE [d_y], [d_x], esi, [sx] + .end_2: + +popad + ret +endp + +restore INTERP_Z + +; internal defines +purge DRAWLINE +purge PUTPIXEL +purge RGBPIXEL diff --git a/programs/develop/libraries/TinyGL/asm_fork/zmath.asm b/programs/develop/libraries/TinyGL/asm_fork/zmath.asm new file mode 100644 index 0000000000..6873b02ee7 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zmath.asm @@ -0,0 +1,428 @@ +; Some simple mathematical functions. Don't look for some logic in +; the function names :-) + +; ******* Gestion des matrices 4x4 ****** + +align 4 +proc gl_M4_Id uses eax ecx edi, a:dword + mov edi,[a] + add edi,4 + mov ecx,14 + mov eax,0.0 + rep stosd + mov eax,1.0 + stosd + mov edi,[a] + stosd + add edi,16 + stosd + add edi,16 + stosd + ret +endp + +align 4 +proc gl_M4_IsId uses ebx ecx, a:dword + mov eax,[a] + xor ebx,ebx + xor ecx,ecx + .cycle_01: + fld dword[eax] + cmp ecx,ebx + je .once + ftst ; 0.0 + fstsw ax + sahf + je @f + jmp .not_1 ; 0.0 + .once: + fld1 + fcomp st1 ; 1.0 + fstsw ax + test ah,0x40 + je .not_1 ; 1.0 + @@: + add eax,4 + inc ebx + btr ebx,2 + jnc .cycle_01 + inc ecx + bt ecx,2 ; ecx==4 + jnc .cycle_01 + + mov eax,1 + jmp @f + .not_1: + xor eax,eax + @@: + ret +endp + +align 4 +proc gl_M4_Mul, c:dword,a:dword,b:dword +pushad + mov edx,[c] + xor eax,eax + .cycle_0: ;i + xor ebx,ebx + .cycle_1: ;j + finit + fldz ;sum=0 + xor ecx,ecx + M4_reg edi,[a],eax,0 + .cycle_2: ;k + fld dword[edi] + add edi,4 + M4_reg esi,[b],ecx,ebx + fmul dword[esi] + fadd st0,st1 ;sum += a[i][k] * b[k][j] + inc ecx + cmp ecx,4 + jl .cycle_2 + fstp dword[edx] ;c[i][j] = sum + add edx,4 + inc ebx + cmp ebx,4 + jl .cycle_1 + inc eax + cmp eax,4 + jl .cycle_0 + finit +if DEBUG ;gl_M4_Mul + stdcall dbg_print,f_m4m,txt_nl + stdcall gl_print_matrix,[c],4 + stdcall dbg_print,txt_sp,txt_nl +end if +popad + ret +endp + +; c=c*a +align 4 +proc gl_M4_MulLeft, c:dword,b:dword +locals + i dd ? + a M4 +endl +pushad + mov ecx,16 + mov esi,[c] + mov edi,ebp + sub edi,sizeof.M4 + rep movsd ; [a]=[c] + + mov edx,[c] + mov dword[i],0 + .cycle_0: ;i + xor ebx,ebx + .cycle_1: ;j + finit + fldz ;sum=0 + xor ecx,ecx + mov eax,ebp + sub eax,sizeof.M4 + M4_reg edi,eax,dword[i],0 + .cycle_2: ;k + fld dword[edi] + add edi,4 + M4_reg esi,[b],ecx,ebx + fmul dword[esi] + fadd st0,st1 ;sum += a[i][k] * b[k][j] + inc ecx + add eax,4 + cmp ecx,4 + jl .cycle_2 + fstp dword[edx] ;c[i][j] = sum + add edx,4 + inc ebx + cmp ebx,4 + jl .cycle_1 + inc dword[i] + cmp dword[i],4 + jl .cycle_0 + finit +if DEBUG ;gl_M4_MulLeft + stdcall dbg_print,f_m4ml,txt_nl + stdcall gl_print_matrix,[c],4 + stdcall dbg_print,txt_sp,txt_nl +end if +popad + ret +endp + +align 4 +proc gl_M4_Move uses ecx edi esi, a:dword,b:dword + mov edi,[a] + mov esi,[b] + mov ecx,sizeof.M4/4 + rep movsd + ret +endp + +align 4 +proc gl_MoveV3 uses edi esi, a:dword,b:dword + mov edi,[a] + mov esi,[b] + movsd + movsd + movsd + ret +endp + +;void gl_MulM4V3(V3 *a,M4 *b,V3 *c) +;{ +; a->X=b->m[0][0]*c->X+b->m[0][1]*c->Y+b->m[0][2]*c->Z+b->m[0][3]; +; a->Y=b->m[1][0]*c->X+b->m[1][1]*c->Y+b->m[1][2]*c->Z+b->m[1][3]; +; a->Z=b->m[2][0]*c->X+b->m[2][1]*c->Y+b->m[2][2]*c->Z+b->m[2][3]; +;} + +;void gl_MulM3V3(V3 *a,M4 *b,V3 *c) +;{ +; a->X=b->m[0][0]*c->X+b->m[0][1]*c->Y+b->m[0][2]*c->Z; +; a->Y=b->m[1][0]*c->X+b->m[1][1]*c->Y+b->m[1][2]*c->Z; +; a->Z=b->m[2][0]*c->X+b->m[2][1]*c->Y+b->m[2][2]*c->Z; +;} + +;void gl_M4_MulV4(V4 *a,M4 *b,V4 *c) +;{ +; a->X=b->m[0][0]*c->X+b->m[0][1]*c->Y+b->m[0][2]*c->Z+b->m[0][3]*c->W; +; a->Y=b->m[1][0]*c->X+b->m[1][1]*c->Y+b->m[1][2]*c->Z+b->m[1][3]*c->W; +; a->Z=b->m[2][0]*c->X+b->m[2][1]*c->Y+b->m[2][2]*c->Z+b->m[2][3]*c->W; +; a->W=b->m[3][0]*c->X+b->m[3][1]*c->Y+b->m[3][2]*c->Z+b->m[3][3]*c->W; +;} + +; transposition of a 4x4 matrix +align 4 +proc gl_M4_Transpose uses eax ecx edx, a:dword, b:dword + mov eax,[a] + mov ecx,[b] + + mov edx,[ecx] + mov [eax],edx + mov edx,[ecx+0x10] + mov [eax+0x4],edx + mov edx,[ecx+0x20] + mov [eax+0x8],edx + mov edx,[ecx+0x30] + mov [eax+0x0c],edx + + mov edx,[ecx+0x4] + mov [eax+0x10],edx + mov edx,[ecx+0x14] + mov [eax+0x14],edx + mov edx,[ecx+0x24] + mov [eax+0x18],edx + mov edx,[ecx+0x34] + mov [eax+0x1c],edx + + mov edx,[ecx+0x8] + mov [eax+0x20],edx + mov edx,[ecx+0x18] + mov [eax+0x24],edx + mov edx,[ecx+0x28] + mov [eax+0x28],edx + mov edx,[ecx+0x38] + mov [eax+0x2c],edx + + mov edx,[ecx+0x0c] + mov [eax+0x30],edx + mov edx,[ecx+0x1c] + mov [eax+0x34],edx + mov edx,[ecx+0x2c] + mov [eax+0x38],edx + mov edx,[ecx+0x3c] + mov [eax+0x3c],edx + ret +endp + +;/* inversion of an orthogonal matrix of type Y=M.X+P */ +;void gl_M4_InvOrtho(M4 *a,M4 b) +;{ +; int i,j; +; float s; +; for(i=0;i<3;i++) +; for(j=0;j<3;j++) a->m[i][j]=b.m[j][i]; +; a->m[3][0]=0.0; a->m[3][1]=0.0; a->m[3][2]=0.0; a->m[3][3]=1.0; +; for(i=0;i<3;i++) { +; s=0; +; for(j=0;j<3;j++) s-=b.m[j][i]*b.m[j][3]; +; a->m[i][3]=s; +; } +;} + +;/* Inversion of a general nxn matrix. +; Note : m is destroyed */ + +align 4 +proc Matrix_Inv uses ecx, r:dword, m:dword, n:dword ;(float *r,float *m,int n) +; int i,j,k,l; +; float max,tmp,t; + +; /* identite dans r */ +; for(i=0;ifabs(max)) { +; k=i; +; max=m[i*n+j]; +; } + +; /* non intersible matrix */ +; if (max==0) return 1; + +; /* permutation des lignes j et k */ +; if (k!=j) { +; for(i=0;im[0][0]*m->m[1][1]*m->m[2][2]-m->m[0][0]*m->m[1][2]*m->m[2][1]- +; m->m[1][0]*m->m[0][1]*m->m[2][2]+m->m[1][0]*m->m[0][2]*m->m[2][1]+ +; m->m[2][0]*m->m[0][1]*m->m[1][2]-m->m[2][0]*m->m[0][2]*m->m[1][1]; + +; a->m[0][0] = (m->m[1][1]*m->m[2][2]-m->m[1][2]*m->m[2][1])/det; +; a->m[0][1] = -(m->m[0][1]*m->m[2][2]-m->m[0][2]*m->m[2][1])/det; +; a->m[0][2] = -(-m->m[0][1]*m->m[1][2]+m->m[0][2]*m->m[1][1])/det; + +; a->m[1][0] = -(m->m[1][0]*m->m[2][2]-m->m[1][2]*m->m[2][0])/det; +; a->m[1][1] = (m->m[0][0]*m->m[2][2]-m->m[0][2]*m->m[2][0])/det; +; a->m[1][2] = -(m->m[0][0]*m->m[1][2]-m->m[0][2]*m->m[1][0])/det; + +; a->m[2][0] = (m->m[1][0]*m->m[2][1]-m->m[1][1]*m->m[2][0])/det; +; a->m[2][1] = -(m->m[0][0]*m->m[2][1]-m->m[0][1]*m->m[2][0])/det; +; a->m[2][2] = (m->m[0][0]*m->m[1][1]-m->m[0][1]*m->m[1][0])/det; +;} + +; vector arithmetic + +;int gl_V3_Norm(V3 *a) +;{ +; float n; +; n=sqrt(a->X*a->X+a->Y*a->Y+a->Z*a->Z); +; if (n==0) return 1; +; a->X/=n; +; a->Y/=n; +; a->Z/=n; +; return 0; +;} + +macro gl_V3_New p_mem, x, y, z +{ + mov dword[p_mem],x + mov dword[p_mem+4],y + mov dword[p_mem+8],z +} + +macro gl_V4_New p_mem, x, y, z, w +{ + mov dword[p_mem],x + mov dword[p_mem+4],y + mov dword[p_mem+8],z + mov dword[p_mem+12],w +} diff --git a/programs/develop/libraries/TinyGL/asm_fork/zmath.inc b/programs/develop/libraries/TinyGL/asm_fork/zmath.inc new file mode 100644 index 0000000000..ea0db53673 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/zmath.inc @@ -0,0 +1,42 @@ +; Matrix & Vertex + +align 4 +an180f dd 180.0 ;константа для вычисления углов + +struct M4 + m rd 4*4 ;float[4][4] +ends + +; макрос облегчающий доступ к элементам матрицы M4 +; для доступа к элементам 1-й индекс множится на 16, 2-й на 4: +; m[i1*16][i2*4], потом все пишется в регистр reg: +; reg <-- m[i1][i2] +macro M4_reg reg,m,i1,i2 +{ + mov reg,i1 ;1-й индекс + if i2 eq 0 + shl reg,4 + else + shl reg,2 + add reg,i2 ;2-й индекс + shl reg,2 + end if + add reg,m ;указатель на начало матрицы +} + +struct M3 + m rd 3*3 ;float[3][3] +ends + +struct M34 + m rd 3*4 ;float[3][4] +ends + +struct V3 + v rd 3 ;float[3] +ends + +struct V4 + v rd 4 ;float[4] +ends + diff --git a/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm new file mode 100644 index 0000000000..b4edd96245 --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm @@ -0,0 +1,344 @@ + +INTERP_Z equ 1 + +macro DRAW_INIT +{ +if TGL_FEATURE_RENDER_BITS eq 24 + mov ecx,[p2] + mov eax,[ecx+offs_zbup_r] + shr eax,8 + mov [colorR],eax ;colorR=p2.r>>8 + mov eax,[ecx+offs_zbup_g] + shr eax,8 + mov [colorG],eax ;colorG=p2.g>>8 + mov eax,[ecx+offs_zbup_b] + shr eax,8 + mov [colorB],eax ;colorB=p2.b>>8 +else +; color=RGB_TO_PIXEL(p2->r,p2->g,p2->b); +end if +} + +macro PUT_PIXEL _a +{ +; zz=z >> ZB_POINT_Z_FRAC_BITS; +; if (zz >= pz[_a]) { +if TGL_FEATURE_RENDER_BITS eq 24 +; pp[3 * _a]=colorR; +; pp[3 * _a + 1]=colorG; +; pp[3 * _a + 2]=colorB; +; pz[_a]=zz; +else +; pp[_a]=color; +; pz[_a]=zz; +end if +; } +; z+=dzdx; +} + +align 4 +proc ZB_fillTriangleFlat, zb:dword, p0:dword, p1:dword, p2:dword +locals +if TGL_FEATURE_RENDER_BITS eq 24 + colorR db ? + colorG db ? + colorB db ? ;unsigned char +else + color dd ? ;int +end if +include 'ztriangle.inc' + ret +endp + +; +; Smooth filled triangle. +; The code below is very tricky :) +; + +INTERP_Z equ 1 +INTERP_RGB equ 1 + +macro DRAW_INIT +{ +if TGL_FEATURE_RENDER_BITS eq 16 +; _drgbdx=((drdx / (1<<6)) << 22) & 0xFFC00000; +; _drgbdx|=(dgdx / (1<<5)) & 0x000007FF; +; _drgbdx|=((dbdx / (1<<7)) << 12) & 0x001FF000; +end if +} + +macro PUT_PIXEL _a +{ +; zz=z >> ZB_POINT_Z_FRAC_BITS; +if TGL_FEATURE_RENDER_BITS eq 24 +; if (zz >= pz[_a]) { +; pp[3 * _a]=or1 >> 8; +; pp[3 * _a + 1]=og1 >> 8; +; pp[3 * _a + 2]=ob1 >> 8; +; pz[_a]=zz; +; } +; z+=dzdx; +; og1+=dgdx; +; or1+=drdx; +; ob1+=dbdx; +elseif TGL_FEATURE_RENDER_BITS eq 16 +; if (zz >= pz[_a]) { +; tmp=rgb & 0xF81F07E0; +; pp[_a]=tmp | (tmp >> 16); +; pz[_a]=zz; +; } +; z+=dzdx; +; rgb=(rgb+drgbdx) & ( ~ 0x00200800); +else +; if (zz >= pz[_a]) { +; pp[_a] = RGB_TO_PIXEL(or1, og1, ob1); +; pz[_a]=zz; +; } +; z+=dzdx; +; og1+=dgdx; +; or1+=drdx; +; ob1+=dbdx; +end if +} + +macro DRAW_LINE +{ +if TGL_FEATURE_RENDER_BITS eq 16 +; register unsigned short *pz; +; register PIXEL *pp; +; register unsigned int tmp,z,zz,rgb,drgbdx; +; register int n; +; n=(x2 >> 16) - x1; +; pp=pp1+x1; +; pz=pz1+x1; +; z=z1; +; rgb=(r1 << 16) & 0xFFC00000; +; rgb|=(g1 >> 5) & 0x000007FF; +; rgb|=(b1 << 5) & 0x001FF000; +; drgbdx=_drgbdx; +; while (n>=3) { +; PUT_PIXEL(0); +; PUT_PIXEL(1); +; PUT_PIXEL(2); +; PUT_PIXEL(3); +; pz+=4; +; pp+=4; +; n-=4; +; } +; while (n>=0) { +; PUT_PIXEL(0); +; pz+=1; +; pp+=1; +; n-=1; +; } +end if +if TGL_FEATURE_RENDER_BITS eq 24 +; register unsigned short *pz; +; register PIXEL *pp; +; register unsigned int s,t,z,zz; +; register int n,dsdx,dtdx; +; float sz,tz,fz,zinv; +; n=(x2>>16)-x1; +; fz=(float)z1; +; zinv=1.0 / fz; +; pp=(pp1 + x1 * PSZB); +; pz=pz1+x1; +; z=z1; +; sz=sz1; +; tz=tz1; +; while (n>=(NB_INTERP-1)) { +; { +; float ss,tt; +; ss=(sz * zinv); +; tt=(tz * zinv); +; s=(int) ss; +; t=(int) tt; +; dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); +; dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); +; fz+=fndzdx; +; zinv=1.0 / fz; +; } +; PUT_PIXEL(0); +; PUT_PIXEL(1); +; PUT_PIXEL(2); +; PUT_PIXEL(3); +; PUT_PIXEL(4); +; PUT_PIXEL(5); +; PUT_PIXEL(6); +; PUT_PIXEL(7); +; pz+=NB_INTERP; +; pp=(pp + NB_INTERP * PSZB); +; n-=NB_INTERP; +; sz+=ndszdx; +; tz+=ndtzdx; +; } +; { +; float ss,tt; +; ss=(sz * zinv); +; tt=(tz * zinv); +; s=(int) ss; +; t=(int) tt; +; dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); +; dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); +; } +; while (n>=0) { +; PUT_PIXEL(0); +; pz+=1; +; pp=(PIXEL *)((char *)pp + PSZB); +; n-=1; +; } +end if +} + +align 4 +proc ZB_fillTriangleSmooth, zb:dword, p0:dword, p1:dword, p2:dword +locals +if TGL_FEATURE_RENDER_BITS eq 16 + _drgbdx dd ? ;int +end if +include 'ztriangle.inc' + ret +endp + +align 4 +proc ZB_setTexture uses eax ebx, zb:dword, texture:dword + mov eax,[zb] + mov ebx,[texture] + mov dword[eax+offs_zbuf_current_texture],ebx + ret +endp + +INTERP_Z equ 1 +INTERP_ST equ 1 + +macro DRAW_INIT +{ +; texture=zb->current_texture; +} + +macro PUT_PIXEL _a +{ +; zz=z >> ZB_POINT_Z_FRAC_BITS; +if TGL_FEATURE_RENDER_BITS eq 24 +; unsigned char *ptr; +; if (zz >= pz[_a]) { +; ptr = texture + (((t & 0x3FC00000) | s) >> 14) * 3; +; pp[3 * _a]= ptr[0]; +; pp[3 * _a + 1]= ptr[1]; +; pp[3 * _a + 2]= ptr[2]; +; pz[_a]=zz; +; } +else +; if (zz >= pz[_a]) { +; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14]; +; pz[_a]=zz; +; } +end if +; z+=dzdx; +; s+=dsdx; +; t+=dtdx; +} + +align 4 +proc ZB_fillTriangleMapping, zb:dword, p0:dword, p1:dword, p2:dword +locals + texture dd ? ;PIXEL* +include 'ztriangle.inc' + ret +endp + +; +; Texture mapping with perspective correction. +; We use the gradient method to make less divisions. +; TODO: pipeline the division +; +if 1 + +INTERP_Z equ 1 +INTERP_STZ equ 1 + +NB_INTERP equ 8 + +macro DRAW_INIT +{ +; texture=zb->current_texture; +; fdzdx=(float)dzdx; +; fndzdx=NB_INTERP * fdzdx; +; ndszdx=NB_INTERP * dszdx; +; ndtzdx=NB_INTERP * dtzdx; +} + +macro PUT_PIXEL _a +{ +; zz=z >> ZB_POINT_Z_FRAC_BITS; +if TGL_FEATURE_RENDER_BITS eq 24 +; unsigned char *ptr; +; if (zz >= pz[_a]) { +; ptr = texture + (((t & 0x3FC00000) | (s & 0x003FC000)) >> 14) * 3; +; pp[3 * _a]= ptr[0]; +; pp[3 * _a + 1]= ptr[1]; +; pp[3 * _a + 2]= ptr[2]; +; pz[_a]=zz; +; } +else +; if (zz >= pz[_a]) { +; pp[_a]=*(PIXEL *)((char *)texture+ +; (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); +; pz[_a]=zz; +; } +end if +; z+=dzdx; +; s+=dsdx; +; t+=dtdx; +} + +align 4 +proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword +locals +; PIXEL *texture; +; float fdzdx,fndzdx,ndszdx,ndtzdx; +include 'ztriangle.inc' + ret +endp + +end if + +if 0 + +; slow but exact version (only there for reference, incorrect for 24 +; bits) + +INTERP_Z equ 1 +INTERP_STZ equ 1 + +macro DRAW_INIT +{ +; texture=zb->current_texture; +} + +macro PUT_PIXEL _a +{ +; float zinv; +; int s,t; +; zz=z >> ZB_POINT_Z_FRAC_BITS; +; if (zz >= pz[_a]) { +; zinv= 1.0 / (float) z; +; s= (int) (sz * zinv); +; t= (int) (tz * zinv); +; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14]; +; pz[_a]=zz; +; } +; z+=dzdx; +; sz+=dszdx; +; tz+=dtzdx; +} + +align 4 +proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword +locals + texture dd ? ;PIXEL* +include 'ztriangle.inc' + ret +endp + +end if diff --git a/programs/develop/libraries/TinyGL/asm_fork/ztriangle.inc b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.inc new file mode 100644 index 0000000000..8222176ece --- /dev/null +++ b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.inc @@ -0,0 +1,415 @@ +; +; We draw a triangle with various interpolations +; + t dd ? ;ZBufferPoint* + pr1 dd ? ;ZBufferPoint* + pr2 dd ? ;ZBufferPoint* + l1 dd ? ;ZBufferPoint* + l2 dd ? ;ZBufferPoint* + fdx1 dd ? + fdx2 dd ? + fdy1 dd ? + fdy2 dd ? + fz dd ? + d1 dd ? + d2 dd ? + pz1 dd ? ;unsigned short* + pp1 dd ? ;PIXEL* + part dd ? + update_left dd ? + update_right dd ? + + nb_lines dd ? + dx1 dd ? + dy1 dd ? + tmp dd ? + dx2 dd ? + dy2 dd ? + + error dd ? + derror dd ? + x1 dd ? + dxdy_min dd ? + dxdy_max dd ? + ; warning: x2 is multiplied by 2^16 + x2 dd ? + dx2dy2 dd ? + +if INTERP_Z eq 1 + z1 dd ? + dzdx dd ? + dzdy dd ? + dzdl_min dd ? + dzdl_max dd ? +end if +if INTERP_RGB eq 1 + r1 dd ? ;int + drdx dd ? + drdy dd ? + drdl_min dd ? + drdl_max dd ? + g1 dd ? + dgdx dd ? + dgdy dd ? + dgdl_min dd ? + dgdl_max dd ? + b1 dd ? + dbdx dd ? + dbdy dd ? + dbdl_min dd ? + dbdl_max dd ? +end if +if INTERP_ST eq 1 + ;s1 dd ? + dsdx dd ? + dsdy dd ? + dsdl_min dd ? + dsdl_max dd ? + t1 dd ? + dtdx dd ? + dtdy dd ? + dtdl_min dd ? + dtdl_max dd ? +end if +if INTERP_STZ eq 1 + sz1 dd ? + dszdx dd ? + dszdy dd ? + dszdl_min dd ? + dszdl_max dd ? + tz1 dd ? + dtzdx dd ? + dtzdy dd ? + dtzdl_min dd ? + dtzdl_max dd ? +end if + +endl + +; /* we sort the vertex with increasing y */ +; if (p1->y < p0->y) { +; t = p0; +; p0 = p1; +; p1 = t; +; } +; if (p2->y < p0->y) { +; t = p2; +; p2 = p1; +; p1 = p0; +; p0 = t; +; } else if (p2->y < p1->y) { +; t = p1; +; p1 = p2; +; p2 = t; +; } + + ; we compute dXdx and dXdy for all interpolated values + +; fdx1 = p1->x - p0->x; +; fdy1 = p1->y - p0->y; + +; fdx2 = p2->x - p0->x; +; fdy2 = p2->y - p0->y; + +; fz = fdx1 * fdy2 - fdx2 * fdy1; +; if (fz == 0) +; return; +; fz = 1.0 / fz; + +; fdx1 *= fz; +; fdy1 *= fz; +; fdx2 *= fz; +; fdy2 *= fz; + +if INTERP_Z eq 1 +; d1 = p1->z - p0->z; +; d2 = p2->z - p0->z; +; dzdx = (int) (fdy2 * d1 - fdy1 * d2); +; dzdy = (int) (fdx1 * d2 - fdx2 * d1); +end if + +if INTERP_RGB eq 1 +; d1 = p1->r - p0->r; +; d2 = p2->r - p0->r; +; drdx = (int) (fdy2 * d1 - fdy1 * d2); +; drdy = (int) (fdx1 * d2 - fdx2 * d1); + +; d1 = p1->g - p0->g; +; d2 = p2->g - p0->g; +; dgdx = (int) (fdy2 * d1 - fdy1 * d2); +; dgdy = (int) (fdx1 * d2 - fdx2 * d1); + +; d1 = p1->b - p0->b; +; d2 = p2->b - p0->b; +; dbdx = (int) (fdy2 * d1 - fdy1 * d2); +; dbdy = (int) (fdx1 * d2 - fdx2 * d1); + +end if + +if INTERP_ST eq 1 +; d1 = p1->s - p0->s; +; d2 = p2->s - p0->s; +; dsdx = (int) (fdy2 * d1 - fdy1 * d2); +; dsdy = (int) (fdx1 * d2 - fdx2 * d1); + +; d1 = p1->t - p0->t; +; d2 = p2->t - p0->t; +; dtdx = (int) (fdy2 * d1 - fdy1 * d2); +; dtdy = (int) (fdx1 * d2 - fdx2 * d1); +end if + +if INTERP_STZ eq 1 +; { +; float zz; +; zz=(float) p0->z; +; p0->sz= (float) p0->s * zz; +; p0->tz= (float) p0->t * zz; +; zz=(float) p1->z; +; p1->sz= (float) p1->s * zz; +; p1->tz= (float) p1->t * zz; +; zz=(float) p2->z; +; p2->sz= (float) p2->s * zz; +; p2->tz= (float) p2->t * zz; + +; d1 = p1->sz - p0->sz; +; d2 = p2->sz - p0->sz; +; dszdx = (fdy2 * d1 - fdy1 * d2); +; dszdy = (fdx1 * d2 - fdx2 * d1); + +; d1 = p1->tz - p0->tz; +; d2 = p2->tz - p0->tz; +; dtzdx = (fdy2 * d1 - fdy1 * d2); +; dtzdy = (fdx1 * d2 - fdx2 * d1); +; } +end if + + ; screen coordinates + +; pp1 = (PIXEL *) ((char *) zb->pbuf + zb->linesize * p0->y); +; pz1 = zb->zbuf + p0->y * zb->xsize; + + DRAW_INIT + +; for(part=0;part<2;part++) { +; if (part == 0) { +; if (fz > 0) { +; update_left=1; +; update_right=1; +; l1=p0; +; l2=p2; +; pr1=p0; +; pr2=p1; +; } else { +; update_left=1; +; update_right=1; +; l1=p0; +; l2=p1; +; pr1=p0; +; pr2=p2; +; } +; nb_lines = p1->y - p0->y; +; } else { +; /* second part */ +; if (fz > 0) { +; update_left=0; +; update_right=1; +; pr1=p1; +; pr2=p2; +; } else { +; update_left=1; +; update_right=0; +; l1=p1; +; l2=p2; +; } +; nb_lines = p2->y - p1->y + 1; +; } + + ; compute the values for the left edge + +; if (update_left) { +; dy1 = l2->y - l1->y; +; dx1 = l2->x - l1->x; +; if (dy1 > 0) +; tmp = (dx1 << 16) / dy1; +; else +; tmp = 0; +; x1 = l1->x; +; error = 0; +; derror = tmp & 0x0000ffff; +; dxdy_min = tmp >> 16; +; dxdy_max = dxdy_min + 1; + +if INTERP_Z eq 1 +; z1=l1->z; +; dzdl_min=(dzdy + dzdx * dxdy_min); +; dzdl_max=dzdl_min + dzdx; +end if +if INTERP_RGB eq 1 +; r1=l1->r; +; drdl_min=(drdy + drdx * dxdy_min); +; drdl_max=drdl_min + drdx; + +; g1=l1->g; +; dgdl_min=(dgdy + dgdx * dxdy_min); +; dgdl_max=dgdl_min + dgdx; + +; b1=l1->b; +; dbdl_min=(dbdy + dbdx * dxdy_min); +; dbdl_max=dbdl_min + dbdx; +end if +if INTERP_ST eq 1 +; s1=l1->s; +; dsdl_min=(dsdy + dsdx * dxdy_min); +; dsdl_max=dsdl_min + dsdx; + +; t1=l1->t; +; dtdl_min=(dtdy + dtdx * dxdy_min); +; dtdl_max=dtdl_min + dtdx; +end if +if INTERP_STZ eq 1 +; sz1=l1->sz; +; dszdl_min=(dszdy + dszdx * dxdy_min); +; dszdl_max=dszdl_min + dszdx; + +; tz1=l1->tz; +; dtzdl_min=(dtzdy + dtzdx * dxdy_min); +; dtzdl_max=dtzdl_min + dtzdx; +end if +; } + +; /* compute values for the right edge */ + +; if (update_right) { +; dx2 = (pr2->x - pr1->x); +; dy2 = (pr2->y - pr1->y); +; if (dy2>0) +; dx2dy2 = ( dx2 << 16) / dy2; +; else +; dx2dy2 = 0; +; x2 = pr1->x << 16; +; } + +; /* we draw all the scan line of the part */ + +; while (nb_lines>0) { +; nb_lines--; +;#ifndef DRAW_LINE +; /* generic draw line */ +; { +; register PIXEL *pp; +; register int n; +if INTERP_Z eq 1 +; register unsigned short *pz; +; register unsigned int z,zz; +end if +if INTERP_RGB eq 1 +; register unsigned int or1,og1,ob1; +end if +if INTERP_ST eq 1 +; register unsigned int s,t; +end if +if INTERP_STZ eq 1 +; float sz,tz; +end if +; n=(x2 >> 16) - x1; +; pp=(PIXEL *)((char *)pp1 + x1 * PSZB); +if INTERP_Z eq 1 +; pz=pz1+x1; +; z=z1; +end if +if INTERP_RGB eq 1 +; or1 = r1; +; og1 = g1; +; ob1 = b1; +end if +if INTERP_ST eq 1 +; s=s1; +; t=t1; +end if +if INTERP_STZ eq 1 +; sz=sz1; +; tz=tz1; +end if +; while (n>=3) { +; PUT_PIXEL(0); +; PUT_PIXEL(1); +; PUT_PIXEL(2); +; PUT_PIXEL(3); +if INTERP_Z eq 1 +; pz+=4; +end if +; pp=(PIXEL *)((char *)pp + 4 * PSZB); +; n-=4; +; } +; while (n>=0) { +; PUT_PIXEL(0); +if INTERP_Z eq 1 +; pz+=1; +end if +; pp=(PIXEL *)((char *)pp + PSZB); +; n-=1; +; } +; } +;#else +; DRAW_LINE(); +;#endif +; +; /* left edge */ +; error+=derror; +; if (error > 0) { +; error-=0x10000; +; x1+=dxdy_max; +if INTERP_Z eq 1 +; z1+=dzdl_max; +end if +if INTERP_RGB eq 1 +; r1+=drdl_max; +; g1+=dgdl_max; +; b1+=dbdl_max; +end if +if INTERP_ST eq 1 +; s1+=dsdl_max; +; t1+=dtdl_max; +end if +if INTERP_STZ eq 1 +; sz1+=dszdl_max; +; tz1+=dtzdl_max; +end if +; } else { +; x1+=dxdy_min; +if INTERP_Z eq 1 +; z1+=dzdl_min; +end if +if INTERP_RGB eq 1 +; r1+=drdl_min; +; g1+=dgdl_min; +; b1+=dbdl_min; +end if +if INTERP_ST eq 1 +; s1+=dsdl_min; +; t1+=dtdl_min; +end if +if INTERP_STZ eq 1 +; sz1+=dszdl_min; +; tz1+=dtzdl_min; +end if +; } +; +; /* right edge */ +; x2+=dx2dy2; +; +; /* screen coordinates */ +; pp1=(PIXEL *)((char *)pp1 + zb->linesize); +; pz1+=zb->xsize; +; } +; } +;} + +restore INTERP_Z +restore INTERP_RGB +restore INTERP_ST +restore INTERP_STZ + +purge DRAW_INIT +purge DRAW_LINE +purge PUT_PIXEL