From: grumbel 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=3bdfcbe06bc5b2725f3b662924251f5ca91e3261;p=supertux.git Use GLEW to check for OpenGL extensions git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6075 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- 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