From: Ingo Ruhnke Date: Fri, 20 Nov 2009 21:24:41 +0000 (+0000) Subject: Use GLEW to check for OpenGL extensions X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ae58704e9ea3fd28b57784b6b8fe699a7dd3e47e;p=supertux.git Use GLEW to check for OpenGL extensions SVN-Revision: 6075 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 750af0c62..74474820a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -325,6 +325,7 @@ TARGET_LINK_LIBRARIES(supertux2 ${OGGVORBIS_LIBRARIES}) TARGET_LINK_LIBRARIES(supertux2 ${PHYSFS_LIBRARY}) IF(HAVE_OPENGL) TARGET_LINK_LIBRARIES(supertux2 ${OPENGL_LIBRARY}) + TARGET_LINK_LIBRARIES(supertux2 GLEW) ENDIF(HAVE_OPENGL) IF(HAVE_LIBCURL) TARGET_LINK_LIBRARIES(supertux2 ${CURL_LIBRARY}) diff --git a/SConscript b/SConscript index 6e1a0503e..08da37b0a 100644 --- a/SConscript +++ b/SConscript @@ -52,7 +52,7 @@ class Project: "src/", "/usr/include/AL/", # yuck "."], - CXXFLAGS=["-O2", "-g3", + CXXFLAGS=["-O0", "-g3", "-ansi", "-pedantic", "-Wall", @@ -71,7 +71,7 @@ class Project: self.env.ParseConfig("pkg-config --libs --cflags openal") self.env.ParseConfig("pkg-config --libs --cflags vorbis vorbisfile ogg") self.env.Append(LIBS=[self.libsquirrel, self.libbinreloc, self.libtinygettext, self.libfindlocale]) - self.env.Append(LIBS=["SDL_image", "curl", "GL", "physfs"]) + self.env.Append(LIBS=["SDL_image", "curl", "GL", "GLEW", "physfs"]) # Create config.h self.iconv_const = 0 diff --git a/src/video/gl/gl_renderer.cpp b/src/video/gl/gl_renderer.cpp index ecba7df2c..12086fc70 100644 --- a/src/video/gl/gl_renderer.cpp +++ b/src/video/gl/gl_renderer.cpp @@ -111,9 +111,9 @@ inline void intern_draw(float left, float top, float right, float bottom, } // namespace -GLRenderer::GLRenderer() - : desktop_width(-1), - desktop_height(-1) +GLRenderer::GLRenderer() : + desktop_width(-1), + desktop_height(-1) { Renderer::instance_ = this; @@ -189,6 +189,17 @@ GLRenderer::GLRenderer() texture_manager = new TextureManager(); else texture_manager->reload_textures(); + +#ifndef GL_VERSION_ES_CM_1_0 + GLenum err = glewInit(); + if (GLEW_OK != err) + { + std::ostringstream out; + out << "GLRenderer: " << glewGetErrorString(err); + throw std::runtime_error(out.str()); + } + log_info << "Using GLEW " << glewGetString(GLEW_VERSION) << std::endl; +#endif } GLRenderer::~GLRenderer() diff --git a/src/video/gl/gl_texture.cpp b/src/video/gl/gl_texture.cpp index ec20565b3..f9fa1b2a3 100644 --- a/src/video/gl/gl_texture.cpp +++ b/src/video/gl/gl_texture.cpp @@ -77,8 +77,16 @@ GLTexture::GLTexture(SDL_Surface* image) : texture_width = next_power_of_two(image->w); texture_height = next_power_of_two(image->h); #else - texture_width = image->w; - texture_height = image->h; + if (GL_ARB_texture_non_power_of_two) + { + texture_width = image->w; + texture_height = image->h; + } + else + { + texture_width = next_power_of_two(image->w); + texture_height = next_power_of_two(image->h); + } #endif image_width = image->w; diff --git a/src/video/glutil.hpp b/src/video/glutil.hpp index 4ffea0050..2b46f6d7f 100644 --- a/src/video/glutil.hpp +++ b/src/video/glutil.hpp @@ -24,6 +24,10 @@ #include #include +#ifndef GL_VERSION_ES_CM_1_0 +# include +#endif + #if defined(MACOSX) # include # include