From 225ef187d1c37232bd77836f791b035ce2695644 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Wed, 6 Dec 2017 22:05:27 -0500 Subject: [PATCH] use LEGACY_GL to determine of GL1 is used or not --- CMakeLists.txt | 4 ++++ src/graphics/2d.cpp | 12 ++++++------ src/graphics/grgl1.cpp | 2 +- src/graphics/grgl1render.cpp | 2 +- src/graphics/grgl1texture.cpp | 2 +- src/graphics/gropengl.cpp | 12 +++++------- src/graphics/grwxgl.cpp | 20 +++++++++++++++++++- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de045de..b6975f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,10 @@ if(EMSCRIPTEN) set(CMAKE_EXECUTABLE_SUFFIX ".html") endif() +if(NOT EMSCRIPTEN) + add_definitions(-DLEGACY_GL) +endif() + if(NOT WIN32) set(PLATFORM_LIBRARIES "") diff --git a/src/graphics/2d.cpp b/src/graphics/2d.cpp index 83740f2..6ff510e 100644 --- a/src/graphics/2d.cpp +++ b/src/graphics/2d.cpp @@ -529,11 +529,11 @@ void gr_close() case GR_OPENGL: gr_opengl_cleanup(); break; -#ifndef __EMSCRIPTEN__ + case GR_WXGL: gr_wxgl_cleanup(); break; -#endif + case GR_STUB: break; @@ -716,10 +716,10 @@ int gr_init() case GR_OPENGL: gr_opengl_cleanup(); break; -#ifndef __EMSCRIPTEN__ + case GR_WXGL: gr_wxgl_cleanup(); -#endif + case GR_STUB: break; @@ -778,12 +778,12 @@ int gr_init() case GR_OPENGL: gr_opengl_init(); break; -#ifndef __EMSCRIPTEN__ + case GR_WXGL: SDL_assert( Pofview_running || Fred_running ); gr_wxgl_init(); break; -#endif + case GR_STUB: SDL_assert(Is_standalone); gr_stub_init(); diff --git a/src/graphics/grgl1.cpp b/src/graphics/grgl1.cpp index fe5e5ee..80c2a54 100644 --- a/src/graphics/grgl1.cpp +++ b/src/graphics/grgl1.cpp @@ -6,7 +6,7 @@ * the source. */ -#ifndef __EMSCRIPTEN__ +#ifdef LEGACY_GL #include "SDL_opengl.h" diff --git a/src/graphics/grgl1render.cpp b/src/graphics/grgl1render.cpp index c0bb41c..a00175c 100644 --- a/src/graphics/grgl1render.cpp +++ b/src/graphics/grgl1render.cpp @@ -6,7 +6,7 @@ * the source. */ -#ifndef __EMSCRIPTEN__ +#ifdef LEGACY_GL #include "SDL_opengl.h" diff --git a/src/graphics/grgl1texture.cpp b/src/graphics/grgl1texture.cpp index c400f56..fbbbccc 100644 --- a/src/graphics/grgl1texture.cpp +++ b/src/graphics/grgl1texture.cpp @@ -6,7 +6,7 @@ * the source. */ -#ifndef __EMSCRIPTEN__ +#ifdef LEGACY_GL #include "SDL_opengl.h" diff --git a/src/graphics/gropengl.cpp b/src/graphics/gropengl.cpp index aec6748..38653e4 100644 --- a/src/graphics/gropengl.cpp +++ b/src/graphics/gropengl.cpp @@ -178,7 +178,7 @@ void gr_opengl_activate(int active) void gr_opengl_cleanup() { -#ifndef __EMSCRIPTEN__ +#ifdef LEGACY_GL opengl1_cleanup(); #endif opengl2_cleanup(); @@ -231,15 +231,13 @@ void gr_opengl_init() SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, FSAA); } -#ifndef __EMSCRIPTEN__ - int rc = 1; + // try GL 2 first, then fall back to legacy GL (if enabled) + int rc = opengl2_init(); - // try GL 2 first, then fall back to GL 1 - if ( !opengl2_init() ) { +#ifdef LEGACY_GL + if ( !rc ) { rc = opengl1_init(); } -#else - int rc = opengl2_init(); #endif if ( !rc ) { diff --git a/src/graphics/grwxgl.cpp b/src/graphics/grwxgl.cpp index 2c12b2b..6a10429 100644 --- a/src/graphics/grwxgl.cpp +++ b/src/graphics/grwxgl.cpp @@ -6,7 +6,7 @@ * the source. */ -#ifndef __EMSCRIPTEN__ +#ifdef LEGACY_GL #include "SDL_opengl.h" @@ -285,4 +285,22 @@ void gr_wxgl_init() gr_clear(); } +#else + +void gr_wxgl_init() +{ +} + +void gr_wxgl_cleanup() +{ +} + +void gr_wxgl_flip() +{ +} + +void gr_wxgl_set_viewport(int width, int height) +{ +} + #endif -- 2.39.2