diff --git a/include/ACGL/OpenGL/GL.hh b/include/ACGL/OpenGL/GL.hh index 2b6d0a175adc6459c3ddb4a12e1a3d5a6d57445e..23dadaa6559e30dc38e7d1e3a950d9ba85a379b4 100644 --- a/include/ACGL/OpenGL/GL.hh +++ b/include/ACGL/OpenGL/GL.hh @@ -182,6 +182,8 @@ #else // use the internal loader: #define ACGL_EXTENSION_LOADER_GLLOADGEN + // prevent other GL headers from getting included and redefine GL: + #define __gl3_h_ // // Include the right header which has just what is needed to catch compatibility problems at compiletime. diff --git a/include/ACGL/OpenGL/Objects/ShaderProgram.hh b/include/ACGL/OpenGL/Objects/ShaderProgram.hh index 9b0ec4497de4f6c3f3b3086c212294d9d36a790c..5cb57557d3275139b9541ccfb4d08a862b7d20d8 100644 --- a/include/ACGL/OpenGL/Objects/ShaderProgram.hh +++ b/include/ACGL/OpenGL/Objects/ShaderProgram.hh @@ -126,11 +126,11 @@ public: inline GLuint getUniformBlockIndex (const std::string& _nameInShader) const { return glGetUniformBlockIndex(mObjectName, _nameInShader.c_str()); } //! binds a uniform block, the string version will ignore a non-existent block - inline void setUniformBlockBinding( GLuint _blockIndex, GLuint _bindingPoint ) const { glUniformBlockBinding( mObjectName, _blockIndex, _bindingPoint ); openGLCommonErrorOccured(); } + inline void setUniformBlockBinding( GLuint _blockIndex, GLuint _bindingPoint ) const { glUniformBlockBinding( mObjectName, _blockIndex, _bindingPoint ); openGLCommonError(); } inline void setUniformBlockBinding( const std::string& _blockName, GLuint _bindingPoint ) const { GLuint blockIndex = getUniformBlockIndex(_blockName); if (blockIndex != GL_INVALID_INDEX) glUniformBlockBinding( mObjectName, blockIndex, _bindingPoint ); - openGLCommonErrorOccured(); + openGLCommonError(); } GLint getUniformBlockBinding( const std::string& _blockName ) const { return getUniformBlockBinding( getUniformBlockIndex(_blockName)); } diff --git a/include/ACGL/OpenGL/Objects/UniformBuffer.hh b/include/ACGL/OpenGL/Objects/UniformBuffer.hh index 3d60683f31c0c9034ec0b434a4de2b41fb9e059e..73cb0b41eb887067ed7df1b7c7abef06e84dfcd1 100644 --- a/include/ACGL/OpenGL/Objects/UniformBuffer.hh +++ b/include/ACGL/OpenGL/Objects/UniformBuffer.hh @@ -105,6 +105,11 @@ public: template <typename T> void setUniform (const std::string &_nameInShader, T _v) { GLint offset = getUniformOffset( _nameInShader ); + if (offset == -1) { + // hack for MacOS bug: + offset = getUniformOffset( mBlockName+"."+_nameInShader ); + //ACGL::Utils::debug() << "testing " + mBlockName+"."+_nameInShader << std::endl; + } if (offset == -1) { ACGL::Utils::error() << "UniformBuffer does not know uniform " << _nameInShader << std::endl; return; @@ -120,6 +125,11 @@ private: template <typename T> void setUniformScalar (const std::string &_nameInShader, T _v) { GLint offset = getUniformOffset( _nameInShader ); + if (offset == -1) { + // hack for MacOS bug: + offset = getUniformOffset( mBlockName+"."+_nameInShader ); + //ACGL::Utils::debug() << "testing " + mBlockName+"."+_nameInShader << std::endl; + } if (offset == -1) { ACGL::Utils::error() << "UniformBuffer does not know uniform " << _nameInShader << std::endl; return; @@ -128,6 +138,9 @@ private: } SharedLocationMappings uniformNameToOffsetMap; + +public: // for mac bug + std::string mBlockName; }; ACGL_SMARTPOINTER_TYPEDEFS(UniformBuffer) diff --git a/src/ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.cc b/src/ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.cc index 752313adf965b155c7bd99ab1f3d12414b5eea2f..e83ef07423515a1f9f456398cdc78767f7aa9e2f 100644 --- a/src/ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.cc +++ b/src/ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.cc @@ -23,7 +23,8 @@ using namespace ACGL::Base; bool GeometryDataControlFileOBJ::load(SharedGeometryData& geometry) const { - if(geometry = loadGeometryDataFromOBJ(getFullFilePath())) + geometry = loadGeometryDataFromOBJ(getFullFilePath()); + if (geometry) return true; else return false; diff --git a/src/ACGL/OpenGL/Controller/ShaderProgramControlFiles.cc b/src/ACGL/OpenGL/Controller/ShaderProgramControlFiles.cc index 87ae6e074b0b87441d1325202ebb332323c5c6af..022cb00ca7532ddbc9e215724087198df0ff5607 100644 --- a/src/ACGL/OpenGL/Controller/ShaderProgramControlFiles.cc +++ b/src/ACGL/OpenGL/Controller/ShaderProgramControlFiles.cc @@ -92,7 +92,7 @@ SharedShaderProgram ShaderProgramControlFiles::create(void) if (!setBindings( shaderProgram )) { return SharedShaderProgram(); // e.g. linking failed } - openGLCommonErrorOccured(); + openGLCommonError(); updateFileModificationTimes(); return shaderProgram; } @@ -100,18 +100,18 @@ SharedShaderProgram ShaderProgramControlFiles::create(void) // will get called from the create and update functions: bool ShaderProgramControlFiles::setBindings(SharedShaderProgram &_shaderProgram) { - openGLRareErrorOccured(); + openGLRareError(); _shaderProgram->link(); # if (ACGL_OPENGL_VERSION >= 30) _shaderProgram->setFragmentDataLocations( mFragmentDataLocations ); // might relink on it's own - openGLRareErrorOccured(); + openGLRareError(); SharedLocationMappings oldAttributeMap = _shaderProgram->getAttributeLocations(); mAttributeLocations->addLocations( oldAttributeMap ); // add as many old locations as possible without destoying the location map _shaderProgram->setAttributeLocations( mAttributeLocations ); // might relink on it's own - openGLRareErrorOccured(); + openGLRareError(); # else if ( (mAttributeLocations->getSize() > 0) && (mFragmentDataLocations->getSize() > 0) ) { Utils::error() << "can't set explicit attribute/fragdata locations on OpenGL < 3.0" << std::endl; diff --git a/src/ACGL/OpenGL/Objects/Texture.cc b/src/ACGL/OpenGL/Objects/Texture.cc index dd286f4763ca7c0962e9bea2130be67c0816def5..329c539c0133e50b03fb5d1fbc3371f2ac99a3d7 100644 --- a/src/ACGL/OpenGL/Objects/Texture.cc +++ b/src/ACGL/OpenGL/Objects/Texture.cc @@ -343,7 +343,7 @@ void TextureRectangle::setImageData( const SharedTextureData &_data ) mWidth = _data->getWidth(); mHeight = _data->getHeight(); - openGLCriticalErrorOccured(); + openGLCriticalError(); bind(); glTexImage2D( mTarget, @@ -354,7 +354,7 @@ void TextureRectangle::setImageData( const SharedTextureData &_data ) _data->getFormat(), _data->getType(), _data->getData() ); - openGLCriticalErrorOccured(); + openGLCriticalError(); } @@ -577,7 +577,7 @@ void TextureCubeMap::texImage2DCube( const SharedTextureData &_data, GLenum _cub _data->getFormat(), _data->getType(), _data->getData() ); - openGLRareErrorOccured(); + openGLRareError(); } void TextureCubeMap::texSubImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel, glm::ivec2 _offset ) @@ -591,7 +591,7 @@ void TextureCubeMap::texSubImage2DCube( const SharedTextureData &_data, GLenum _ _data->getFormat(), _data->getType(), _data->getData() ); - openGLRareErrorOccured(); + openGLRareError(); } @@ -610,7 +610,7 @@ void TextureBase::texImage1D( const SharedTextureData &_data, GLint _mipmapLevel _data->getFormat(), _data->getType(), _data->getData() ); - openGLRareErrorOccured(); + openGLRareError(); } void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLevel, uint32_t _offset ) @@ -626,7 +626,7 @@ void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLe _data->getFormat(), _data->getType(), _data->getData() ); - openGLRareErrorOccured(); + openGLRareError(); } void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel ) @@ -644,7 +644,7 @@ void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel _data->getFormat(), _data->getType(), _data->getData() ); - openGLRareErrorOccured(); + openGLRareError(); } void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset ) @@ -661,7 +661,7 @@ void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLe _data->getFormat(), _data->getType(), _data->getData() ); - openGLRareErrorOccured(); + openGLRareError(); } @@ -681,7 +681,7 @@ void TextureBase::texImage3D( const SharedTextureData &_data, GLint _mipmapLevel _data->getFormat(), _data->getType(), _data->getData() ); - openGLRareErrorOccured(); + openGLRareError(); } void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset ) @@ -699,7 +699,7 @@ void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLe _data->getFormat(), _data->getType(), _data->getData() ); - openGLRareErrorOccured(); + openGLRareError(); } diff --git a/src/ACGL/OpenGL/Objects/UniformBuffer.cc b/src/ACGL/OpenGL/Objects/UniformBuffer.cc index 7fa68e341924bcb8e35f6d1d449b6e4c57421f6c..54c5e65f258a37d3a346e255a1e6311bfeb9af22 100644 --- a/src/ACGL/OpenGL/Objects/UniformBuffer.cc +++ b/src/ACGL/OpenGL/Objects/UniformBuffer.cc @@ -14,6 +14,7 @@ using namespace ACGL::OpenGL; UniformBuffer::UniformBuffer( const ptr::shared_ptr<const ShaderProgram> &_shaderProgram, const std::string &_uboName ) : Buffer(GL_UNIFORM_BUFFER) { + mBlockName = _uboName; reserveMemory( _shaderProgram->getUniformBlockSize( _uboName ) ); setUniformOffsets( _shaderProgram->getUniformOffsetsOfBlock( _uboName ) ); // to enable intuitive setUniform functions bindBufferBase( _shaderProgram->getUniformBlockBinding( _uboName ) ); // bind the UBO to the binding point where the shader expects it diff --git a/src/ACGL/OpenGL/Tools.cc b/src/ACGL/OpenGL/Tools.cc index cf21fe18efb4b2773e47e15f58ebef597a404ac4..b9946ade1c2b039bbae4f0b627ff833f3eaccb49 100644 --- a/src/ACGL/OpenGL/Tools.cc +++ b/src/ACGL/OpenGL/Tools.cc @@ -51,6 +51,7 @@ uint32_t privateGetOpenGLVersion( int _type ) // NOTE: similar to GLEW we assume here, that the minor and major numbers // only have one digit. We also ignore release numbers. This will fail e.g. for OpenGL 10.0 const GLubyte* versionString; + openGLRareError(); // clear errors versionString = glGetString(GL_VERSION); if (openGLRareErrorOccured()) { ACGL::Utils::error() << "could not query OpenGL version!" << std::endl;