fix some things that I had left broken in the 3d engine

This commit is contained in:
zeromus 2008-09-14 22:13:11 +00:00
parent 313ac48708
commit e44fd0eac9
3 changed files with 46 additions and 33 deletions

View File

@ -77,19 +77,13 @@ static ALIGN(16) unsigned char GPU_screenStencil[256*256]={0};
static const unsigned short map3d_cull[4] = {GL_FRONT_AND_BACK, GL_FRONT, GL_BACK, 0};
static const int texEnv[4] = { GL_MODULATE, GL_DECAL, GL_MODULATE, GL_MODULATE };
static const int depthFunc[2] = { GL_LESS, GL_EQUAL };
static bool needRefreshFramebuffer = false;
static unsigned short matrixMode[2] = {GL_PROJECTION, GL_MODELVIEW};
static unsigned char texMAP[1024*2048*4];
static unsigned int textureMode=0;
float clearAlpha;
//raw ds format poly attributes, installed from the display list
static u32 polyAttr=0,textureFormat=0, texturePalette=0;
@ -341,9 +335,9 @@ static char Init(void)
#ifdef _WIN32
if(!glBlendFuncSeparateEXT)
#endif
glClearColor(0, 0, 0, 1);
clearAlpha = 1;
#ifdef _WIN32
else glClearColor(0, 0, 0, 0);
else clearAlpha = 0;
#endif
ENDGL();
@ -958,8 +952,17 @@ static void Render()
Control();
xglDepthMask (GL_TRUE);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx3d.rgbToonTable);
xglDepthMask(GL_TRUE);
glViewport(gfx3d.viewport.x,gfx3d.viewport.y,gfx3d.viewport.width,gfx3d.viewport.height);
//we're not using the alpha clear color right now
glClearColor(gfx3d.clearColor[0],gfx3d.clearColor[1],gfx3d.clearColor[2], clearAlpha);
glClearDepth(gfx3d.clearDepth);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
//render display list
//TODO - properly doublebuffer the display lists

View File

@ -213,18 +213,19 @@ void gfx3d_reset()
void gfx3d_glViewPort(unsigned long v)
{
//zero: NHerve messed with this in mod2 and mod3, but im still not sure its perfect. need to research this.
//glViewport( (v&0xFF), ((v>>8)&0xFF), (((v>>16)&0xFF)+1)-(v&0xFF), ((v>>24)+1)-((v>>8)&0xFF));
//TODO
gfx3d.viewport.x = (v&0xFF);
gfx3d.viewport.y = (v&0xFF);
gfx3d.viewport.width = (((v>>16)&0xFF)+1)-(v&0xFF);
gfx3d.viewport.height = ((v>>24)+1)-((v>>8)&0xFF);
}
void gfx3d_glClearColor(unsigned long v)
{
//glClearColor( ((float)(v&0x1F))/31.0f,
// ((float)((v>>5)&0x1F))/31.0f,
// ((float)((v>>10)&0x1F))/31.0f,
// ((float)((v>>16)&0x1F))/31.0f);
//TODO
gfx3d.clearColor[0] = ((float)(v&0x1F))/31.0f;
gfx3d.clearColor[1] = ((float)((v>>5)&0x1F))/31.0f;
gfx3d.clearColor[2] = ((float)((v>>10)&0x1F))/31.0f;
gfx3d.clearColor[3] = ((float)((v>>16)&0x1F))/31.0f;
}
void gfx3d_glFogColor(unsigned long v)
@ -242,15 +243,13 @@ void gfx3d_glFogOffset (unsigned long v)
void gfx3d_glClearDepth(unsigned long v)
{
//u32 depth24b;
u32 depth24b;
//v &= 0x7FFFF;
//
//// Thanks for NHerve
//depth24b = (v*0x200)+((v+1)/0x8000)*0x01FF;
//glClearDepth(depth24b / ((float)(1<<24)));
//TODO
v &= 0x7FFFF;
//Thanks to NHerve
depth24b = (v*0x200)+((v+1)/0x8000)*0x01FF;
gfx3d.clearDepth = depth24b / ((float)(1<<24));
}
void gfx3d_glMatrixMode(unsigned long v)
@ -741,13 +740,9 @@ void gfx3d_glShininess (unsigned long val)
void gfx3d_UpdateToonTable(void* toonTable)
{
u16* u16toonTable = (u16*)toonTable;
u32 rgbToonTable[32];
int i;
for(i=0;i<32;i++)
rgbToonTable[i] = RGB15TO32(u16toonTable[i],255);
//glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbToonTable);
//TODO
gfx3d.rgbToonTable[i] = RGB15TO32(u16toonTable[i],255);
}

View File

@ -81,7 +81,10 @@ struct GFX3D
, polylist(0)
, vertlist(0)
, alphaTestRef(0)
{}
, clearDepth(1)
{
clearColor[0] = clearColor[1] = clearColor[2] = clearColor[3] = 0;
}
bool enableTexturing, enableAlphaTest, enableAlphaBlending, enableAntialiasing, enableEdgeMarking;
enum {
@ -95,6 +98,18 @@ struct GFX3D
bool wbuffer, sortmode;
float alphaTestRef;
struct VIEWPORT {
VIEWPORT()
: x(0), y(0), width(256), height(256)
{}
int x, y, width, height;
} viewport;
float clearColor[4];
float clearDepth;
u32 rgbToonTable[32];
};
extern GFX3D gfx3d;