make up for the lack of ogllog.txt

This commit is contained in:
Jaime Passos 2020-01-25 22:17:39 -03:00
parent 8bcdd105ce
commit e576c1ada1

View file

@ -157,6 +157,56 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...)
#endif
}
// -----------------+
// GL_MSG_Warning : Raises a warning.
// :
// Returns :
// -----------------+
static void GL_MSG_Warning(const char *format, ...)
{
char str[4096] = "";
va_list arglist;
va_start(arglist, format);
vsnprintf(str, 4096, format, arglist);
va_end(arglist);
#ifdef HAVE_SDL
CONS_Alert(CONS_WARNING, "%s", str);
#endif
#ifdef DEBUG_TO_FILE
if (!gllogstream)
gllogstream = fopen("ogllog.txt", "w");
fwrite(str, strlen(str), 1, gllogstream);
#endif
}
// -----------------+
// GL_MSG_Error : Raises an error.
// :
// Returns :
// -----------------+
static void GL_MSG_Error(const char *format, ...)
{
char str[4096] = "";
va_list arglist;
va_start(arglist, format);
vsnprintf(str, 4096, format, arglist);
va_end(arglist);
#ifdef HAVE_SDL
CONS_Alert(CONS_ERROR, "%s", str);
#endif
#ifdef DEBUG_TO_FILE
if (!gllogstream)
gllogstream = fopen("ogllog.txt", "w");
fwrite(str, strlen(str), 1, gllogstream);
#endif
}
#ifdef STATIC_OPENGL
/* 1.0 functions */
/* Miscellaneous */
@ -413,7 +463,7 @@ boolean SetupGLfunc(void)
func = GetGLFunc(#proc); \
if (!func) \
{ \
GL_DBG_Printf("failed to get OpenGL function: %s", #proc); \
GL_MSG_Warning("failed to get OpenGL function: %s", #proc); \
} \
GETOPENGLFUNC(pglClearColor, glClearColor)
@ -858,7 +908,7 @@ EXPORT void HWRAPI(LoadShaders) (void)
gl_vertShader = pglCreateShader(GL_VERTEX_SHADER);
if (!gl_vertShader)
{
GL_DBG_Printf("LoadShaders: Error creating vertex shader %d", i);
GL_MSG_Error("LoadShaders: Error creating vertex shader %d\n", i);
continue;
}
@ -877,7 +927,7 @@ EXPORT void HWRAPI(LoadShaders) (void)
infoLog = malloc(logLength);
pglGetShaderInfoLog(gl_vertShader, logLength, NULL, infoLog);
GL_DBG_Printf("LoadShaders: Error compiling vertex shader %d\n%s", i, infoLog);
GL_MSG_Error("LoadShaders: Error compiling vertex shader %d\n%s", i, infoLog);
continue;
}
@ -887,7 +937,7 @@ EXPORT void HWRAPI(LoadShaders) (void)
gl_fragShader = pglCreateShader(GL_FRAGMENT_SHADER);
if (!gl_fragShader)
{
GL_DBG_Printf("LoadShaders: Error creating fragment shader %d", i);
GL_MSG_Error("LoadShaders: Error creating fragment shader %d\n", i);
continue;
}
@ -906,7 +956,7 @@ EXPORT void HWRAPI(LoadShaders) (void)
infoLog = malloc(logLength);
pglGetShaderInfoLog(gl_fragShader, logLength, NULL, infoLog);
GL_DBG_Printf("LoadShaders: Error compiling fragment shader %d\n%s", i, infoLog);
GL_MSG_Error("LoadShaders: Error compiling fragment shader %d\n%s", i, infoLog);
continue;
}
@ -927,7 +977,7 @@ EXPORT void HWRAPI(LoadShaders) (void)
{
shader->program = 0;
shader->custom = false;
GL_DBG_Printf("LoadShaders: Error linking shader program %d", i);
GL_MSG_Error("LoadShaders: Error linking shader program %d\n", i);
continue;
}
@ -1709,7 +1759,7 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
}
}
else
GL_DBG_Printf ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
GL_MSG_Warning ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
// the texture number was already generated by pglGenTextures
pglBindTexture(GL_TEXTURE_2D, texnum);