mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
OpenGL 1 errors are visible now
Needs DEBUG=1 to enable
This commit is contained in:
parent
e40f5d1480
commit
9f9c212648
4 changed files with 85 additions and 3 deletions
2
Makefile
2
Makefile
|
@ -144,7 +144,7 @@ endif
|
||||||
# Highest supported optimizations are -O2, higher levels
|
# Highest supported optimizations are -O2, higher levels
|
||||||
# will likely break this crappy code.
|
# will likely break this crappy code.
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
CFLAGS ?= -O0 -g -Wall -pipe
|
CFLAGS ?= -O0 -g -Wall -pipe -DDEBUG
|
||||||
ifdef ASAN
|
ifdef ASAN
|
||||||
override CFLAGS += -fsanitize=address -DUSE_SANITIZER
|
override CFLAGS += -fsanitize=address -DUSE_SANITIZER
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1405,6 +1405,10 @@ RI_Init(void)
|
||||||
R_Printf(PRINT_ALL, "Refresh: " REF_VERSION "\n");
|
R_Printf(PRINT_ALL, "Refresh: " REF_VERSION "\n");
|
||||||
R_Printf(PRINT_ALL, "Client: " YQ2VERSION "\n\n");
|
R_Printf(PRINT_ALL, "Client: " YQ2VERSION "\n\n");
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
R_Printf(PRINT_ALL, "ref_gl1::R_Init() - DEBUG mode enabled\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
GetPCXPalette (&colormap, d_8to24table);
|
GetPCXPalette (&colormap, d_8to24table);
|
||||||
free(colormap);
|
free(colormap);
|
||||||
|
|
||||||
|
@ -1981,3 +1985,32 @@ Com_Printf(const char *msg, ...)
|
||||||
ri.Com_VPrintf(PRINT_ALL, msg, argptr);
|
ri.Com_VPrintf(PRINT_ALL, msg, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
void
|
||||||
|
glCheckError_(const char *file, const char *function, int line)
|
||||||
|
{
|
||||||
|
GLenum errorCode;
|
||||||
|
const char * msg;
|
||||||
|
|
||||||
|
#define MY_ERROR_CASE(X) case X : msg = #X; break;
|
||||||
|
|
||||||
|
while ((errorCode = glGetError()) != GL_NO_ERROR)
|
||||||
|
{
|
||||||
|
switch(errorCode)
|
||||||
|
{
|
||||||
|
MY_ERROR_CASE(GL_INVALID_ENUM);
|
||||||
|
MY_ERROR_CASE(GL_INVALID_VALUE);
|
||||||
|
MY_ERROR_CASE(GL_INVALID_OPERATION);
|
||||||
|
MY_ERROR_CASE(GL_STACK_OVERFLOW);
|
||||||
|
MY_ERROR_CASE(GL_STACK_UNDERFLOW);
|
||||||
|
MY_ERROR_CASE(GL_OUT_OF_MEMORY);
|
||||||
|
default: msg = "UNKNOWN";
|
||||||
|
}
|
||||||
|
R_Printf(PRINT_ALL, "glError: %s in %s (%s, %d)\n", msg, function, file, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef MY_ERROR_CASE
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -303,6 +303,55 @@ void R_TextureAlphaMode(char *string);
|
||||||
void R_TextureSolidMode(char *string);
|
void R_TextureSolidMode(char *string);
|
||||||
int Scrap_AllocBlock(int w, int h, int *x, int *y);
|
int Scrap_AllocBlock(int w, int h, int *x, int *y);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
void glCheckError_(const char *file, const char *function, int line);
|
||||||
|
// Ideally, the following list should contain all OpenGL calls.
|
||||||
|
// Either way, errors are caught, since error flags are persisted until the next glGetError() call.
|
||||||
|
// So they show, even if the location of the error is inaccurate.
|
||||||
|
#define glDrawArrays(...) glDrawArrays(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glTexImage2D(...) glTexImage2D(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glTexSubImage2D(...) glTexSubImage2D(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glTexEnvf(...) glTexEnvf(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glTexEnvi(...) glTexEnvi(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glVertexPointer(...) glVertexPointer(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glTexCoordPointer(...) glTexCoordPointer(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glColorPointer(...) glColorPointer(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glTexParameteri(...) glTexParameteri(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glBindTexture(...) glBindTexture(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glFrustum(...) glFrustum(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glTranslatef(...) glTranslatef(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glRotatef(...) glRotatef(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glScalef(...) glScalef(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glScissor(...) glScissor(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glBlendFunc(...) glBlendFunc(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glDepthFunc(...) glDepthFunc(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glDepthMask(...) glDepthMask(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glDepthRange(...) glDepthRange(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glEnable(...) glEnable(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glDisable(...) glDisable(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glEnableClientState(...) glEnableClientState(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glDisableClientState(...) glDisableClientState(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glPushMatrix(...) glPushMatrix(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glPopMatrix(...) glPopMatrix(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glMatrixMode(...) glMatrixMode(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glOrtho(...) glOrtho(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glColorMask(...) glColorMask(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glStencilOp(...) glStencilOp(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glStencilFunc(...) glStencilFunc(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glDrawBuffer(...) glDrawBuffer(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glReadPixels(...) glReadPixels(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glClear(...) glClear(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glClearColor(...) glClearColor(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glClearStencil(...) glClearStencil(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glDeleteTextures(...) glDeleteTextures(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glFinish() glFinish(); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glAlphaFunc(...) glAlphaFunc(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glHint(...) glHint(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glLoadIdentity() glLoadIdentity(); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glBegin(...) glBegin(__VA_ARGS__); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#define glEnd() glEnd(); glCheckError_(__FILE__, __func__, __LINE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* GL extension emulation functions */
|
/* GL extension emulation functions */
|
||||||
void R_DrawParticles2(int n,
|
void R_DrawParticles2(int n,
|
||||||
const particle_t particles[],
|
const particle_t particles[],
|
||||||
|
|
Loading…
Reference in a new issue