Commit 1b5d5de4 authored by Robert Menzel's avatar Robert Menzel

better mac compatibility and removed warnings

parent 580fc9c6
...@@ -182,6 +182,8 @@ ...@@ -182,6 +182,8 @@
#else #else
// use the internal loader: // use the internal loader:
#define ACGL_EXTENSION_LOADER_GLLOADGEN #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. // Include the right header which has just what is needed to catch compatibility problems at compiletime.
......
...@@ -126,11 +126,11 @@ public: ...@@ -126,11 +126,11 @@ public:
inline GLuint getUniformBlockIndex (const std::string& _nameInShader) const { return glGetUniformBlockIndex(mObjectName, _nameInShader.c_str()); } 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 //! 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 { inline void setUniformBlockBinding( const std::string& _blockName, GLuint _bindingPoint ) const {
GLuint blockIndex = getUniformBlockIndex(_blockName); GLuint blockIndex = getUniformBlockIndex(_blockName);
if (blockIndex != GL_INVALID_INDEX) glUniformBlockBinding( mObjectName, blockIndex, _bindingPoint ); if (blockIndex != GL_INVALID_INDEX) glUniformBlockBinding( mObjectName, blockIndex, _bindingPoint );
openGLCommonErrorOccured(); openGLCommonError();
} }
GLint getUniformBlockBinding( const std::string& _blockName ) const { return getUniformBlockBinding( getUniformBlockIndex(_blockName)); } GLint getUniformBlockBinding( const std::string& _blockName ) const { return getUniformBlockBinding( getUniformBlockIndex(_blockName)); }
......
...@@ -105,6 +105,11 @@ public: ...@@ -105,6 +105,11 @@ public:
template <typename T> template <typename T>
void setUniform (const std::string &_nameInShader, T _v) { void setUniform (const std::string &_nameInShader, T _v) {
GLint offset = getUniformOffset( _nameInShader ); 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) { if (offset == -1) {
ACGL::Utils::error() << "UniformBuffer does not know uniform " << _nameInShader << std::endl; ACGL::Utils::error() << "UniformBuffer does not know uniform " << _nameInShader << std::endl;
return; return;
...@@ -120,6 +125,11 @@ private: ...@@ -120,6 +125,11 @@ private:
template <typename T> template <typename T>
void setUniformScalar (const std::string &_nameInShader, T _v) { void setUniformScalar (const std::string &_nameInShader, T _v) {
GLint offset = getUniformOffset( _nameInShader ); 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) { if (offset == -1) {
ACGL::Utils::error() << "UniformBuffer does not know uniform " << _nameInShader << std::endl; ACGL::Utils::error() << "UniformBuffer does not know uniform " << _nameInShader << std::endl;
return; return;
...@@ -128,6 +138,9 @@ private: ...@@ -128,6 +138,9 @@ private:
} }
SharedLocationMappings uniformNameToOffsetMap; SharedLocationMappings uniformNameToOffsetMap;
public: // for mac bug
std::string mBlockName;
}; };
ACGL_SMARTPOINTER_TYPEDEFS(UniformBuffer) ACGL_SMARTPOINTER_TYPEDEFS(UniformBuffer)
......
...@@ -23,7 +23,8 @@ using namespace ACGL::Base; ...@@ -23,7 +23,8 @@ using namespace ACGL::Base;
bool GeometryDataControlFileOBJ::load(SharedGeometryData& geometry) const bool GeometryDataControlFileOBJ::load(SharedGeometryData& geometry) const
{ {
if(geometry = loadGeometryDataFromOBJ(getFullFilePath())) geometry = loadGeometryDataFromOBJ(getFullFilePath());
if (geometry)
return true; return true;
else else
return false; return false;
......
...@@ -92,7 +92,7 @@ SharedShaderProgram ShaderProgramControlFiles::create(void) ...@@ -92,7 +92,7 @@ SharedShaderProgram ShaderProgramControlFiles::create(void)
if (!setBindings( shaderProgram )) { if (!setBindings( shaderProgram )) {
return SharedShaderProgram(); // e.g. linking failed return SharedShaderProgram(); // e.g. linking failed
} }
openGLCommonErrorOccured(); openGLCommonError();
updateFileModificationTimes(); updateFileModificationTimes();
return shaderProgram; return shaderProgram;
} }
...@@ -100,18 +100,18 @@ SharedShaderProgram ShaderProgramControlFiles::create(void) ...@@ -100,18 +100,18 @@ SharedShaderProgram ShaderProgramControlFiles::create(void)
// will get called from the create and update functions: // will get called from the create and update functions:
bool ShaderProgramControlFiles::setBindings(SharedShaderProgram &_shaderProgram) bool ShaderProgramControlFiles::setBindings(SharedShaderProgram &_shaderProgram)
{ {
openGLRareErrorOccured(); openGLRareError();
_shaderProgram->link(); _shaderProgram->link();
# if (ACGL_OPENGL_VERSION >= 30) # if (ACGL_OPENGL_VERSION >= 30)
_shaderProgram->setFragmentDataLocations( mFragmentDataLocations ); // might relink on it's own _shaderProgram->setFragmentDataLocations( mFragmentDataLocations ); // might relink on it's own
openGLRareErrorOccured(); openGLRareError();
SharedLocationMappings oldAttributeMap = _shaderProgram->getAttributeLocations(); SharedLocationMappings oldAttributeMap = _shaderProgram->getAttributeLocations();
mAttributeLocations->addLocations( oldAttributeMap ); // add as many old locations as possible without destoying the location map mAttributeLocations->addLocations( oldAttributeMap ); // add as many old locations as possible without destoying the location map
_shaderProgram->setAttributeLocations( mAttributeLocations ); // might relink on it's own _shaderProgram->setAttributeLocations( mAttributeLocations ); // might relink on it's own
openGLRareErrorOccured(); openGLRareError();
# else # else
if ( (mAttributeLocations->getSize() > 0) && (mFragmentDataLocations->getSize() > 0) ) { if ( (mAttributeLocations->getSize() > 0) && (mFragmentDataLocations->getSize() > 0) ) {
Utils::error() << "can't set explicit attribute/fragdata locations on OpenGL < 3.0" << std::endl; Utils::error() << "can't set explicit attribute/fragdata locations on OpenGL < 3.0" << std::endl;
......
...@@ -343,7 +343,7 @@ void TextureRectangle::setImageData( const SharedTextureData &_data ) ...@@ -343,7 +343,7 @@ void TextureRectangle::setImageData( const SharedTextureData &_data )
mWidth = _data->getWidth(); mWidth = _data->getWidth();
mHeight = _data->getHeight(); mHeight = _data->getHeight();
openGLCriticalErrorOccured(); openGLCriticalError();
bind(); bind();
glTexImage2D( glTexImage2D(
mTarget, mTarget,
...@@ -354,7 +354,7 @@ void TextureRectangle::setImageData( const SharedTextureData &_data ) ...@@ -354,7 +354,7 @@ void TextureRectangle::setImageData( const SharedTextureData &_data )
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLCriticalErrorOccured(); openGLCriticalError();
} }
...@@ -577,7 +577,7 @@ void TextureCubeMap::texImage2DCube( const SharedTextureData &_data, GLenum _cub ...@@ -577,7 +577,7 @@ void TextureCubeMap::texImage2DCube( const SharedTextureData &_data, GLenum _cub
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLRareErrorOccured(); openGLRareError();
} }
void TextureCubeMap::texSubImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel, glm::ivec2 _offset ) void TextureCubeMap::texSubImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel, glm::ivec2 _offset )
...@@ -591,7 +591,7 @@ void TextureCubeMap::texSubImage2DCube( const SharedTextureData &_data, GLenum _ ...@@ -591,7 +591,7 @@ void TextureCubeMap::texSubImage2DCube( const SharedTextureData &_data, GLenum _
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLRareErrorOccured(); openGLRareError();
} }
...@@ -610,7 +610,7 @@ void TextureBase::texImage1D( const SharedTextureData &_data, GLint _mipmapLevel ...@@ -610,7 +610,7 @@ void TextureBase::texImage1D( const SharedTextureData &_data, GLint _mipmapLevel
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLRareErrorOccured(); openGLRareError();
} }
void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLevel, uint32_t _offset ) void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLevel, uint32_t _offset )
...@@ -626,7 +626,7 @@ void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLe ...@@ -626,7 +626,7 @@ void TextureBase::texSubImage1D( const SharedTextureData &_data, GLint _mipmapLe
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLRareErrorOccured(); openGLRareError();
} }
void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel ) void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel )
...@@ -644,7 +644,7 @@ void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel ...@@ -644,7 +644,7 @@ void TextureBase::texImage2D( const SharedTextureData &_data, GLint _mipmapLevel
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLRareErrorOccured(); openGLRareError();
} }
void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset ) void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset )
...@@ -661,7 +661,7 @@ void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLe ...@@ -661,7 +661,7 @@ void TextureBase::texSubImage2D( const SharedTextureData &_data, GLint _mipmapLe
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLRareErrorOccured(); openGLRareError();
} }
...@@ -681,7 +681,7 @@ void TextureBase::texImage3D( const SharedTextureData &_data, GLint _mipmapLevel ...@@ -681,7 +681,7 @@ void TextureBase::texImage3D( const SharedTextureData &_data, GLint _mipmapLevel
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLRareErrorOccured(); openGLRareError();
} }
void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset ) void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset )
...@@ -699,7 +699,7 @@ void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLe ...@@ -699,7 +699,7 @@ void TextureBase::texSubImage3D( const SharedTextureData &_data, GLint _mipmapLe
_data->getFormat(), _data->getFormat(),
_data->getType(), _data->getType(),
_data->getData() ); _data->getData() );
openGLRareErrorOccured(); openGLRareError();
} }
......
...@@ -14,6 +14,7 @@ using namespace ACGL::OpenGL; ...@@ -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) UniformBuffer::UniformBuffer( const ptr::shared_ptr<const ShaderProgram> &_shaderProgram, const std::string &_uboName ) : Buffer(GL_UNIFORM_BUFFER)
{ {
mBlockName = _uboName;
reserveMemory( _shaderProgram->getUniformBlockSize( _uboName ) ); reserveMemory( _shaderProgram->getUniformBlockSize( _uboName ) );
setUniformOffsets( _shaderProgram->getUniformOffsetsOfBlock( _uboName ) ); // to enable intuitive setUniform functions 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 bindBufferBase( _shaderProgram->getUniformBlockBinding( _uboName ) ); // bind the UBO to the binding point where the shader expects it
......
...@@ -51,6 +51,7 @@ uint32_t privateGetOpenGLVersion( int _type ) ...@@ -51,6 +51,7 @@ uint32_t privateGetOpenGLVersion( int _type )
// NOTE: similar to GLEW we assume here, that the minor and major numbers // 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 // only have one digit. We also ignore release numbers. This will fail e.g. for OpenGL 10.0
const GLubyte* versionString; const GLubyte* versionString;
openGLRareError(); // clear errors
versionString = glGetString(GL_VERSION); versionString = glGetString(GL_VERSION);
if (openGLRareErrorOccured()) { if (openGLRareErrorOccured()) {
ACGL::Utils::error() << "could not query OpenGL version!" << std::endl; ACGL::Utils::error() << "could not query OpenGL version!" << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment