PCMOpenGLExtensionLoader.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "../include/PCMOpenGLExtensionLoader.h"
00030
00031
00032
00033
00034
00035 #include <GL/glew.h>
00036 #include <GL/glx.h>
00037 #include <GL/glu.h>
00038
00039 namespace ParCompMark
00040 {
00041
00042
00043
00044
00045
00046 OpenGLExtensionLoader::LoadingMode OpenGLExtensionLoader::mLoadingMode = DELAYED;
00047 std::list < std::string > OpenGLExtensionLoader::mExtensionsToLoad;
00048
00049
00050
00051
00052
00053 void OpenGLExtensionLoader::load(const std::list < std::string > &extensions)
00054 {
00055 switch (mLoadingMode)
00056 {
00057 case IMMEDIATE:
00058 _init();
00059 _load(extensions);
00060 break;
00061 case DELAYED:std::list < std::string > _extensions = extensions;
00062 mExtensionsToLoad.splice(mExtensionsToLoad.end(), _extensions);
00063 break;
00064 }
00065 }
00066
00067
00068
00069 void OpenGLExtensionLoader::loadDelayed()
00070 {
00071 _init();
00072 _load(mExtensionsToLoad);
00073 }
00074
00075
00076
00077 void OpenGLExtensionLoader::_load(const std::list < std::string > &extensions)
00078 {
00079
00080
00081 std::string currentExt;
00082
00083 std::list < std::string > ext = extensions;
00084
00085 for(; !ext.empty(); ext.pop_back())
00086 {
00087
00088
00089 currentExt = "";
00090
00091 currentExt = ext.back();
00092
00093
00094 if(!glewIsSupported(currentExt.c_str()))
00095 Except(INTERNAL_ERROR, "OpenGLExtensionLoader::load()",
00096 "OpenGL extension `" + currentExt + "\'is not supported.");
00097
00098 }
00099 }
00100
00101
00102
00103 void OpenGLExtensionLoader::_init()
00104 {
00105
00106 glewExperimental = GL_TRUE;
00107
00108
00109 GLenum err = glewInit();
00110
00111
00112 if(GLEW_OK != err)
00113 Except(INTERNAL_ERROR, "OpenGLExtensionLoader::load()",
00114 std::string("Error during OpenGL extentension loading: ") +
00115 std::string((const char *) glewGetErrorString(err)));
00116 }
00117
00118
00119
00120 }