From 72c0188ec37c3783133baf6960d72cb3c9d12a6c Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sat, 28 Jul 2012 23:36:12 +0200 Subject: GLEW Added GLEW for loading OpenGL extensions --- src/graphics/opengl/gldevice.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/graphics') 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 + +#else + // Should define prototypes of used extensions as OpenGL functions #define GL_GLEXT_PROTOTYPES @@ -27,9 +37,11 @@ #include #include +#endif // if defined(GLEW) + #include -#include +#include @@ -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; -- cgit v1.2.3-1-g7c22