Skip to content

Commit 507f50c

Browse files
committed
Fix OpenGL errors when framebuffer effects are disabled
This also promotes medium and high severity OpenGL messages to the general logging category to help troubleshooting in the future.
1 parent bb94d5b commit 507f50c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

code/graphics/opengl/gropengl.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,12 +1349,15 @@ static void APIENTRY debug_callback(GLenum source, GLenum type, GLuint id, GLenu
13491349
break;
13501350
}
13511351

1352+
bool print_to_general_log = false;
13521353
switch(severity) {
13531354
case GL_DEBUG_SEVERITY_HIGH_ARB:
13541355
severityStr = "High";
1356+
print_to_general_log = true; // High and medium messages are sent to the normal log for later troubleshooting
13551357
break;
13561358
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
13571359
severityStr = "Medium";
1360+
print_to_general_log = true;
13581361
break;
13591362
case GL_DEBUG_SEVERITY_LOW_ARB:
13601363
severityStr = "Low";
@@ -1364,8 +1367,14 @@ static void APIENTRY debug_callback(GLenum source, GLenum type, GLuint id, GLenu
13641367
break;
13651368
}
13661369

1367-
nprintf(("OpenGL Debug", "OpenGL Debug: Source:%s\tType:%s\tID:%d\tSeverity:%s\tMessage:%s\n",
1368-
sourceStr, typeStr, id, severityStr, message));
1370+
if (print_to_general_log) {
1371+
mprintf(("OpenGL Debug: Source:%s\tType:%s\tID:%d\tSeverity:%s\tMessage:%s\n",
1372+
sourceStr, typeStr, id, severityStr, message));
1373+
} else {
1374+
// We still print these messages but only to the special debug stream
1375+
nprintf(("OpenGL Debug", "OpenGL Debug: Source:%s\tType:%s\tID:%d\tSeverity:%s\tMessage:%s\n",
1376+
sourceStr, typeStr, id, severityStr, message));
1377+
}
13691378
printf("OpenGL Debug: Source:%s\tType:%s\tID:%d\tSeverity:%s\tMessage:%s\n",
13701379
sourceStr, typeStr, id, severityStr, message);
13711380
}

code/graphics/opengl/gropengldraw.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ GLuint Scene_depth_texture;
107107
GLuint Cockpit_depth_texture;
108108
GLuint Scene_stencil_buffer;
109109

110-
GLuint Distortion_framebuffer;
110+
GLuint Distortion_framebuffer = 0;
111111
GLuint Distortion_texture[2];
112112
int Distortion_switch = 0;
113113

@@ -2272,6 +2272,11 @@ void gr_opengl_render_shield_impact(shield_material *material_info, primitive_ty
22722272

22732273
void gr_opengl_update_distortion()
22742274
{
2275+
if (Distortion_framebuffer == 0) {
2276+
// distortion is disabled
2277+
return;
2278+
}
2279+
22752280
GR_DEBUG_SCOPE("Update distortion");
22762281
TRACE_SCOPE(tracing::UpdateDistortion);
22772282

0 commit comments

Comments
 (0)