Skip to content

Commit b5f57e5

Browse files
dos1SiegeLord
authored andcommitted
introduce ALLEGRO_CFG_OPENGL_FIXED_FUNCTION config macro
Makes the legacy GL code parts a bit clearer.
1 parent bdb8640 commit b5f57e5

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ if(WANT_OPENGL)
571571
if(OPENGL_FOUND AND OPENGL_GLU_FOUND)
572572
set(SUPPORT_OPENGL 1)
573573
set(ALLEGRO_CFG_OPENGL 1)
574+
set(ALLEGRO_CFG_OPENGL_FIXED_FUNCTION 1)
574575
# We assume that the OpenGL library is not very old.
575576
set(ALLEGRO_CFG_OPENGL_PROGRAMMABLE_PIPELINE 1)
576577
if(OPENGL_opengl_LIBRARY) # prefer GLVND if available
@@ -636,6 +637,7 @@ if(WANT_OPENGL)
636637
set(ALLEGRO_CFG_OPENGL 1)
637638
set(ALLEGRO_CFG_OPENGLES 1)
638639
set(ALLEGRO_CFG_OPENGLES1 1)
640+
set(ALLEGRO_CFG_OPENGL_FIXED_FUNCTION 1)
639641
message("Using OpenGL ES 1.1")
640642
set(OPENGL_LIBRARIES ${OPENGLES1_LIBRARIES})
641643
include_directories(SYSTEM ${OPENGLES1_INCLUDE_DIR})

addons/primitives/prim_opengl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static void setup_state(const char* vtxs, const ALLEGRO_VERTEX_DECL* decl, ALLEG
200200
#endif
201201
}
202202
else {
203-
#ifndef ALLEGRO_CFG_OPENGLES2
203+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
204204
if(decl) {
205205
ALLEGRO_VERTEX_ELEMENT* e;
206206
e = &decl->elements[ALLEGRO_PRIM_POSITION];
@@ -315,7 +315,7 @@ static void setup_state(const char* vtxs, const ALLEGRO_VERTEX_DECL* decl, ALLEG
315315
#endif
316316
}
317317
else {
318-
#ifndef ALLEGRO_CFG_OPENGLES2
318+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
319319
glMatrixMode(GL_TEXTURE);
320320
glLoadMatrixf(mat[0]);
321321
glMatrixMode(GL_MODELVIEW);
@@ -359,7 +359,7 @@ static void revert_state(ALLEGRO_BITMAP* texture)
359359
#endif
360360
}
361361
else {
362-
#ifndef ALLEGRO_CFG_OPENGLES2
362+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
363363
glDisable(GL_TEXTURE_2D);
364364
glMatrixMode(GL_TEXTURE);
365365
glLoadIdentity();
@@ -379,7 +379,7 @@ static void revert_state(ALLEGRO_BITMAP* texture)
379379
#endif
380380
}
381381
else {
382-
#ifndef ALLEGRO_CFG_OPENGLES2
382+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
383383
glDisableClientState(GL_COLOR_ARRAY);
384384
glDisableClientState(GL_VERTEX_ARRAY);
385385
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

include/allegro5/platform/alplatf.h.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#cmakedefine ALLEGRO_CFG_OPENGLES1
2222
#cmakedefine ALLEGRO_CFG_OPENGLES2
2323
#cmakedefine ALLEGRO_CFG_OPENGLES3
24+
#cmakedefine ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
2425
#cmakedefine ALLEGRO_CFG_OPENGL_PROGRAMMABLE_PIPELINE
2526
#cmakedefine ALLEGRO_CFG_SHADER_GLSL
2627
#cmakedefine ALLEGRO_CFG_SHADER_HLSL

src/opengl/ogl_bitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ char const *_al_gl_error_string(GLenum e)
183183
ERR(GL_INVALID_ENUM)
184184
ERR(GL_INVALID_VALUE)
185185
ERR(GL_INVALID_OPERATION)
186-
#ifndef ALLEGRO_CFG_OPENGLES2
186+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
187187
ERR(GL_STACK_OVERFLOW)
188188
ERR(GL_STACK_UNDERFLOW)
189189
#endif
@@ -464,7 +464,7 @@ static bool ogl_upload_bitmap(ALLEGRO_BITMAP *bitmap)
464464
post_generate_mipmap = true;
465465
}
466466
else {
467-
#ifndef ALLEGRO_CFG_OPENGLES2
467+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
468468
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
469469
e = glGetError();
470470
if (e) {

src/opengl/ogl_draw.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void vert_ptr_on(ALLEGRO_DISPLAY *display, int n, GLint t, int stride, vo
134134
#endif
135135
}
136136
else {
137-
#ifndef ALLEGRO_CFG_OPENGLES2
137+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
138138
glEnableClientState(GL_VERTEX_ARRAY);
139139
glVertexPointer(n, t, stride, v);
140140
#endif
@@ -151,7 +151,7 @@ static void vert_ptr_off(ALLEGRO_DISPLAY *display)
151151
#endif
152152
}
153153
else {
154-
#ifndef ALLEGRO_CFG_OPENGLES2
154+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
155155
glDisableClientState(GL_VERTEX_ARRAY);
156156
#endif
157157
}
@@ -168,7 +168,7 @@ static void color_ptr_on(ALLEGRO_DISPLAY *display, int n, GLint t, int stride, v
168168
#endif
169169
}
170170
else {
171-
#ifndef ALLEGRO_CFG_OPENGLES2
171+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
172172
glEnableClientState(GL_COLOR_ARRAY);
173173
glColorPointer(n, t, stride, v);
174174
#endif
@@ -185,7 +185,7 @@ static void color_ptr_off(ALLEGRO_DISPLAY *display)
185185
#endif
186186
}
187187
else {
188-
#ifndef ALLEGRO_CFG_OPENGLES2
188+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
189189
glDisableClientState(GL_COLOR_ARRAY);
190190
#endif
191191
}
@@ -202,7 +202,7 @@ static void tex_ptr_on(ALLEGRO_DISPLAY *display, int n, GLint t, int stride, voi
202202
#endif
203203
}
204204
else {
205-
#ifndef ALLEGRO_CFG_OPENGLES2
205+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
206206
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
207207
glTexCoordPointer(n, t, stride, v);
208208
#endif
@@ -219,7 +219,7 @@ static void tex_ptr_off(ALLEGRO_DISPLAY *display)
219219
#endif
220220
}
221221
else {
222-
#ifndef ALLEGRO_CFG_OPENGLES2
222+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
223223
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
224224
#endif
225225
}
@@ -409,7 +409,7 @@ static void ogl_flush_vertex_cache(ALLEGRO_DISPLAY *disp)
409409
color_ptr_on(disp, 4, GL_FLOAT, sizeof(ALLEGRO_OGL_BITMAP_VERTEX),
410410
(char*)(disp->vertex_cache) + offsetof(ALLEGRO_OGL_BITMAP_VERTEX, r));
411411

412-
#ifndef ALLEGRO_CFG_OPENGLES2
412+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
413413
if (!(disp->flags & ALLEGRO_PROGRAMMABLE_PIPELINE))
414414
glDisableClientState(GL_NORMAL_ARRAY);
415415
#endif
@@ -475,7 +475,7 @@ static void ogl_update_transformation(ALLEGRO_DISPLAY* disp,
475475
}
476476
#endif
477477
} else {
478-
#ifndef ALLEGRO_CFG_OPENGLES2
478+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
479479
glMatrixMode(GL_PROJECTION);
480480
glLoadMatrixf((float *)target->proj_transform.m);
481481
glMatrixMode(GL_MODELVIEW);

src/opengl/ogl_render_state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void _al_ogl_update_render_state(ALLEGRO_DISPLAY *display)
2525
* avoid so many redundant OpenGL calls.
2626
*/
2727

28-
#ifndef ALLEGRO_CFG_OPENGLES2
28+
#ifdef ALLEGRO_CFG_OPENGL_FIXED_FUNCTION
2929
if (!(display->flags & ALLEGRO_PROGRAMMABLE_PIPELINE)) {
3030
if (r->alpha_test == 0)
3131
glDisable(GL_ALPHA_TEST);

0 commit comments

Comments
 (0)