Merge pull request #186 from cxd4/so_i_herd_u_liek_OpenGL
Include more debugging in PJGlide64 for the OpenGL side of it.
This commit is contained in:
commit
f5b58e17a1
|
@ -41,6 +41,15 @@
|
|||
#include "Util.h"
|
||||
#include "Debugger.h"
|
||||
|
||||
/*
|
||||
* required to include OpenGL library without errors
|
||||
* Dependency on OpenGL in this module is limited to just `glGetError`.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
|
||||
GLIDE64_DEBUGGER _debugger;
|
||||
|
||||
#define SX(x) ((x)*rdp.scale_1024)
|
||||
|
@ -1018,3 +1027,52 @@ void output (float x, float y, int scale, const char *fmt, ...)
|
|||
x+=8;
|
||||
}
|
||||
}
|
||||
|
||||
static const char * GL_errors[7 + 1] = {
|
||||
"GL_NO_ERROR", /* "There is no current error." */
|
||||
"GL_INVALID_ENUM", /* "Invalid parameter." */
|
||||
"GL_INVALID_VALUE", /* "Invalid enum parameter value." */
|
||||
"GL_INVALID_OPERATION", /* "Illegal call." */
|
||||
"GL_STACK_OVERFLOW",
|
||||
"GL_STACK_UNDERFLOW",
|
||||
"GL_OUT_OF_MEMORY", /* "Unable to allocate memory." */
|
||||
|
||||
"GL_UNKNOWN_ERROR" /* ??? */
|
||||
};
|
||||
|
||||
int grDisplayGLError(const char* message)
|
||||
{
|
||||
GLenum status;
|
||||
unsigned int error_index;
|
||||
int failure;
|
||||
|
||||
status = glGetError();
|
||||
failure = 1;
|
||||
|
||||
if (status == GL_NO_ERROR)
|
||||
error_index = failure = 0;
|
||||
else
|
||||
error_index =
|
||||
(status < GL_INVALID_ENUM) /* to avoid underflow when subtracting */
|
||||
? ( 7 ) /* our own, made-up "GL_UNKNOWN_ERROR" error */
|
||||
: (status - GL_INVALID_ENUM) + 1;
|
||||
|
||||
if (error_index > 7)
|
||||
error_index = 7;
|
||||
|
||||
#if !0
|
||||
/*
|
||||
* In most cases, we don't want to spam the screen to repeatedly say that
|
||||
* there were no OpenGL errors yet, though sometimes one may need verbosity.
|
||||
*/
|
||||
if (failure == 0)
|
||||
return (failure);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
MessageBoxA(NULL, message, GL_errors[error_index], MB_ICONERROR);
|
||||
#else
|
||||
fprintf(stderr, "%s\n%s\n\n", GL_errors[error_index], message);
|
||||
#endif
|
||||
return (failure);
|
||||
}
|
||||
|
|
|
@ -135,3 +135,5 @@ void debug_cacheviewer ();
|
|||
void debug_mouse ();
|
||||
void debug_keys ();
|
||||
void output (float x, float y, int scale, const char *fmt, ...);
|
||||
|
||||
extern int grDisplayGLError( const char * message );
|
||||
|
|
|
@ -1890,6 +1890,10 @@ void CALL UpdateScreen (void)
|
|||
if (fullscreen && (*gfx.VI_ORIGIN_REG > width))
|
||||
update_screen_count++;
|
||||
|
||||
#if defined(_DEBUG) || 0
|
||||
grDisplayGLError("UpdateScreen");
|
||||
#endif
|
||||
|
||||
#ifdef FPS
|
||||
// vertical interrupt has occurred, increment counter
|
||||
vi_count ++;
|
||||
|
|
|
@ -2115,6 +2115,10 @@ grBufferSwap( FxU32 swap_interval )
|
|||
for (i = 0; i < nb_fb; i++)
|
||||
fbs[i].buff_clear = 1;
|
||||
|
||||
#ifdef _DEBUG
|
||||
grFinish();
|
||||
#endif
|
||||
|
||||
// VP debugging
|
||||
#ifdef VPDEBUG
|
||||
dump_stop();
|
||||
|
@ -2572,13 +2576,13 @@ grErrorSetCallback( GrErrorCallbackFnc_t /*fnc*/ )
|
|||
FX_ENTRY void FX_CALL
|
||||
grFinish(void)
|
||||
{
|
||||
display_warning("grFinish");
|
||||
glFinish();
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
grFlush(void)
|
||||
{
|
||||
display_warning("grFlush");
|
||||
glFlush();
|
||||
}
|
||||
|
||||
FX_ENTRY void FX_CALL
|
||||
|
|
Loading…
Reference in New Issue