summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2001-08-08 15:49:59 +0000
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:36 +0200
commita113617c026d00770c0a01b292386bd1857f5a6a (patch)
treef0a689c37369f985171fabd9b9444d74a50c49df
parent9e5b7f430d3c5f30042c1fa380ed6b4be13c884d (diff)
Fixed major bug in TranslatePoint (was accidently loading a value to edx
instead of edi). Failed to get anything comprehendible on screen.
-rw-r--r--Makefile2
-rw-r--r--src/kshape.c2
-rw-r--r--src/main.c6
-rw-r--r--src/math.asm3
-rw-r--r--src/mathline.c113
-rw-r--r--src/opengl.c64
6 files changed, 62 insertions, 128 deletions
diff --git a/Makefile b/Makefile
index b9839ff..b7635ad 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
CC = gcc
NASM = nasm
-CFLAGS = -g -Wall -pipe -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets
+CFLAGS = -g -Wall -pipe -O2 -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp/win95/frontend -Iavp/win95/gadgets
CXXFLAGS = $(CFLAGS)
LDLIBS = -lm # /home/relnev/ElectricFence-2.2.2/libefence.a
diff --git a/src/kshape.c b/src/kshape.c
index 1e5d12b..0e95c46 100644
--- a/src/kshape.c
+++ b/src/kshape.c
@@ -4508,7 +4508,7 @@ static void TranslatePoint(float *source, float *dest, float *matrix)
/* Moved to a separate file because I can't figure out the damn syntax! */
__asm__("call TranslatePoint_Asm \n\t"
:
- : "S" (source), "b" (dest), "d" (matrix)
+ : "S" (source), "b" (dest), "D" (matrix)
);
}
diff --git a/src/main.c b/src/main.c
index 117477a..eeea7d7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -56,10 +56,12 @@ int InitialiseWindowsSystem()
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glFrustum(-1, 1, -1, 1, 1, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
-
+
+ glEnable(GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
+
return 0;
}
diff --git a/src/math.asm b/src/math.asm
index 555b289..4ac6913 100644
--- a/src/math.asm
+++ b/src/math.asm
@@ -4,7 +4,7 @@ SECTION .text
GLOBAL TranslatePoint_Asm
; float *source, float *dest, float *matrix
-; "S" (source), "b" (dest), "d" (matrix)
+; "S" (source), "b" (dest), "D" (matrix)
TranslatePoint_Asm:
fld dword [esi]
fmul dword [edi]
@@ -49,4 +49,3 @@ TranslatePoint_Asm:
fstp dword [ebx+8]
ret
- \ No newline at end of file
diff --git a/src/mathline.c b/src/mathline.c
index ca3546d..99837b2 100644
--- a/src/mathline.c
+++ b/src/mathline.c
@@ -543,119 +543,6 @@ typedef struct matrixch {
*/
-#if 0 /* TODO if these are needed */
-static void RotateVector_ASM(VECTORCH *v, MATRIXCH *m)
-{
- _asm
- {
- mov esi,v
- mov edi,m
-
- mov eax,[edi + 0]
- imul DWORD PTR [esi + 0]
- shrd eax,edx,16
- mov ecx,eax
- mov eax,[edi + 12]
- imul DWORD PTR [esi + 4]
- shrd eax,edx,16
- add ecx,eax
- mov eax,[edi + 24]
- imul DWORD PTR [esi + 8]
- shrd eax,edx,16
- add ecx,eax
-
- mov eax,[edi + 4]
- imul DWORD PTR [esi + 0]
- shrd eax,edx,16
- mov ebx,eax
- mov eax,[edi + 16]
- imul DWORD PTR [esi + 4]
- shrd eax,edx,16
- add ebx,eax
- mov eax,[edi + 28]
- imul DWORD PTR [esi + 8]
- shrd eax,edx,16
- add ebx,eax
-
- mov eax,[edi + 8]
- imul DWORD PTR [esi + 0]
- shrd eax,edx,16
- mov ebp,eax
- mov eax,[edi + 20]
- imul DWORD PTR [esi + 4]
- shrd eax,edx,16
- add ebp,eax
- mov eax,[edi + 32]
- imul DWORD PTR [esi + 8]
- shrd eax,edx,16
- add ebp,eax
-
- mov [esi + 0],ecx
- mov [esi + 4],ebx
- mov [esi + 8],ebp
- }
-}
-
-/*
-
- Here is the same function, this time copying the result to a second vector
-
-*/
-
-static void RotateAndCopyVector_ASM(VECTORCH *v1, VECTORCH *v2, MATRIXCH *m)
-{
- _asm
- {
- mov esi,v1
- mov edi,m
-
- mov eax,[edi + 0]
- imul DWORD PTR [esi + 0]
- shrd eax,edx,16
- mov ecx,eax
- mov eax,[edi + 12]
- imul DWORD PTR [esi + 4]
- shrd eax,edx,16
- add ecx,eax
- mov eax,[edi + 24]
- imul DWORD PTR [esi + 8]
- shrd eax,edx,16
- add ecx,eax
-
- mov eax,[edi + 4]
- imul DWORD PTR [esi + 0]
- shrd eax,edx,16
- mov ebx,eax
- mov eax,[edi + 16]
- imul DWORD PTR [esi + 4]
- shrd eax,edx,16
- add ebx,eax
- mov eax,[edi + 28]
- imul DWORD PTR [esi + 8]
- shrd eax,edx,16
- add ebx,eax
-
- mov eax,[edi + 8]
- imul DWORD PTR [esi + 0]
- shrd eax,edx,16
- mov ebp,eax
- mov eax,[edi + 20]
- imul DWORD PTR [esi + 4]
- shrd eax,edx,16
- add ebp,eax
- mov eax,[edi + 32]
- imul DWORD PTR [esi + 8]
- shrd eax,edx,16
- add ebp,eax
-
- mov edx,v2
- mov [edx + 0],ecx
- mov [edx + 4],ebx
- mov [edx + 8],ebp
- }
-}
-#endif
-
/*
Square Root
diff --git a/src/opengl.c b/src/opengl.c
index e24a595..d9851b2 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -30,6 +30,9 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER
int texoffset;
void *TextureHandle;
int i;
+ GLfloat ZNear, zvalue;
+
+ ZNear = (GLfloat) (Global_VDB_Ptr->VDB_ClipZ * GlobalScale);
texoffset = inputPolyPtr->PolyColour & ClrTxDefn;
if (texoffset) {
@@ -41,7 +44,34 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER
fprintf(stderr, "D3D_ZBufferedGouraudTexturedPolygon_Output(%p, %p)\n", inputPolyPtr, renderVerticesPtr);
fprintf(stderr, "\tRenderPolygon.NumberOfVertices = %d\n", RenderPolygon.NumberOfVertices);
fprintf(stderr, "\ttexoffset = %d (ptr = %p)\n", texoffset, texoffset ? (void *)ImageHeaderArray[texoffset].D3DHandle : CurrTextureHandle);
-
+
+switch(RenderPolygon.TranslucencyMode)
+{
+ case TRANSLUCENCY_OFF:
+ glBlendFunc(GL_ONE, GL_ZERO);
+ break;
+ case TRANSLUCENCY_NORMAL:
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ break;
+ case TRANSLUCENCY_COLOUR:
+ glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+ break;
+ case TRANSLUCENCY_INVCOLOUR:
+ glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
+ break;
+ case TRANSLUCENCY_GLOWING:
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ break;
+ case TRANSLUCENCY_DARKENINGCOLOUR:
+ glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
+ break;
+ case TRANSLUCENCY_JUSTSETZ:
+ glBlendFunc(GL_ZERO, GL_ONE);
+ break;
+ default:
+ fprintf(stderr, "RenderPolygon.TranslucencyMode: invalid %d\n", RenderPolygon.TranslucencyMode);
+}
+
glBegin(GL_POLYGON);
for (i = 0; i < RenderPolygon.NumberOfVertices; i++) {
GLfloat x, y, z;
@@ -49,14 +79,30 @@ void D3D_ZBufferedGouraudTexturedPolygon_Output(POLYHEADER *inputPolyPtr, RENDER
RENDERVERTEX *vertices = &renderVerticesPtr[i];
/* this is just random garbage */
-// x1 = (vertices->X*(Global_VDB_Ptr->VDB_ProjX+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreX;
-// y1 = (vertices->Y*(Global_VDB_Ptr->VDB_ProjY+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreY;
- x = vertices->X;
- y = vertices->Y;
-
- x = x/32768.0;
- y = y/32768.0;
- z = -1+-1.0f/vertices->Z;
+ x1 = (vertices->X*(Global_VDB_Ptr->VDB_ProjX+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreX;
+ y1 = (vertices->Y*(Global_VDB_Ptr->VDB_ProjY+1))/vertices->Z+Global_VDB_Ptr->VDB_CentreY;
+// x = vertices->X;
+// y = vertices->Y;
+ x = x1;
+ y = y1;
+
+// x = x/32768.0;
+// y = y/32768.0;
+// x = (x - 32768.0)/32768.0;
+// y = (y - 32768.0)/32768.0;
+ x = (x - 320.0)/320.0;
+ y = (y - 240.0)/240.0;
+
+// z = vertices->Z*16;
+// z = -z/65536;
+
+ zvalue = vertices->Z+HeadUpDisplayZOffset;
+ zvalue = 1.0f - ZNear/zvalue;
+ z = -zvalue;
+
+// x *= 16.0;
+// y *= 16.0;
+// z *= 16.0;
glColor4ub(vertices->R, vertices->G, vertices->B, vertices->A);
glVertex3f(x, y, z);