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

better mac compatibility and removed warnings

parent 580fc9c6
......@@ -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.
......
......@@ -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)); }
......
......@@ -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)
......
......@@ -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;
......
......@@ -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;
......
......@@ -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();
}
......
......@@ -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
......
......@@ -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;
......
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