diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2012-07-28 23:36:12 +0200 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2012-07-28 23:36:12 +0200 |
commit | 72c0188ec37c3783133baf6960d72cb3c9d12a6c (patch) | |
tree | 0aa06fe40a3721238c9bc82090f9478a088ca9b6 /src/graphics/opengl/gldevice.cpp | |
parent | da63248bb9127cc64b6f174e0de254d6c01b7809 (diff) | |
download | colobot-72c0188ec37c3783133baf6960d72cb3c9d12a6c.tar.gz colobot-72c0188ec37c3783133baf6960d72cb3c9d12a6c.tar.bz2 colobot-72c0188ec37c3783133baf6960d72cb3c9d12a6c.zip |
GLEW
Added GLEW for loading OpenGL extensions
Diffstat (limited to 'src/graphics/opengl/gldevice.cpp')
-rw-r--r-- | src/graphics/opengl/gldevice.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index d31d007..bfe7fd7 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -16,10 +16,20 @@ // gldevice.cpp -#include "common/image.h" #include "graphics/opengl/gldevice.h" + +#include "common/config.h" +#include "common/image.h" #include "math/geometry.h" + +#if defined(USE_GLEW) + +// When using GLEW, only glew.h is needed +#include <GL/glew.h> + +#else + // Should define prototypes of used extensions as OpenGL functions #define GL_GLEXT_PROTOTYPES @@ -27,9 +37,11 @@ #include <GL/glu.h> #include <GL/glext.h> +#endif // if defined(GLEW) + #include <SDL/SDL.h> -#include <assert.h> +#include <cassert> @@ -73,9 +85,23 @@ std::string Gfx::CGLDevice::GetError() bool Gfx::CGLDevice::Create() { - /* NOTE: extension testing is not done here as the assumed version of OpenGL to be used (1.4+) - must already have the required extensions. The used extensions are listed here for reference: - GL_ARB_multitexture, GL_EXT_texture_env_combine, GL_EXT_secondary_color */ +#if defined(USE_GLEW) + if (glewInit() != GLEW_OK) + { + m_error = "GLEW initialization failed"; + return false; + } + + if ( (! GLEW_ARB_multitexture) || (! GLEW_EXT_texture_env_combine) || (! GLEW_EXT_secondary_color) ) + { + m_error = "GLEW reports required extensions not supported"; + return false; + } + +#endif + + /* NOTE: when not using GLEW, extension testing is not performed, as it is assumed that + glext.h is up-to-date and the OpenGL shared library has the required functions present. */ m_wasInit = true; |