[Glide64] Clean up OGLgeometry.cpp

This commit is contained in:
zilmar 2016-02-04 19:34:02 +11:00
parent 009dfa94f3
commit ee5a59910c
1 changed files with 597 additions and 598 deletions

View File

@ -34,12 +34,11 @@ inline float ZCALC(const float & z, const float & q) {
#define zclamp (1.0f-1.0f/zscale) #define zclamp (1.0f-1.0f/zscale)
static inline void zclamp_glVertex4f(float a, float b, float c, float d) static inline void zclamp_glVertex4f(float a, float b, float c, float d)
{ {
if (c<zclamp) c = zclamp; if (c < zclamp) c = zclamp;
glVertex4f(a,b,c,d); glVertex4f(a, b, c, d);
} }
#define glVertex4f(a,b,c,d) zclamp_glVertex4f(a,b,c,d) #define glVertex4f(a,b,c,d) zclamp_glVertex4f(a,b,c,d)
static inline float ytex(int tmu, float y) { static inline float ytex(int tmu, float y) {
if (invtex[tmu]) if (invtex[tmu])
return invtex[tmu] - y; return invtex[tmu] - y;
@ -59,10 +58,10 @@ void init_geometry()
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grCoordinateSpace( GrCoordinateSpaceMode_t mode ) grCoordinateSpace(GrCoordinateSpaceMode_t mode)
{ {
LOG("grCoordinateSpace(%d)\r\n", mode); LOG("grCoordinateSpace(%d)\r\n", mode);
switch(mode) switch (mode)
{ {
case GR_WINDOW_COORDS: case GR_WINDOW_COORDS:
break; break;
@ -75,7 +74,7 @@ FX_ENTRY void FX_CALL
grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode) grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
{ {
LOG("grVertexLayout(%d,%d,%d)\r\n", param, offset, mode); LOG("grVertexLayout(%d,%d,%d)\r\n", param, offset, mode);
switch(param) switch (param)
{ {
case GR_PARAM_XY: case GR_PARAM_XY:
xy_en = mode; xy_en = mode;
@ -111,7 +110,7 @@ grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grCullMode( GrCullMode_t mode ) grCullMode(GrCullMode_t mode)
{ {
LOG("grCullMode(%d)\r\n", mode); LOG("grCullMode(%d)\r\n", mode);
static int oldmode = -1, oldinv = -1; static int oldmode = -1, oldinv = -1;
@ -120,7 +119,7 @@ grCullMode( GrCullMode_t mode )
return; return;
oldmode = mode; oldmode = mode;
oldinv = inverted_culling; oldinv = inverted_culling;
switch(mode) switch (mode)
{ {
case GR_CULL_DISABLE: case GR_CULL_DISABLE:
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
@ -148,10 +147,10 @@ grCullMode( GrCullMode_t mode )
// Depth buffer // Depth buffer
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDepthBufferMode( GrDepthBufferMode_t mode ) grDepthBufferMode(GrDepthBufferMode_t mode)
{ {
LOG("grDepthBufferMode(%d)\r\n", mode); LOG("grDepthBufferMode(%d)\r\n", mode);
switch(mode) switch (mode)
{ {
case GR_DEPTHBUFFER_DISABLE: case GR_DEPTHBUFFER_DISABLE:
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
@ -174,10 +173,10 @@ grDepthBufferMode( GrDepthBufferMode_t mode )
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDepthBufferFunction( GrCmpFnc_t function ) grDepthBufferFunction(GrCmpFnc_t function)
{ {
LOG("grDepthBufferFunction(%d)\r\n", function); LOG("grDepthBufferFunction(%d)\r\n", function);
switch(function) switch (function)
{ {
case GR_CMP_GEQUAL: case GR_CMP_GEQUAL:
if (w_buffer_mode) if (w_buffer_mode)
@ -223,7 +222,7 @@ grDepthBufferFunction( GrCmpFnc_t function )
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDepthMask( FxBool mask ) grDepthMask(FxBool mask)
{ {
LOG("grDepthMask(%d)\r\n", mask); LOG("grDepthMask(%d)\r\n", mask);
glDepthMask((GLboolean)mask); glDepthMask((GLboolean)mask);
@ -249,7 +248,7 @@ void FindBestDepthBias()
glReadBuffer(GL_BACK); glReadBuffer(GL_BACK);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
glColor4ub(255,255,255,255); glColor4ub(255, 255, 255, 255);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
for (x = 0; x < 4; x++) for (x = 0; x < 4; x++)
@ -275,9 +274,9 @@ void FindBestDepthBias()
glVertex3fv(vertices[3]); glVertex3fv(vertices[3]);
glEnd(); glEnd();
glReadPixels(x+2, 2+viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); glReadPixels(x + 2, 2 + viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
z -= 0.75f + 8e-6f; z -= 0.75f + 8e-6f;
if (z<0.0f) z = -z; if (z < 0.0f) z = -z;
if (z > 0.01f) continue; if (z > 0.01f) continue;
if (z < bestz) { if (z < bestz) {
bestz = z; bestz = z;
@ -291,20 +290,20 @@ void FindBestDepthBias()
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDepthBiasLevel( FxI32 level ) grDepthBiasLevel(FxI32 level)
{ {
LOG("grDepthBiasLevel(%d)\r\n", level); LOG("grDepthBiasLevel(%d)\r\n", level);
if (level) if (level)
{ {
if(w_buffer_mode) if (w_buffer_mode)
glPolygonOffset(1.0f, -(float)level*zscale/255.0f); glPolygonOffset(1.0f, -(float)level*zscale / 255.0f);
else else
glPolygonOffset(0, (float)level*biasFactor); glPolygonOffset(0, (float)level*biasFactor);
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
} }
else else
{ {
glPolygonOffset(0,0); glPolygonOffset(0, 0);
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
} }
grDisplayGLError("grDepthBiasLevel"); grDisplayGLError("grDepthBiasLevel");
@ -313,45 +312,45 @@ grDepthBiasLevel( FxI32 level )
// draw // draw
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDrawTriangle( const void *a, const void *b, const void *c ) grDrawTriangle(const void *a, const void *b, const void *c)
{ {
float *a_x = (float*)a + xy_off/sizeof(float); float *a_x = (float*)a + xy_off / sizeof(float);
float *a_y = (float*)a + xy_off/sizeof(float) + 1; float *a_y = (float*)a + xy_off / sizeof(float) + 1;
float *a_z = (float*)a + z_off/sizeof(float); float *a_z = (float*)a + z_off / sizeof(float);
float *a_q = (float*)a + q_off/sizeof(float); float *a_q = (float*)a + q_off / sizeof(float);
unsigned char *a_pargb = (unsigned char*)a + pargb_off; unsigned char *a_pargb = (unsigned char*)a + pargb_off;
float *a_s0 = (float*)a + st0_off/sizeof(float); float *a_s0 = (float*)a + st0_off / sizeof(float);
float *a_t0 = (float*)a + st0_off/sizeof(float) + 1; float *a_t0 = (float*)a + st0_off / sizeof(float) + 1;
float *a_s1 = (float*)a + st1_off/sizeof(float); float *a_s1 = (float*)a + st1_off / sizeof(float);
float *a_t1 = (float*)a + st1_off/sizeof(float) + 1; float *a_t1 = (float*)a + st1_off / sizeof(float) + 1;
float *a_fog = (float*)a + fog_ext_off/sizeof(float); float *a_fog = (float*)a + fog_ext_off / sizeof(float);
float *b_x = (float*)b + xy_off/sizeof(float); float *b_x = (float*)b + xy_off / sizeof(float);
float *b_y = (float*)b + xy_off/sizeof(float) + 1; float *b_y = (float*)b + xy_off / sizeof(float) + 1;
float *b_z = (float*)b + z_off/sizeof(float); float *b_z = (float*)b + z_off / sizeof(float);
float *b_q = (float*)b + q_off/sizeof(float); float *b_q = (float*)b + q_off / sizeof(float);
unsigned char *b_pargb = (unsigned char*)b + pargb_off; unsigned char *b_pargb = (unsigned char*)b + pargb_off;
float *b_s0 = (float*)b + st0_off/sizeof(float); float *b_s0 = (float*)b + st0_off / sizeof(float);
float *b_t0 = (float*)b + st0_off/sizeof(float) + 1; float *b_t0 = (float*)b + st0_off / sizeof(float) + 1;
float *b_s1 = (float*)b + st1_off/sizeof(float); float *b_s1 = (float*)b + st1_off / sizeof(float);
float *b_t1 = (float*)b + st1_off/sizeof(float) + 1; float *b_t1 = (float*)b + st1_off / sizeof(float) + 1;
float *b_fog = (float*)b + fog_ext_off/sizeof(float); float *b_fog = (float*)b + fog_ext_off / sizeof(float);
float *c_x = (float*)c + xy_off/sizeof(float); float *c_x = (float*)c + xy_off / sizeof(float);
float *c_y = (float*)c + xy_off/sizeof(float) + 1; float *c_y = (float*)c + xy_off / sizeof(float) + 1;
float *c_z = (float*)c + z_off/sizeof(float); float *c_z = (float*)c + z_off / sizeof(float);
float *c_q = (float*)c + q_off/sizeof(float); float *c_q = (float*)c + q_off / sizeof(float);
unsigned char *c_pargb = (unsigned char*)c + pargb_off; unsigned char *c_pargb = (unsigned char*)c + pargb_off;
float *c_s0 = (float*)c + st0_off/sizeof(float); float *c_s0 = (float*)c + st0_off / sizeof(float);
float *c_t0 = (float*)c + st0_off/sizeof(float) + 1; float *c_t0 = (float*)c + st0_off / sizeof(float) + 1;
float *c_s1 = (float*)c + st1_off/sizeof(float); float *c_s1 = (float*)c + st1_off / sizeof(float);
float *c_t1 = (float*)c + st1_off/sizeof(float) + 1; float *c_t1 = (float*)c + st1_off / sizeof(float) + 1;
float *c_fog = (float*)c + fog_ext_off/sizeof(float); float *c_fog = (float*)c + fog_ext_off / sizeof(float);
LOG("grDrawTriangle()\r\n"); LOG("grDrawTriangle()\r\n");
// ugly ? i know but nvidia drivers are losing the viewport otherwise // ugly ? i know but nvidia drivers are losing the viewport otherwise
if(nvidia_viewport_hack && !render_to_texture) if (nvidia_viewport_hack && !render_to_texture)
{ {
glViewport(0, viewport_offset, viewport_width, viewport_height); glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0; nvidia_viewport_hack = 0;
@ -359,7 +358,7 @@ grDrawTriangle( const void *a, const void *b, const void *c )
reloadTexture(); reloadTexture();
if(need_to_compile) compile_shader(); if (need_to_compile) compile_shader();
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);
@ -379,16 +378,16 @@ grDrawTriangle( const void *a, const void *b, const void *c )
ytex(0, *a_t0 / *a_q / (float)tex0_height)); ytex(0, *a_t0 / *a_q / (float)tex0_height));
} }
if (pargb_en) if (pargb_en)
glColor4f(a_pargb[2]/255.0f, a_pargb[1]/255.0f, a_pargb[0]/255.0f, a_pargb[3]/255.0f); glColor4f(a_pargb[2] / 255.0f, a_pargb[1] / 255.0f, a_pargb[0] / 255.0f, a_pargb[3] / 255.0f);
if (fog_enabled && fog_coord_support) if (fog_enabled && fog_coord_support)
{ {
if(!fog_ext_en || fog_enabled != 2) if (!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *a_q) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *a_q) / 255.0f, 0.0f, 0.0f);
else else
glSecondaryColor3f((1.0f / *a_fog) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *a_fog) / 255.0f, 0.0f, 0.0f);
} }
glVertex4f((*a_x - (float)widtho) / (float)(width/2) / *a_q, glVertex4f((*a_x - (float)widtho) / (float)(width / 2) / *a_q,
-(*a_y - (float)heighto) / (float)(height/2) / *a_q, ZCALC(*a_z, *a_q), 1.0f / *a_q); -(*a_y - (float)heighto) / (float)(height / 2) / *a_q, ZCALC(*a_z, *a_q), 1.0f / *a_q);
if (nbTextureUnits > 2) if (nbTextureUnits > 2)
{ {
@ -406,17 +405,17 @@ grDrawTriangle( const void *a, const void *b, const void *c )
ytex(0, *b_t0 / *b_q / (float)tex0_height)); ytex(0, *b_t0 / *b_q / (float)tex0_height));
} }
if (pargb_en) if (pargb_en)
glColor4f(b_pargb[2]/255.0f, b_pargb[1]/255.0f, b_pargb[0]/255.0f, b_pargb[3]/255.0f); glColor4f(b_pargb[2] / 255.0f, b_pargb[1] / 255.0f, b_pargb[0] / 255.0f, b_pargb[3] / 255.0f);
if (fog_enabled && fog_coord_support) if (fog_enabled && fog_coord_support)
{ {
if(!fog_ext_en || fog_enabled != 2) if (!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *b_q) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *b_q) / 255.0f, 0.0f, 0.0f);
else else
glSecondaryColor3f((1.0f / *b_fog) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *b_fog) / 255.0f, 0.0f, 0.0f);
} }
glVertex4f((*b_x - (float)widtho) / (float)(width/2) / *b_q, glVertex4f((*b_x - (float)widtho) / (float)(width / 2) / *b_q,
-(*b_y - (float)heighto) / (float)(height/2) / *b_q, ZCALC(*b_z, *b_q), 1.0f / *b_q); -(*b_y - (float)heighto) / (float)(height / 2) / *b_q, ZCALC(*b_z, *b_q), 1.0f / *b_q);
if (nbTextureUnits > 2) if (nbTextureUnits > 2)
{ {
@ -434,37 +433,37 @@ grDrawTriangle( const void *a, const void *b, const void *c )
ytex(0, *c_t0 / *c_q / (float)tex0_height)); ytex(0, *c_t0 / *c_q / (float)tex0_height));
} }
if (pargb_en) if (pargb_en)
glColor4f(c_pargb[2]/255.0f, c_pargb[1]/255.0f, c_pargb[0]/255.0f, c_pargb[3]/255.0f); glColor4f(c_pargb[2] / 255.0f, c_pargb[1] / 255.0f, c_pargb[0] / 255.0f, c_pargb[3] / 255.0f);
if (fog_enabled && fog_coord_support) if (fog_enabled && fog_coord_support)
{ {
if(!fog_ext_en || fog_enabled != 2) if (!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *c_q) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *c_q) / 255.0f, 0.0f, 0.0f);
else else
glSecondaryColor3f((1.0f / *c_fog) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *c_fog) / 255.0f, 0.0f, 0.0f);
} }
glVertex4f((*c_x - (float)widtho) / (float)(width/2) / *c_q, glVertex4f((*c_x - (float)widtho) / (float)(width / 2) / *c_q,
-(*c_y - (float)heighto) / (float)(height/2) / *c_q, ZCALC(*c_z ,*c_q), 1.0f / *c_q); -(*c_y - (float)heighto) / (float)(height / 2) / *c_q, ZCALC(*c_z, *c_q), 1.0f / *c_q);
glEnd(); glEnd();
grDisplayGLError("grDrawTriangle"); grDisplayGLError("grDrawTriangle");
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDrawPoint( const void *pt ) grDrawPoint(const void *pt)
{ {
float *x = (float*)pt + xy_off/sizeof(float); float *x = (float*)pt + xy_off / sizeof(float);
float *y = (float*)pt + xy_off/sizeof(float) + 1; float *y = (float*)pt + xy_off / sizeof(float) + 1;
float *z = (float*)pt + z_off/sizeof(float); float *z = (float*)pt + z_off / sizeof(float);
float *q = (float*)pt + q_off/sizeof(float); float *q = (float*)pt + q_off / sizeof(float);
unsigned char *pargb = (unsigned char*)pt + pargb_off; unsigned char *pargb = (unsigned char*)pt + pargb_off;
float *s0 = (float*)pt + st0_off/sizeof(float); float *s0 = (float*)pt + st0_off / sizeof(float);
float *t0 = (float*)pt + st0_off/sizeof(float) + 1; float *t0 = (float*)pt + st0_off / sizeof(float) + 1;
float *s1 = (float*)pt + st1_off/sizeof(float); float *s1 = (float*)pt + st1_off / sizeof(float);
float *t1 = (float*)pt + st1_off/sizeof(float) + 1; float *t1 = (float*)pt + st1_off / sizeof(float) + 1;
float *fog = (float*)pt + fog_ext_off/sizeof(float); float *fog = (float*)pt + fog_ext_off / sizeof(float);
LOG("grDrawPoint()\r\n"); LOG("grDrawPoint()\r\n");
if(nvidia_viewport_hack && !render_to_texture) if (nvidia_viewport_hack && !render_to_texture)
{ {
glViewport(0, viewport_offset, viewport_width, viewport_height); glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0; nvidia_viewport_hack = 0;
@ -472,7 +471,7 @@ grDrawPoint( const void *pt )
reloadTexture(); reloadTexture();
if(need_to_compile) compile_shader(); if (need_to_compile) compile_shader();
glBegin(GL_POINTS); glBegin(GL_POINTS);
@ -492,48 +491,48 @@ grDrawPoint( const void *pt )
ytex(0, *t0 / *q / (float)tex0_height)); ytex(0, *t0 / *q / (float)tex0_height));
} }
if (pargb_en) if (pargb_en)
glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f); glColor4f(pargb[2] / 255.0f, pargb[1] / 255.0f, pargb[0] / 255.0f, pargb[3] / 255.0f);
if (fog_enabled && fog_coord_support) if (fog_enabled && fog_coord_support)
{ {
if(!fog_ext_en || fog_enabled != 2) if (!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
else else
glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
} }
glVertex4f((*x - (float)widtho) / (float)(width/2) / *q, glVertex4f((*x - (float)widtho) / (float)(width / 2) / *q,
-(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z ,*q), 1.0f / *q); -(*y - (float)heighto) / (float)(height / 2) / *q, ZCALC(*z, *q), 1.0f / *q);
glEnd(); glEnd();
grDisplayGLError("grDrawPoint"); grDisplayGLError("grDrawPoint");
} }
FX_ENTRY void FX_CALL FX_ENTRY void FX_CALL
grDrawLine( const void *a, const void *b ) grDrawLine(const void *a, const void *b)
{ {
float *a_x = (float*)a + xy_off/sizeof(float); float *a_x = (float*)a + xy_off / sizeof(float);
float *a_y = (float*)a + xy_off/sizeof(float) + 1; float *a_y = (float*)a + xy_off / sizeof(float) + 1;
float *a_z = (float*)a + z_off/sizeof(float); float *a_z = (float*)a + z_off / sizeof(float);
float *a_q = (float*)a + q_off/sizeof(float); float *a_q = (float*)a + q_off / sizeof(float);
unsigned char *a_pargb = (unsigned char*)a + pargb_off; unsigned char *a_pargb = (unsigned char*)a + pargb_off;
float *a_s0 = (float*)a + st0_off/sizeof(float); float *a_s0 = (float*)a + st0_off / sizeof(float);
float *a_t0 = (float*)a + st0_off/sizeof(float) + 1; float *a_t0 = (float*)a + st0_off / sizeof(float) + 1;
float *a_s1 = (float*)a + st1_off/sizeof(float); float *a_s1 = (float*)a + st1_off / sizeof(float);
float *a_t1 = (float*)a + st1_off/sizeof(float) + 1; float *a_t1 = (float*)a + st1_off / sizeof(float) + 1;
float *a_fog = (float*)a + fog_ext_off/sizeof(float); float *a_fog = (float*)a + fog_ext_off / sizeof(float);
float *b_x = (float*)b + xy_off/sizeof(float); float *b_x = (float*)b + xy_off / sizeof(float);
float *b_y = (float*)b + xy_off/sizeof(float) + 1; float *b_y = (float*)b + xy_off / sizeof(float) + 1;
float *b_z = (float*)b + z_off/sizeof(float); float *b_z = (float*)b + z_off / sizeof(float);
float *b_q = (float*)b + q_off/sizeof(float); float *b_q = (float*)b + q_off / sizeof(float);
unsigned char *b_pargb = (unsigned char*)b + pargb_off; unsigned char *b_pargb = (unsigned char*)b + pargb_off;
float *b_s0 = (float*)b + st0_off/sizeof(float); float *b_s0 = (float*)b + st0_off / sizeof(float);
float *b_t0 = (float*)b + st0_off/sizeof(float) + 1; float *b_t0 = (float*)b + st0_off / sizeof(float) + 1;
float *b_s1 = (float*)b + st1_off/sizeof(float); float *b_s1 = (float*)b + st1_off / sizeof(float);
float *b_t1 = (float*)b + st1_off/sizeof(float) + 1; float *b_t1 = (float*)b + st1_off / sizeof(float) + 1;
float *b_fog = (float*)b + fog_ext_off/sizeof(float); float *b_fog = (float*)b + fog_ext_off / sizeof(float);
LOG("grDrawLine()\r\n"); LOG("grDrawLine()\r\n");
if(nvidia_viewport_hack && !render_to_texture) if (nvidia_viewport_hack && !render_to_texture)
{ {
glViewport(0, viewport_offset, viewport_width, viewport_height); glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0; nvidia_viewport_hack = 0;
@ -541,7 +540,7 @@ grDrawLine( const void *a, const void *b )
reloadTexture(); reloadTexture();
if(need_to_compile) compile_shader(); if (need_to_compile) compile_shader();
glBegin(GL_LINES); glBegin(GL_LINES);
@ -558,16 +557,16 @@ grDrawLine( const void *a, const void *b )
glTexCoord2f(*a_s0 / *a_q / (float)tex0_width, ytex(0, *a_t0 / *a_q / (float)tex0_height)); glTexCoord2f(*a_s0 / *a_q / (float)tex0_width, ytex(0, *a_t0 / *a_q / (float)tex0_height));
} }
if (pargb_en) if (pargb_en)
glColor4f(a_pargb[2]/255.0f, a_pargb[1]/255.0f, a_pargb[0]/255.0f, a_pargb[3]/255.0f); glColor4f(a_pargb[2] / 255.0f, a_pargb[1] / 255.0f, a_pargb[0] / 255.0f, a_pargb[3] / 255.0f);
if (fog_enabled && fog_coord_support) if (fog_enabled && fog_coord_support)
{ {
if(!fog_ext_en || fog_enabled != 2) if (!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *a_q) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *a_q) / 255.0f, 0.0f, 0.0f);
else else
glSecondaryColor3f((1.0f / *a_fog) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *a_fog) / 255.0f, 0.0f, 0.0f);
} }
glVertex4f((*a_x - (float)widtho) / (float)(width/2) / *a_q, glVertex4f((*a_x - (float)widtho) / (float)(width / 2) / *a_q,
-(*a_y - (float)heighto) / (float)(height/2) / *a_q, ZCALC(*a_z, *a_q), 1.0f / *a_q); -(*a_y - (float)heighto) / (float)(height / 2) / *a_q, ZCALC(*a_z, *a_q), 1.0f / *a_q);
if (nbTextureUnits > 2) if (nbTextureUnits > 2)
{ {
@ -585,16 +584,16 @@ grDrawLine( const void *a, const void *b )
ytex(0, *b_t0 / *b_q / (float)tex0_height)); ytex(0, *b_t0 / *b_q / (float)tex0_height));
} }
if (pargb_en) if (pargb_en)
glColor4f(b_pargb[2]/255.0f, b_pargb[1]/255.0f, b_pargb[0]/255.0f, b_pargb[3]/255.0f); glColor4f(b_pargb[2] / 255.0f, b_pargb[1] / 255.0f, b_pargb[0] / 255.0f, b_pargb[3] / 255.0f);
if (fog_enabled && fog_coord_support) if (fog_enabled && fog_coord_support)
{ {
if(!fog_ext_en || fog_enabled != 2) if (!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *b_q) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *b_q) / 255.0f, 0.0f, 0.0f);
else else
glSecondaryColor3f((1.0f / *b_fog) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *b_fog) / 255.0f, 0.0f, 0.0f);
} }
glVertex4f((*b_x - (float)widtho) / (float)(width/2) / *b_q, glVertex4f((*b_x - (float)widtho) / (float)(width / 2) / *b_q,
-(*b_y - (float)heighto) / (float)(height/2) / *b_q, ZCALC(*b_z, *b_q), 1.0f / *b_q); -(*b_y - (float)heighto) / (float)(height / 2) / *b_q, ZCALC(*b_z, *b_q), 1.0f / *b_q);
glEnd(); glEnd();
grDisplayGLError("grDrawLine"); grDisplayGLError("grDrawLine");
@ -609,7 +608,7 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
void **pointers = (void**)pointers2; void **pointers = (void**)pointers2;
LOG("grDrawVertexArray(%d,%d)\r\n", mode, Count); LOG("grDrawVertexArray(%d,%d)\r\n", mode, Count);
if(nvidia_viewport_hack && !render_to_texture) if (nvidia_viewport_hack && !render_to_texture)
{ {
glViewport(0, viewport_offset, viewport_width, viewport_height); glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0; nvidia_viewport_hack = 0;
@ -617,9 +616,9 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
reloadTexture(); reloadTexture();
if(need_to_compile) compile_shader(); if (need_to_compile) compile_shader();
switch(mode) switch (mode)
{ {
case GR_TRIANGLE_FAN: case GR_TRIANGLE_FAN:
glBegin(GL_TRIANGLE_FAN); glBegin(GL_TRIANGLE_FAN);
@ -628,18 +627,18 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
display_warning("grDrawVertexArray : unknown mode : %x", mode); display_warning("grDrawVertexArray : unknown mode : %x", mode);
} }
for (i=0; i<Count; i++) for (i = 0; i < Count; i++)
{ {
x = (float*)pointers[i] + xy_off/sizeof(float); x = (float*)pointers[i] + xy_off / sizeof(float);
y = (float*)pointers[i] + xy_off/sizeof(float) + 1; y = (float*)pointers[i] + xy_off / sizeof(float) + 1;
z = (float*)pointers[i] + z_off/sizeof(float); z = (float*)pointers[i] + z_off / sizeof(float);
q = (float*)pointers[i] + q_off/sizeof(float); q = (float*)pointers[i] + q_off / sizeof(float);
pargb = (unsigned char*)pointers[i] + pargb_off; pargb = (unsigned char*)pointers[i] + pargb_off;
s0 = (float*)pointers[i] + st0_off/sizeof(float); s0 = (float*)pointers[i] + st0_off / sizeof(float);
t0 = (float*)pointers[i] + st0_off/sizeof(float) + 1; t0 = (float*)pointers[i] + st0_off / sizeof(float) + 1;
s1 = (float*)pointers[i] + st1_off/sizeof(float); s1 = (float*)pointers[i] + st1_off / sizeof(float);
t1 = (float*)pointers[i] + st1_off/sizeof(float) + 1; t1 = (float*)pointers[i] + st1_off / sizeof(float) + 1;
fog = (float*)pointers[i] + fog_ext_off/sizeof(float); fog = (float*)pointers[i] + fog_ext_off / sizeof(float);
if (nbTextureUnits > 2) if (nbTextureUnits > 2)
{ {
@ -657,16 +656,16 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
ytex(0, *t0 / *q / (float)tex0_height)); ytex(0, *t0 / *q / (float)tex0_height));
} }
if (pargb_en) if (pargb_en)
glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f); glColor4f(pargb[2] / 255.0f, pargb[1] / 255.0f, pargb[0] / 255.0f, pargb[3] / 255.0f);
if (fog_enabled && fog_coord_support) if (fog_enabled && fog_coord_support)
{ {
if(!fog_ext_en || fog_enabled != 2) if (!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
else else
glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
} }
glVertex4f((*x - (float)widtho) / (float)(width/2) / *q, glVertex4f((*x - (float)widtho) / (float)(width / 2) / *q,
-(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z, *q), 1.0f / *q); -(*y - (float)heighto) / (float)(height / 2) / *q, ZCALC(*z, *q), 1.0f / *q);
} }
glEnd(); glEnd();
@ -681,7 +680,7 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid
unsigned char *pargb; unsigned char *pargb;
LOG("grDrawVertexArrayContiguous(%d,%d,%d)\r\n", mode, Count, stride); LOG("grDrawVertexArrayContiguous(%d,%d,%d)\r\n", mode, Count, stride);
if(nvidia_viewport_hack && !render_to_texture) if (nvidia_viewport_hack && !render_to_texture)
{ {
glViewport(0, viewport_offset, viewport_width, viewport_height); glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0; nvidia_viewport_hack = 0;
@ -689,9 +688,9 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid
reloadTexture(); reloadTexture();
if(need_to_compile) compile_shader(); if (need_to_compile) compile_shader();
switch(mode) switch (mode)
{ {
case GR_TRIANGLE_STRIP: case GR_TRIANGLE_STRIP:
glBegin(GL_TRIANGLE_STRIP); glBegin(GL_TRIANGLE_STRIP);
@ -703,18 +702,18 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid
display_warning("grDrawVertexArrayContiguous : unknown mode : %x", mode); display_warning("grDrawVertexArrayContiguous : unknown mode : %x", mode);
} }
for (i=0; i<Count; i++) for (i = 0; i < Count; i++)
{ {
x = (float*)((unsigned char*)pointers+stride*i) + xy_off/sizeof(float); x = (float*)((unsigned char*)pointers + stride*i) + xy_off / sizeof(float);
y = (float*)((unsigned char*)pointers+stride*i) + xy_off/sizeof(float) + 1; y = (float*)((unsigned char*)pointers + stride*i) + xy_off / sizeof(float) + 1;
z = (float*)((unsigned char*)pointers+stride*i) + z_off/sizeof(float); z = (float*)((unsigned char*)pointers + stride*i) + z_off / sizeof(float);
q = (float*)((unsigned char*)pointers+stride*i) + q_off/sizeof(float); q = (float*)((unsigned char*)pointers + stride*i) + q_off / sizeof(float);
pargb = (unsigned char*)pointers+stride*i + pargb_off; pargb = (unsigned char*)pointers + stride*i + pargb_off;
s0 = (float*)((unsigned char*)pointers+stride*i) + st0_off/sizeof(float); s0 = (float*)((unsigned char*)pointers + stride*i) + st0_off / sizeof(float);
t0 = (float*)((unsigned char*)pointers+stride*i) + st0_off/sizeof(float) + 1; t0 = (float*)((unsigned char*)pointers + stride*i) + st0_off / sizeof(float) + 1;
s1 = (float*)((unsigned char*)pointers+stride*i) + st1_off/sizeof(float); s1 = (float*)((unsigned char*)pointers + stride*i) + st1_off / sizeof(float);
t1 = (float*)((unsigned char*)pointers+stride*i) + st1_off/sizeof(float) + 1; t1 = (float*)((unsigned char*)pointers + stride*i) + st1_off / sizeof(float) + 1;
fog = (float*)((unsigned char*)pointers+stride*i) + fog_ext_off/sizeof(float); fog = (float*)((unsigned char*)pointers + stride*i) + fog_ext_off / sizeof(float);
//if(*fog == 0.0f) *fog = 1.0f; //if(*fog == 0.0f) *fog = 1.0f;
@ -734,17 +733,17 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid
ytex(0, *t0 / *q / (float)tex0_height)); ytex(0, *t0 / *q / (float)tex0_height));
} }
if (pargb_en) if (pargb_en)
glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f); glColor4f(pargb[2] / 255.0f, pargb[1] / 255.0f, pargb[0] / 255.0f, pargb[3] / 255.0f);
if (fog_enabled && fog_coord_support) if (fog_enabled && fog_coord_support)
{ {
if(!fog_ext_en || fog_enabled != 2) if (!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
else else
glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f); glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
} }
glVertex4f((*x - (float)widtho) / (float)(width/2) / *q, glVertex4f((*x - (float)widtho) / (float)(width / 2) / *q,
-(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z, *q), 1.0f / *q); -(*y - (float)heighto) / (float)(height / 2) / *q, ZCALC(*z, *q), 1.0f / *q);
} }
glEnd(); glEnd();