Use GLEW to check for OpenGL extensions
authorIngo Ruhnke <grumbel@gmx.de>
Fri, 20 Nov 2009 21:24:41 +0000 (21:24 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Fri, 20 Nov 2009 21:24:41 +0000 (21:24 +0000)
SVN-Revision: 6075

CMakeLists.txt
SConscript
src/video/gl/gl_renderer.cpp
src/video/gl/gl_texture.cpp
src/video/glutil.hpp

index 750af0c..7447482 100644 (file)
@@ -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})
index 6e1a050..08da37b 100644 (file)
@@ -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
index ecba7df..12086fc 100644 (file)
@@ -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()
index ec20565..f9fa1b2 100644 (file)
@@ -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;
index 4ffea00..2b46f6d 100644 (file)
 #include <sstream>
 #include <stdexcept>
 
+#ifndef GL_VERSION_ES_CM_1_0
+#  include <GL/glew.h>
+#endif
+
 #if defined(MACOSX)
 #  include <OpenGL/gl.h>
 #  include <OpenGL/glext.h>