diff --git a/modules/gfx/src/glext_include.hh b/modules/gfx/src/glext_include.hh index b297153e2cf7a62ae864e7ef2b4e6ec69c7b95ef..3eda5fb9a91d72ba3fc698f4af2fcfbaccf64dbc 100644 --- a/modules/gfx/src/glext_include.hh +++ b/modules/gfx/src/glext_include.hh @@ -42,4 +42,11 @@ #include <ost/gfx/gl_include.hh> +#if defined(__APPLE__) +// On all MacOS X version we support, OpenGL 2.0 is available, so it's safe to +// hardcode the value here... +#define OST_GL_VERSION_2_0 1 +#else +#define OST_GL_VERSION_2_0 GLEW_VERSION_2_0 +#endif #endif diff --git a/modules/gfx/src/impl/scene_fx.cc b/modules/gfx/src/impl/scene_fx.cc index 2370addb637ee8114660a7a67b046866d1d045ed..16d6c426f5d9a1da5587b1db5c90ca8b29d24028 100644 --- a/modules/gfx/src/impl/scene_fx.cc +++ b/modules/gfx/src/impl/scene_fx.cc @@ -61,6 +61,7 @@ SceneFX::~SceneFX() void SceneFX::Setup() { + if(!OST_GL_VERSION_2_0) return; LOGN_DEBUG("SceneFX: setup"); glGenTextures(1,&scene_tex_id_); @@ -212,6 +213,7 @@ void SceneFX::Resize(unsigned int w, unsigned int h) void SceneFX::Preprocess() { + if(!OST_GL_VERSION_2_0) return; if(use_fb_) { #if GL_VERSION_3_0 glBindFramebuffer(GL_FRAMEBUFFER, scene_fb_); @@ -223,6 +225,7 @@ void SceneFX::Preprocess() void SceneFX::Postprocess() { + if(!OST_GL_VERSION_2_0) return; if(use_fb_) { #if GL_VERSION_3_0 glBindFramebuffer(GL_FRAMEBUFFER, 0); @@ -351,6 +354,7 @@ void SceneFX::Postprocess() void SceneFX::DrawTex(unsigned int w, unsigned int h, GLuint texid) { + if(!OST_GL_VERSION_2_0) return; Shader::Instance().PushProgram(); Shader::Instance().Activate(""); glActiveTexture(GL_TEXTURE0); diff --git a/modules/gfx/src/scene.cc b/modules/gfx/src/scene.cc index 71d4a2ad424fe3577e92d34d488005d1ecdc7dd5..fdac2ef582bc0d7ccd7e43f68b09b8d6cac48e3e 100644 --- a/modules/gfx/src/scene.cc +++ b/modules/gfx/src/scene.cc @@ -373,8 +373,10 @@ void Scene::InitGL(bool full) #if OST_SHADER_SUPPORT_ENABLED GLint mbufs=0,msamples=0; - glGetIntegerv(GL_SAMPLE_BUFFERS, &mbufs); - glGetIntegerv(GL_SAMPLES, &msamples); + if(OST_GL_VERSION_2_0) { + glGetIntegerv(GL_SAMPLE_BUFFERS, &mbufs); + glGetIntegerv(GL_SAMPLES, &msamples); + } if(mbufs>0 && msamples>0) { LOGN_VERBOSE("Scene: enabling multisampling with: " << msamples << " samples"); @@ -425,7 +427,9 @@ void Scene::InitGL(bool full) glEnable(GL_TEXTURE_2D); #if OST_SHADER_SUPPORT_ENABLED - glActiveTexture(GL_TEXTURE0); + if(OST_GL_VERSION_2_0) { + glActiveTexture(GL_TEXTURE0); + } #endif glBindTexture(GL_TEXTURE_2D, scene_left_tex_); @@ -1828,7 +1832,9 @@ void Scene::render_stereo() glEnable(GL_TEXTURE_2D); #if OST_SHADER_SUPPORT_ENABLED - glActiveTexture(GL_TEXTURE0); + if(OST_GL_VERSION_2_0) { + glActiveTexture(GL_TEXTURE0); + } #endif glBindTexture(GL_TEXTURE_2D, scene_left_tex_); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, vp_width_, vp_height_, 0); @@ -1838,7 +1844,9 @@ void Scene::render_stereo() render_scene(); glEnable(GL_TEXTURE_2D); #if OST_SHADER_SUPPORT_ENABLED - glActiveTexture(GL_TEXTURE0); + if(OST_GL_VERSION_2_0) { + glActiveTexture(GL_TEXTURE0); + } #endif glBindTexture(GL_TEXTURE_2D, scene_right_tex_); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, vp_width_, vp_height_, 0); @@ -1897,7 +1905,9 @@ void Scene::render_stereo() glStencilFunc(GL_EQUAL,0x0,0x1); } #if OST_SHADER_SUPPORT_ENABLED + if(OST_GL_VERSION_2_0) { glActiveTexture(GL_TEXTURE0); + } #endif glBindTexture(GL_TEXTURE_2D, stereo_inverted_ ? scene_left_tex_ : scene_right_tex_); // draw @@ -1917,7 +1927,9 @@ void Scene::render_stereo() glStencilFunc(GL_EQUAL,0x1,0x1); } #if OST_SHADER_SUPPORT_ENABLED - glActiveTexture(GL_TEXTURE0); + if(OST_GL_VERSION_2_0) { + glActiveTexture(GL_TEXTURE0); + } #endif glBindTexture(GL_TEXTURE_2D, stereo_inverted_ ? scene_right_tex_ : scene_left_tex_); // draw diff --git a/modules/gfx/src/shader.cc b/modules/gfx/src/shader.cc index 187be29d940d8e6fed54f24f85fdcc1a4c8dfd7e..01674489b5d95cb751d6110b900a0361ea7e3de5 100644 --- a/modules/gfx/src/shader.cc +++ b/modules/gfx/src/shader.cc @@ -50,6 +50,9 @@ Shader::Shader(): shader_code_map_(), shader_program_map_() { + if(!OST_GL_VERSION_2_0) { + LOGN_VERBOSE("OpenGL version smaller 2.0, deactivating shader functionality"); + } } @@ -121,6 +124,8 @@ bool link_shader(const std::vector<GLuint>& code_list, String pr_name, GLuint& s void Shader::Setup() { + if(!OST_GL_VERSION_2_0) return; + String ost_root = GetSharedDataPath(); bf::path ost_root_dir(ost_root); bf::path shader_dir(ost_root_dir / "shader"); @@ -298,6 +303,8 @@ void Shader::Setup() void Shader::Activate(const String& name) { + if(!OST_GL_VERSION_2_0) return; + if(!name.empty()) { std::map<String, GLuint>::iterator it = shader_program_map_.find(name); if(it!=shader_program_map_.end()) { @@ -332,6 +339,7 @@ String Shader::GetCurrentName() const bool Shader::IsValid() const { + if(!OST_GL_VERSION_2_0) return false; return valid_; } @@ -342,11 +350,13 @@ bool Shader::IsActive() const void Shader::PushProgram() { + if(!OST_GL_VERSION_2_0) return; program_stack_.push(current_name_); } void Shader::PopProgram() { + if(!OST_GL_VERSION_2_0) return; if(!program_stack_.empty()) { current_name_ = program_stack_.top(); program_stack_.pop(); @@ -356,6 +366,7 @@ void Shader::PopProgram() void Shader::UpdateState() { + if(!OST_GL_VERSION_2_0) return; if(current_program_!=0) { // update all settings GLint result;