Skip to content

Commit ca1a844

Browse files
committed
Remove GL_version checks that are always true
Same as the GLSL version checks, these conditions were always true since we only support OpenGL 3.2 now. There was also an assertion condition that didn't make sense so I fixed that.
1 parent 833df59 commit ca1a844

File tree

4 files changed

+19
-37
lines changed

4 files changed

+19
-37
lines changed

code/graphics/opengl/gropengl.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,8 @@ void gr_opengl_shutdown()
406406

407407
GL_initted = false;
408408

409-
if ( GL_version >= 30 ) {
410-
glDeleteVertexArrays(1, &GL_vao);
411-
GL_vao = 0;
412-
}
409+
glDeleteVertexArrays(1, &GL_vao);
410+
GL_vao = 0;
413411

414412
if (GL_original_gamma_ramp != NULL && os::getSDLMainWindow() != nullptr) {
415413
SDL_SetWindowGammaRamp( os::getSDLMainWindow(), GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
@@ -1536,11 +1534,9 @@ bool gr_opengl_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps)
15361534
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units);
15371535
max_texture_coords = 1;
15381536

1539-
// create vertex array object to make OpenGL Core happy if we can
1540-
if ( GL_version >= 30 ) {
1541-
glGenVertexArrays(1, &GL_vao);
1542-
glBindVertexArray(GL_vao);
1543-
}
1537+
// create vertex array object to make OpenGL Core happy
1538+
glGenVertexArrays(1, &GL_vao);
1539+
glBindVertexArray(GL_vao);
15441540

15451541
GL_state.Texture.init(max_texture_units);
15461542
GL_state.Array.init(max_texture_coords);
@@ -1626,10 +1622,6 @@ bool gr_opengl_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps)
16261622

16271623
bool gr_opengl_is_capable(gr_capability capability)
16281624
{
1629-
if ( GL_version < 20 ) {
1630-
return false;
1631-
}
1632-
16331625
switch ( capability ) {
16341626
case CAPABILITY_ENVIRONMENT_MAP:
16351627
return true;
@@ -1645,11 +1637,11 @@ bool gr_opengl_is_capable(gr_capability capability)
16451637
case CAPABILITY_DEFERRED_LIGHTING:
16461638
return !Cmdline_no_fbo && !Cmdline_no_deferred_lighting;
16471639
case CAPABILITY_SHADOWS:
1648-
return GL_version >= 32;
1640+
return true;
16491641
case CAPABILITY_BATCHED_SUBMODELS:
16501642
return true;
16511643
case CAPABILITY_POINT_PARTICLES:
1652-
return GL_version >= 32 && !Cmdline_no_geo_sdr_effects;
1644+
return true && !Cmdline_no_geo_sdr_effects;
16531645
case CAPABILITY_TIMESTAMP_QUERY:
16541646
return GL_version >= 33; // Timestamp queries are available from 3.3 onwards
16551647
}

code/graphics/opengl/gropenglshader.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -601,13 +601,11 @@ int opengl_compile_shader(shader_type sdr, uint flags)
601601
opengl_shader_set_current(&new_shader);
602602

603603
// bind fragment data locations
604-
if ( GL_version >= 32 ) {
605-
glBindFragDataLocation(new_shader.program->getShaderHandle(), 0, "fragOut0");
606-
glBindFragDataLocation(new_shader.program->getShaderHandle(), 1, "fragOut1");
607-
glBindFragDataLocation(new_shader.program->getShaderHandle(), 2, "fragOut2");
608-
glBindFragDataLocation(new_shader.program->getShaderHandle(), 3, "fragOut3");
609-
glBindFragDataLocation(new_shader.program->getShaderHandle(), 4, "fragOut4");
610-
}
604+
glBindFragDataLocation(new_shader.program->getShaderHandle(), 0, "fragOut0");
605+
glBindFragDataLocation(new_shader.program->getShaderHandle(), 1, "fragOut1");
606+
glBindFragDataLocation(new_shader.program->getShaderHandle(), 2, "fragOut2");
607+
glBindFragDataLocation(new_shader.program->getShaderHandle(), 3, "fragOut3");
608+
glBindFragDataLocation(new_shader.program->getShaderHandle(), 4, "fragOut4");
611609

612610
// initialize uniforms and attributes
613611
for (auto& unif : sdr_info->uniforms) {

code/graphics/opengl/gropenglstate.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,9 @@ void opengl_state::init()
153153
clipplane_Status[i] = GL_FALSE;
154154
}
155155

156-
if (GL_version >= 30) {
157-
for (i = 0; i < (int)(sizeof(clipdistance_Status) / sizeof(GLboolean)); i++) {
158-
//glDisable(GL_CLIP_DISTANCE0+i);
159-
clipdistance_Status[i] = GL_FALSE;
160-
}
156+
for (i = 0; i < (int)(sizeof(clipdistance_Status) / sizeof(GLboolean)); i++) {
157+
//glDisable(GL_CLIP_DISTANCE0+i);
158+
clipdistance_Status[i] = GL_FALSE;
161159
}
162160

163161
glDepthMask(GL_FALSE);
@@ -334,7 +332,7 @@ GLboolean opengl_state::ClipPlane(GLint num, GLint state)
334332

335333
GLboolean opengl_state::ClipDistance(GLint num, GLint state)
336334
{
337-
Assert( (num >= 0) || (num < (int)(sizeof(clipdistance_Status) / sizeof(GLboolean))) || GL_version >= 30 );
335+
Assert( (num >= 0) && (num < (int)(sizeof(clipdistance_Status) / sizeof(GLboolean))) );
338336

339337
GLboolean save_state = clipdistance_Status[num];
340338

@@ -700,9 +698,7 @@ void opengl_array_state::BindUniformBuffer(GLuint id)
700698

701699
void gr_opengl_clear_states()
702700
{
703-
if ( GL_version >= 30 ) {
704-
glBindVertexArray(GL_vao);
705-
}
701+
glBindVertexArray(GL_vao);
706702

707703
gr_zbias(0);
708704
gr_zbuffer_set(ZBUFFER_TYPE_READ);

code/graphics/paths/NVGRenderer.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ namespace
5050
GL_state.Texture.SetActiveUnit(0);
5151
GL_state.Texture.SetTarget(0);
5252

53-
if ( GL_version >= 30 ) {
54-
glBindVertexArray(GL_vao);
55-
}
53+
glBindVertexArray(GL_vao);
5654

5755
GL_state.Array.BindArrayBuffer(0);
5856
GL_state.Array.BindUniformBuffer(0);
@@ -105,9 +103,7 @@ namespace graphics
105103
{
106104
GR_DEBUG_SCOPE("NanoVG flush");
107105

108-
if ( GL_version >= 30 ) {
109-
glBindVertexArray(0);
110-
}
106+
glBindVertexArray(0);
111107

112108
gr_opengl_set_2d_matrix();
113109

0 commit comments

Comments
 (0)