More warnings fixes by riccardom (patch 2157019)

This patch also protects the DebugDumpTexture
with DEBUG_DUMP_TEXTURE preprocessor define.
(btw, there's much chance that function won't
works on non windows platforms...)
This commit is contained in:
yabause 2008-10-17 09:55:15 +00:00
parent 81bbf061c4
commit c26ff21787
1 changed files with 28 additions and 31 deletions

View File

@ -31,17 +31,19 @@
#include <assert.h> #include <assert.h>
#include "debug.h" #include "debug.h"
//#define DEBUG_DUMP_TEXTURE
bool (*oglrender_init)() = 0; bool (*oglrender_init)() = 0;
bool (*oglrender_beginOpenGL)() = 0; bool (*oglrender_beginOpenGL)() = 0;
void (*oglrender_endOpenGL)() = 0; void (*oglrender_endOpenGL)() = 0;
bool BEGINGL() { static bool BEGINGL() {
if(oglrender_beginOpenGL) if(oglrender_beginOpenGL)
return oglrender_beginOpenGL(); return oglrender_beginOpenGL();
else return true; else return true;
} }
void ENDGL() { static void ENDGL() {
if(oglrender_endOpenGL) if(oglrender_endOpenGL)
oglrender_endOpenGL(); oglrender_endOpenGL();
} }
@ -129,13 +131,13 @@ OGLEXT(PFNGLBLENDFUNCSEPARATEEXTPROC,glBlendFuncSeparateEXT)
//every function that is xgl* can be replaced with gl* if we decide to rip this out or if anyone else //every function that is xgl* can be replaced with gl* if we decide to rip this out or if anyone else
//doesnt feel like sticking with it (or if it causes trouble) //doesnt feel like sticking with it (or if it causes trouble)
void xglDepthFunc(GLenum func) { static void xglDepthFunc(GLenum func) {
static GLenum oldfunc = -1; static GLenum oldfunc = -1;
if(oldfunc == func) return; if(oldfunc == func) return;
glDepthFunc(oldfunc=func); glDepthFunc(oldfunc=func);
} }
void xglPolygonMode(GLenum face,GLenum mode) { static void xglPolygonMode(GLenum face,GLenum mode) {
static GLenum oldmodes[2] = {-1,-1}; static GLenum oldmodes[2] = {-1,-1};
switch(face) { switch(face) {
case GL_FRONT: if(oldmodes[0]==mode) return; else glPolygonMode(GL_FRONT,oldmodes[0]=mode); return; case GL_FRONT: if(oldmodes[0]==mode) return; else glPolygonMode(GL_FRONT,oldmodes[0]=mode); return;
@ -144,19 +146,23 @@ void xglPolygonMode(GLenum face,GLenum mode) {
} }
} }
void xglUseProgram(GLuint program) {
#ifdef _WIN32 #ifdef _WIN32
static void xglUseProgram(GLuint program) {
if(!glUseProgram) return; if(!glUseProgram) return;
static GLuint oldprogram = -1; static GLuint oldprogram = -1;
if(oldprogram==program) return; if(oldprogram==program) return;
glUseProgram(oldprogram=program); glUseProgram(oldprogram=program);
}
#else #else
#if 0 /* not used */
static void xglUseProgram(GLuint program) {
(void)program; (void)program;
return; return;
#endif
} }
#endif
#endif
void xglDepthMask (GLboolean flag) { static void xglDepthMask (GLboolean flag) {
static GLboolean oldflag = -1; static GLboolean oldflag = -1;
if(oldflag==flag) return; if(oldflag==flag) return;
glDepthMask(oldflag=flag); glDepthMask(oldflag=flag);
@ -170,7 +176,7 @@ struct GLCaps {
}; };
static GLCaps glcaps; static GLCaps glcaps;
void _xglEnable(GLenum cap) { static void _xglEnable(GLenum cap) {
cap -= 0x0B00; cap -= 0x0B00;
if(glcaps.caps[cap] == 0xFF || glcaps.caps[cap] == 0) { if(glcaps.caps[cap] == 0xFF || glcaps.caps[cap] == 0) {
glEnable(cap+0x0B00); glEnable(cap+0x0B00);
@ -178,7 +184,7 @@ void _xglEnable(GLenum cap) {
} }
} }
void _xglDisable(GLenum cap) { static void _xglDisable(GLenum cap) {
cap -= 0x0B00; cap -= 0x0B00;
if(glcaps.caps[cap]) { if(glcaps.caps[cap]) {
glDisable(cap+0x0B00); glDisable(cap+0x0B00);
@ -345,21 +351,10 @@ static char Init(void)
return 1; return 1;
} }
void Close() static void Close()
{ {
} }
//zero 8/25/08 - i dont like this
//#define CHECKSLOT txt_slot_current_size--;\
// if (txt_slot_current_size<=0)\
// {\
// txt_slot_current++;\
// *adr=(unsigned char *)ARM9Mem.textureSlotAddr[txt_slot_current];\
// adr-=txt_slot_size;\
// txt_slot_size=txt_slot_current_size=0x020000;\
// }
//zero 9/7/08 - changed *adr= to adr= while changing from c++. was that a bug? //zero 9/7/08 - changed *adr= to adr= while changing from c++. was that a bug?
#define CHECKSLOT txt_slot_current_size--;\ #define CHECKSLOT txt_slot_current_size--;\
if (txt_slot_current_size<=0)\ if (txt_slot_current_size<=0)\
@ -444,10 +439,11 @@ void* memcpy_fast(void* dest, const void* src, size_t count)
#define memcpy_fast(d,s,c) memcpy(d,s,c) #define memcpy_fast(d,s,c) memcpy(d,s,c)
#endif #endif
#ifdef DEBUG_DUMP_TEXTURE
static void DebugDumpTexture(int which) static void DebugDumpTexture(int which)
{ {
char fname[100]; char fname[100];
FILE* outf;
sprintf(fname,"c:\\dump\\%d.bmp", which); sprintf(fname,"c:\\dump\\%d.bmp", which);
glBindTexture(GL_TEXTURE_2D,texcache[which].id); glBindTexture(GL_TEXTURE_2D,texcache[which].id);
@ -459,14 +455,16 @@ static void DebugDumpTexture(int which)
NDS_WriteBMP_32bppBuffer(texcache[which].sizeX,texcache[which].sizeY,texMAP,fname); NDS_WriteBMP_32bppBuffer(texcache[which].sizeX,texcache[which].sizeY,texMAP,fname);
} }
#else
#define DebugDumpTexture(which) do { (void)which; } while (0)
#endif
//================================================================================ //================================================================================
static int lastTexture = -1; static int lastTexture = -1;
void setTexture(unsigned int format, unsigned int texpal) static void setTexture(unsigned int format, unsigned int texpal)
{ {
int palSize[7]={32,4,16,256,0,8,32768}; int palSize[7]={32,4,16,256,0,8,32768};
int i=0; unsigned int x=0, y=0, i;
unsigned int x=0, y=0;
unsigned int palZeroTransparent; unsigned int palZeroTransparent;
u16 *pal = NULL; u16 *pal = NULL;
@ -512,7 +510,7 @@ void setTexture(unsigned int format, unsigned int texpal)
{ {
texcache[i].suspectedInvalid = false; texcache[i].suspectedInvalid = false;
texcache_count=i; texcache_count=i;
if(i != lastTexture) if(lastTexture == -1 || (int)i != lastTexture)
{ {
lastTexture = i; lastTexture = i;
glBindTexture(GL_TEXTURE_2D,texcache[i].id); glBindTexture(GL_TEXTURE_2D,texcache[i].id);
@ -798,7 +796,7 @@ void setTexture(unsigned int format, unsigned int texpal)
texcache[i].sizeX, texcache[i].sizeY, 0, texcache[i].sizeX, texcache[i].sizeY, 0,
GL_RGBA, GL_UNSIGNED_BYTE, texMAP); GL_RGBA, GL_UNSIGNED_BYTE, texMAP);
//DebugDumpTexture(i); DebugDumpTexture(i);
//============================================================================================ //============================================================================================
@ -821,7 +819,6 @@ static u32 stencilStateSet = -1;
static void BeginRenderPoly() static void BeginRenderPoly()
{ {
bool enableDepthWrite = true; bool enableDepthWrite = true;
u32 tmp=0;
xglDepthFunc (depthFuncMode); xglDepthFunc (depthFuncMode);
@ -1032,7 +1029,7 @@ static void VramReconfigureSignal()
texcache[i].suspectedInvalid = true; texcache[i].suspectedInvalid = true;
} }
void GL_ReadFramebuffer() static void GL_ReadFramebuffer()
{ {
if(!BEGINGL()) return; if(!BEGINGL()) return;
glFinish(); glFinish();