Commit 77fdffe3 authored by Robert Menzel's avatar Robert Menzel

Merge branch 'experimental' of...

Merge branch 'experimental' of ssh://beatrix.informatik.rwth-aachen.de/data/git-repository/acgl/libraries/acgl into experimental
parents c33c6cc1 b7a3e826
......@@ -22,16 +22,16 @@ namespace OpenGL{
class GeometryDataControlFileATB;
class GeometryDataControlFileOBJ : public ACGL::OpenGL::GeometryDataControlFile
class GeometryDataControlFileMesh : public ACGL::OpenGL::GeometryDataControlFile
{
friend void initStaticFileTypes(void);
friend class GeometryDataControlFileATB;
public:
GeometryDataControlFileOBJ(const std::string& _filename) : GeometryDataControlFile(_filename,Base::Settings::the()->getFullGeometryPath()) {}
virtual ~GeometryDataControlFileOBJ(void) {}
GeometryDataControlFileMesh(const std::string& _filename) : GeometryDataControlFile(_filename,Base::Settings::the()->getFullGeometryPath()) {}
virtual ~GeometryDataControlFileMesh(void) {}
// the entry point that gets registered in registerType()
static SharedGeometryDataControlFile creator(const std::string& _filename) { return SharedGeometryDataControlFile(new GeometryDataControlFileOBJ(_filename)); }
static SharedGeometryDataControlFile creator(const std::string& _filename) { return SharedGeometryDataControlFile(new GeometryDataControlFileMesh(_filename)); }
private:
virtual bool load(SharedGeometryData& geometry) const;
......@@ -39,13 +39,14 @@ private:
// register the file extension 'obj' for this loader
static ACGL::int_t registerType(void)
{
sTypeID = GeometryDataControlFileFactory::the()->registerType("obj", &GeometryDataControlFileOBJ::creator);
sTypeID = GeometryDataControlFileFactory::the()->registerType("obj", &GeometryDataControlFileMesh::creator);
sTypeID = GeometryDataControlFileFactory::the()->registerType("vap", &GeometryDataControlFileMesh::creator);
return sTypeID;
}
};
ACGL_SMARTPOINTER_TYPEDEFS(GeometryDataControlFileOBJ)
ACGL_SMARTPOINTER_TYPEDEFS(GeometryDataControlFileMesh)
} // OpenGL
} // ACGL
......
......@@ -177,6 +177,11 @@ public:
//! Generate mipmaps from the current base texture (i.e. the texture from level 0)
void generateMipmaps(void);
void resize(const glm::uvec3& _size) { resizeI(glm::uvec3(_size.x, _size.y, _size.z)); }
void resize(const glm::uvec2& _size) { resizeI(glm::uvec3(_size.x, _size.y, 1 )); }
void resize(const glm::uvec1& _size) { resizeI(glm::uvec3(_size.x, 1, 1 )); }
void resize( GLuint _size) { resizeI(glm::uvec3(_size, 1, 1 )); }
#ifndef ACGL_OPENGLES_VERSION_20
//! get one texture image:
TextureData *getTextureImageRAW( const Image &_image = Image(), GLenum _format = GL_RGBA, GLenum _type = GL_UNSIGNED_BYTE ) const;
......@@ -229,6 +234,9 @@ protected:
{
return (mWidth != 0);
}
//! Resizes the texture. Subclasses implementing this method may use only use the first entries of _size if they are of lower dimension
virtual void resizeI(const glm::uvec3& _size) = 0;
};
ACGL_SMARTPOINTER_TYPEDEFS(TextureBase)
......@@ -268,9 +276,10 @@ public:
//! sets the content to the given TextureData, might resize the texture
void setImageData( const SharedTextureData &_data );
protected:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec2 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
private:
void generateMipmaps(void) { ACGL::Utils::error() << "Rectangle Textures don't support MipMaps!" << std::endl; }
......@@ -296,9 +305,10 @@ public:
//! sets the content to the given TextureData, might resize the texture
void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
protected:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const uint32_t _newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture1D)
......@@ -318,9 +328,10 @@ public:
//! sets the content to the given TextureData, might resize the texture
void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
protected:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec2 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture2D)
......@@ -344,9 +355,10 @@ public:
//! sets the content of all slices to the given TextureData
void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
protected:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec3 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture3D)
......@@ -369,9 +381,10 @@ public:
//! sets the content to the given TextureData to fill all layers
void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
protected:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec2 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture1DArray)
......@@ -395,9 +408,10 @@ public:
//! sets the content to the given TextureData, might resize the texture
void setImageData( const SharedTextureData &_data, uint32_t _arrayLayer = 0, uint32_t _mipmapLayer = 0 );
protected:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec3 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
};
ACGL_SMARTPOINTER_TYPEDEFS(Texture2DArray)
......@@ -417,9 +431,10 @@ public:
//! sets the content to the given TextureData, might resize the texture
void setImageData( const SharedTextureData &_data, GLenum _cubeSide, uint32_t _mipmapLayer = 0 );
protected:
//! content of the texture is undefined after this, this texture will be bound to the active binding point
//! nothing should be bound to the pixel unpack buffer when calling this
void resize( const glm::uvec2 &_newSize );
void resizeI( const glm::uvec3 &_newSize );
private:
bool cubeSideIsValid( const GLenum _cubeSide ) const;
......
......@@ -326,7 +326,7 @@ public:
glMultiDrawElements( mMode, count, type, indices, primcount );
}
#if (ACGL_OPENGL_VERSION >= 31)
#if (ACGL_OPENGL_VERSION >= 32)
inline void multiDrawElements( GLsizei *count, GLenum type, GLvoid **indices, GLsizei primcount, GLint *basevertex ) const
{
glMultiDrawElementsBaseVertex( mMode, count, type, indices, primcount, basevertex );
......
......@@ -397,6 +397,8 @@ class GenericCamera
glm::uvec2 mViewportSize;
};
ACGL_SMARTPOINTER_TYPEDEFS(GenericCamera)
} // Scene
} // ACGL
......@@ -21,9 +21,9 @@ using namespace ACGL::OpenGL;
using namespace ACGL::Utils;
using namespace ACGL::Base;
bool GeometryDataControlFileOBJ::load(SharedGeometryData& geometry) const
bool GeometryDataControlFileMesh::load(SharedGeometryData& geometry) const
{
geometry = loadGeometryDataFromOBJ(getFullFilePath());
geometry = loadGeometryData(getFullFilePath());
if (geometry)
return true;
else
......
......@@ -174,6 +174,7 @@ SharedTextureData loadTextureDataFromLodepng(const std::string &_filename)
if(colorType == LCT_GREY_ALPHA) { channels = 2; glFormat = GL_RG; }
if(colorType == LCT_RGB) { channels = 3; glFormat = GL_RGB; }
if(colorType == LCT_RGBA) { channels = 4; glFormat = GL_RGBA; }
if(colorType == LCT_PALETTE) { channels = 4; glFormat = GL_RGBA; colorType = LCT_RGBA; } // force LodePNG to convert paletted data to RGBA
GLenum glType = 0;
if(bitdepth == 8) glType = GL_UNSIGNED_BYTE;
......
......@@ -30,7 +30,7 @@ void ACGL::OpenGL::initStaticFileTypes(void)
//
// Geometry, Meshes, Vertex data
//
GeometryDataControlFileOBJ::registerType();
GeometryDataControlFileMesh::registerType();
GeometryDataControlFileATB::registerType();
}
......@@ -172,14 +172,18 @@ GLuint TextureBase::bindAndGetOldTexture() const
else if(mTarget == GL_TEXTURE_3D) glGetIntegerv(GL_TEXTURE_BINDING_3D, &prevTexture);
else if(mTarget == GL_TEXTURE_1D_ARRAY) glGetIntegerv(GL_TEXTURE_BINDING_1D_ARRAY, &prevTexture);
else if(mTarget == GL_TEXTURE_2D_ARRAY) glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &prevTexture);
else if(mTarget == GL_TEXTURE_CUBE_MAP) glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &prevTexture);
#if (ACGL_OPENGL_VERSION >= 31)
else if(mTarget == GL_TEXTURE_RECTANGLE) glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE, &prevTexture);
#if (ACGL_OPENGL_VERSION >= 32)
else if(mTarget == GL_TEXTURE_2D_MULTISAMPLE) glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE, &prevTexture);
else if(mTarget == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) glGetIntegerv(GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY, &prevTexture);
else if(mTarget == GL_TEXTURE_CUBE_MAP) glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &prevTexture);
#if (ACGL_OPENGL_VERSION >= 40)
else if(mTarget == GL_TEXTURE_CUBE_MAP_ARRAY) glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &prevTexture);
#endif
#endif // 4.0
else if(mTarget == GL_TEXTURE_BUFFER) glGetIntegerv(GL_TEXTURE_BINDING_BUFFER, &prevTexture);
#endif // 3.2
#endif // 3.1
else {
ACGL::Utils::error() << "Unknown texture target, will create sideeffecs as old bound texture can not get restored!" << std::endl;
}
......@@ -325,7 +329,7 @@ TextureData *TextureBase::getTextureImageRAW( const Image &_image, GLenum _forma
#endif // ES 2
void TextureRectangle::resize( const glm::uvec2 &_newSize )
void TextureRectangle::resizeI(const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight) {
SharedTextureData sTexData( new TextureData() );
......@@ -367,12 +371,12 @@ void Texture1D::setImageData( const SharedTextureData &_data, uint32_t _mipmapLa
}
}
void Texture1D::resize( const uint32_t _newSize )
void Texture1D::resizeI(const glm::uvec3 &_newSize )
{
if (_newSize != (unsigned int)mWidth) {
if (_newSize.x != (unsigned int)mWidth) {
SharedTextureData sTexData( new TextureData() );
sTexData->setData (NULL);
sTexData->setWidth (_newSize);
sTexData->setWidth (_newSize.x);
sTexData->setFormat(getCompatibleFormat( mInternalFormat ));
sTexData->setType (getCompatibleType( mInternalFormat ));
......@@ -390,7 +394,7 @@ void Texture2D::setImageData( const SharedTextureData &_data, uint32_t _mipmapLa
}
}
void Texture2D::resize( const glm::uvec2 &_newSize )
void Texture2D::resizeI( const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight) {
SharedTextureData sTexData( new TextureData() );
......@@ -430,7 +434,7 @@ void Texture3D::setImageData( const SharedTextureData &_data, uint32_t _mipmapLa
texSubImage3D( _data, _mipmapLayer, offset );
}
void Texture3D::resize( const glm::uvec3 &_newSize )
void Texture3D::resizeI( const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight || _newSize.z != (unsigned int)mDepth) {
SharedTextureData sTexData( new TextureData() );
......@@ -475,7 +479,7 @@ void Texture1DArray::setImageData( const SharedTextureData &_data, uint32_t _mip
texSubImage2D( _data, _mipmapLayer );
}
void Texture1DArray::resize( const glm::uvec2 &_newSize )
void Texture1DArray::resizeI(const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight) {
SharedTextureData sTexData( new TextureData() );
......@@ -502,7 +506,7 @@ void Texture2DArray::setImageData( const SharedTextureData &_data, uint32_t _arr
}
}
void Texture2DArray::resize( const glm::uvec3 &_newSize )
void Texture2DArray::resizeI( const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight || _newSize.z != (unsigned int)mDepth) {
SharedTextureData sTexData( new TextureData() );
......@@ -535,7 +539,7 @@ void TextureCubeMap::setImageData( const SharedTextureData &_data, GLenum _cubeS
//}
}
void TextureCubeMap::resize( const glm::uvec2 &_newSize )
void TextureCubeMap::resizeI(const glm::uvec3 &_newSize )
{
if (_newSize.x != (unsigned int)mWidth || _newSize.y != (unsigned int)mHeight) {
SharedTextureData sTexData( new TextureData() );
......
......@@ -229,6 +229,9 @@ void VertexArrayObject::setAttributePointer( GLuint _index )
}
#if (ACGL_OPENGL_VERSION >= 33)
glVertexAttribDivisor( _index, arrayBufferAttribute.divisor );
#else
if(arrayBufferAttribute.divisor > 0)
warning() << "Attribute divisors are not supported in OpenGL < 3.3" << std::endl;
#endif
glEnableVertexAttribArray(_index);
}
......
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