Skip to content

Commit fe1e9ca

Browse files
authored
Merge pull request #1174 from asarium/cleanup/GLSL_version
Remove some unneeded OpenGL version checks
2 parents cd06284 + 4ed9231 commit fe1e9ca

File tree

10 files changed

+38
-90
lines changed

10 files changed

+38
-90
lines changed

code/graphics/2d.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,9 +1767,7 @@ void poly_list::allocate(int _verts)
17671767
tsb = (tsb_t*)vm_malloc(sizeof(tsb_t) * _verts);
17681768
}
17691769

1770-
if ( GLSL_version >= 150 ) {
1771-
submodels = (int*)vm_malloc(sizeof(int) * _verts);
1772-
}
1770+
submodels = (int*)vm_malloc(sizeof(int) * _verts);
17731771

17741772
sorted_indices = (uint*)vm_malloc(sizeof(uint) * _verts);
17751773
}
@@ -1949,9 +1947,7 @@ void poly_list::make_index_buffer(SCP_vector<int> &vertex_list)
19491947
buffer_list_internal.tsb[z] = tsb[j];
19501948
}
19511949

1952-
if ( GLSL_version >= 150 ) {
1953-
buffer_list_internal.submodels[z] = submodels[j];
1954-
}
1950+
buffer_list_internal.submodels[z] = submodels[j];
19551951

19561952
buffer_list_internal.n_verts++;
19571953
z++;
@@ -1979,9 +1975,7 @@ poly_list& poly_list::operator = (poly_list &other_list)
19791975
memcpy(tsb, other_list.tsb, sizeof(tsb_t) * other_list.n_verts);
19801976
}
19811977

1982-
if ( GLSL_version >= 150 ) {
1983-
memcpy(submodels, other_list.submodels, sizeof(int) * other_list.n_verts);
1984-
}
1978+
memcpy(submodels, other_list.submodels, sizeof(int) * other_list.n_verts);
19851979

19861980
memcpy(sorted_indices, other_list.sorted_indices, sizeof(uint) * other_list.n_verts);
19871981

@@ -2151,9 +2145,7 @@ uint gr_determine_model_shader_flags(
21512145
) {
21522146
uint shader_flags = 0;
21532147

2154-
if ( GLSL_version >= 120 ) {
2155-
shader_flags |= SDR_FLAG_MODEL_CLIP;
2156-
}
2148+
shader_flags |= SDR_FLAG_MODEL_CLIP;
21572149

21582150
if ( transform ) {
21592151
shader_flags |= SDR_FLAG_MODEL_TRANSFORM;

code/graphics/grbatch.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,12 @@ int batch_add_bitmap(int texture, int tmap_flags, vertex *pnt, int orient, float
692692
return 1;
693693
}
694694

695-
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || GLSL_version <= 120 ) ) {
695+
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && !Cmdline_softparticles ) {
696696
// don't render this as a soft particle if we don't support soft particles
697697
tmap_flags &= ~(TMAP_FLAG_SOFT_QUAD);
698698
}
699699

700-
if ( GLSL_version > 120 && Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
700+
if ( Cmdline_softparticles && !Cmdline_no_geo_sdr_effects && (tmap_flags & TMAP_FLAG_VERTEX_GEN) ) {
701701
geometry_batch_add_bitmap(texture, tmap_flags, pnt, orient, rad, alpha, depth);
702702
return 0;
703703
} else if ( tmap_flags & TMAP_FLAG_VERTEX_GEN ) {
@@ -761,7 +761,7 @@ int batch_add_bitmap_rotated(int texture, int tmap_flags, vertex *pnt, float ang
761761
return 1;
762762
}
763763

764-
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && ( !Cmdline_softparticles || GLSL_version <= 120 ) ) {
764+
if ( tmap_flags & TMAP_FLAG_SOFT_QUAD && !Cmdline_softparticles ) {
765765
// don't render this as a soft particle if we don't support soft particles
766766
tmap_flags &= ~(TMAP_FLAG_SOFT_QUAD);
767767
}
@@ -1143,11 +1143,6 @@ int distortion_add_bitmap_rotated(int texture, int tmap_flags, vertex *pnt, floa
11431143
return 1;
11441144
}
11451145

1146-
if ( GLSL_version < 120 ) {
1147-
// don't render distortions if we can't support them.
1148-
return 0;
1149-
}
1150-
11511146
batch_item *item = NULL;
11521147

11531148
SCP_map<int, batch_item>::iterator it = distortion_map.find(texture);
@@ -1178,11 +1173,6 @@ int distortion_add_beam(int texture, int tmap_flags, vec3d *start, vec3d *end, f
11781173
return 1;
11791174
}
11801175

1181-
if ( GLSL_version < 120 ) {
1182-
// don't render distortions if we can't support them.
1183-
return 0;
1184-
}
1185-
11861176
batch_item *item = NULL;
11871177

11881178
SCP_map<int, batch_item>::iterator it = distortion_map.find(texture);

code/graphics/opengl/gropengl.cpp

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,8 @@ void gr_opengl_shutdown()
405405

406406
GL_initted = false;
407407

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

413411
if (GL_original_gamma_ramp != NULL && os::getSDLMainWindow() != nullptr) {
414412
SDL_SetWindowGammaRamp( os::getSDLMainWindow(), GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
@@ -1433,12 +1431,6 @@ static void init_extensions() {
14331431
Error(LOCATION, "Current GL Shading Langauge Version of %d is less than the required version of %d. Switch video modes or update your drivers.", GLSL_version, MIN_REQUIRED_GLSL_VERSION);
14341432
}
14351433

1436-
if ( GLSL_version < 120 ) {
1437-
mprintf((" No hardware support for deferred lighting. Deferred lighting will be disabled. \n"));
1438-
Cmdline_no_deferred_lighting = 1;
1439-
Cmdline_no_batching = true;
1440-
}
1441-
14421434
GLint max_texture_units;
14431435
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units);
14441436

@@ -1452,8 +1444,7 @@ static void init_extensions() {
14521444
Cmdline_normal = 0;
14531445
Cmdline_height = 0;
14541446
} else if (max_texture_units < 4) {
1455-
mprintf(( "Not enough texture units found for GLSL support. We need at least 4, we found %d.\n", max_texture_units ));
1456-
GLSL_version = 0;
1447+
Error(LOCATION, "Not enough texture units found for proper rendering support! We need at least 4, we found %d.", max_texture_units);
14571448
}
14581449
}
14591450

@@ -1542,11 +1533,9 @@ bool gr_opengl_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps)
15421533
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units);
15431534
max_texture_coords = 1;
15441535

1545-
// create vertex array object to make OpenGL Core happy if we can
1546-
if ( GL_version >= 30 ) {
1547-
glGenVertexArrays(1, &GL_vao);
1548-
glBindVertexArray(GL_vao);
1549-
}
1536+
// create vertex array object to make OpenGL Core happy
1537+
glGenVertexArrays(1, &GL_vao);
1538+
glBindVertexArray(GL_vao);
15501539

15511540
GL_state.Texture.init(max_texture_units);
15521541
GL_state.Array.init(max_texture_coords);
@@ -1632,10 +1621,6 @@ bool gr_opengl_init(std::unique_ptr<os::GraphicsOperations>&& graphicsOps)
16321621

16331622
bool gr_opengl_is_capable(gr_capability capability)
16341623
{
1635-
if ( GL_version < 20 ) {
1636-
return false;
1637-
}
1638-
16391624
switch ( capability ) {
16401625
case CAPABILITY_ENVIRONMENT_MAP:
16411626
return true;
@@ -1645,17 +1630,17 @@ bool gr_opengl_is_capable(gr_capability capability)
16451630
return Cmdline_height ? true : false;
16461631
case CAPABILITY_SOFT_PARTICLES:
16471632
case CAPABILITY_DISTORTION:
1648-
return Cmdline_softparticles && (GLSL_version >= 120) && !Cmdline_no_fbo;
1633+
return Cmdline_softparticles && !Cmdline_no_fbo;
16491634
case CAPABILITY_POST_PROCESSING:
1650-
return Cmdline_postprocess && (GLSL_version >= 120) && !Cmdline_no_fbo;
1635+
return Cmdline_postprocess && !Cmdline_no_fbo;
16511636
case CAPABILITY_DEFERRED_LIGHTING:
1652-
return !Cmdline_no_fbo && !Cmdline_no_deferred_lighting && (GLSL_version >= 120);
1637+
return !Cmdline_no_fbo && !Cmdline_no_deferred_lighting;
16531638
case CAPABILITY_SHADOWS:
1654-
return GL_version >= 32;
1639+
return true;
16551640
case CAPABILITY_BATCHED_SUBMODELS:
1656-
return (GLSL_version >= 150);
1641+
return true;
16571642
case CAPABILITY_POINT_PARTICLES:
1658-
return GL_version >= 32 && !Cmdline_no_geo_sdr_effects;
1643+
return !Cmdline_no_geo_sdr_effects;
16591644
case CAPABILITY_TIMESTAMP_QUERY:
16601645
return GL_version >= 33; // Timestamp queries are available from 3.3 onwards
16611646
}

code/graphics/opengl/gropengldraw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,7 @@ void opengl_clear_deferred_buffers()
20392039

20402040
void gr_opengl_deferred_lighting_begin()
20412041
{
2042-
if (GLSL_version < 120 || Cmdline_no_deferred_lighting)
2042+
if ( Cmdline_no_deferred_lighting)
20432043
return;
20442044

20452045
Deferred_lighting = true;
@@ -2069,7 +2069,7 @@ void gr_opengl_deferred_lighting_finish()
20692069
{
20702070
TRACE_SCOPE(tracing::ApplyLights);
20712071

2072-
if ( GLSL_version < 120 || Cmdline_no_deferred_lighting ) {
2072+
if ( Cmdline_no_deferred_lighting ) {
20732073
return;
20742074
}
20752075

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 && GLSL_version >= 150 ) {
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/opengl/gropengltnl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,6 @@ void opengl_reset_immediate_buffer()
266266

267267
int opengl_create_texture_buffer_object()
268268
{
269-
if ( GLSL_version < 130 ) {
270-
return -1;
271-
}
272-
273269
// create the buffer
274270
int buffer_object_handle = opengl_create_buffer_object(GL_TEXTURE_BUFFER, GL_DYNAMIC_DRAW);
275271

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

code/model/modelinterp.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,10 +2283,8 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
22832283
polygon_list[i].n_verts = vert_count;
22842284

22852285
// set submodel ID
2286-
if ( GLSL_version >= 150 ) {
2287-
for ( j = 0; j < polygon_list[i].n_verts; ++j ) {
2288-
polygon_list[i].submodels[j] = mn;
2289-
}
2286+
for ( j = 0; j < polygon_list[i].n_verts; ++j ) {
2287+
polygon_list[i].submodels[j] = mn;
22902288
}
22912289

22922290
// for the moment we can only support INT_MAX worth of verts per index buffer
@@ -2343,9 +2341,7 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
23432341
memcpy( (model_list->tsb) + model_list->n_verts, polygon_list[i].tsb, sizeof(tsb_t) * polygon_list[i].n_verts );
23442342
}
23452343

2346-
if ( GLSL_version >= 150 ) {
2347-
memcpy( (model_list->submodels) + model_list->n_verts, polygon_list[i].submodels, sizeof(int) * polygon_list[i].n_verts );
2348-
}
2344+
memcpy( (model_list->submodels) + model_list->n_verts, polygon_list[i].submodels, sizeof(int) * polygon_list[i].n_verts );
23492345

23502346
model_list->n_verts += polygon_list[i].n_verts;
23512347
}
@@ -2363,7 +2359,6 @@ void interp_configure_vertex_buffers(polymodel *pm, int mn)
23632359
}
23642360

23652361
if ( model_list->submodels != NULL ) {
2366-
Assert( GLSL_version >= 150 );
23672362
vertex_flags |= VB_FLAG_MODEL_ID;
23682363
}
23692364

code/model/modelread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ void create_vertex_buffer(polymodel *pm)
893893

894894
bool use_batched_rendering = true;
895895

896-
if ( GLSL_version >= 150 && !Cmdline_no_batching ) {
896+
if ( !Cmdline_no_batching ) {
897897
size_t stride = 0;
898898

899899
// figure out if the vertex stride of this entire model matches. if not, turn off batched rendering for this model
@@ -2589,7 +2589,7 @@ void model_load_texture(polymodel *pm, int i, char *file)
25892589
gr_maybe_create_shader(SDR_TYPE_MODEL, shader_flags | SDR_FLAG_MODEL_LIGHT);
25902590
gr_maybe_create_shader(SDR_TYPE_MODEL, shader_flags | SDR_FLAG_MODEL_LIGHT | SDR_FLAG_MODEL_FOG);
25912591

2592-
if( !Cmdline_no_batching && GLSL_version >= 150 ) {
2592+
if( !Cmdline_no_batching ) {
25932593
shader_flags &= ~SDR_FLAG_MODEL_DEFERRED;
25942594
shader_flags |= SDR_FLAG_MODEL_TRANSFORM;
25952595

0 commit comments

Comments
 (0)