Commit 7b40da95 authored by Robert Menzel's avatar Robert Menzel

cleanups and additional TextureBuffer constructor

parent e703e047
......@@ -46,8 +46,24 @@ public:
glDeleteTextures(1, &mObjectName);
}
inline GLuint getObjectName () const { return mObjectName; }
inline GLenum getTarget () const { return mTarget; }
GLuint getObjectName () const { return mObjectName; }
GLenum getTarget () const { return mTarget; }
GLsizei getWidth () const;
GLsizei getHeight () const;
GLsizei getDepth () const;
glm::uvec3 getSize () const { return glm::uvec3( getWidth(), getHeight(), getDepth() ); }
GLenum getInternalFormat () const;
GLenum getFormat () const;
GLenum getType () const;
GLint getMinFilter () const;
GLint getMagFilter () const;
#ifndef ACGL_OPENGLES_VERSION_20
GLenum getWrapS () const;
GLenum getWrapT () const;
GLenum getWrapR () const;
#endif // ACGL_OPENGLES_VERSION_20
//! Activate texture unit and bind this texture.
void bind(GLuint _textureUnit = 0) const
......@@ -78,7 +94,7 @@ ACGL_SMARTPOINTER_TYPEDEFS(TextureNG)
class TextureBuffer : public Buffer
{
public:
// _reservedMemory is counted in bytes
// create a new BufferObject with _reservedMemory space (in bytes!)
TextureBuffer( GLenum _dataType, size_t _reservedMemory = 1 ) : Buffer(GL_TEXTURE_BUFFER) {
glGenTextures(1, &mTextureObjectName);
if (openGLCriticalErrorOccured() ) {
......@@ -89,6 +105,21 @@ public:
attachBufferToTexture();
}
// use an existing BufferObject
TextureBuffer( GLenum _dataType, SharedBufferObject _pBuffer ) : Buffer(_pBuffer, GL_TEXTURE_BUFFER) {
glGenTextures(1, &mTextureObjectName);
if (openGLCriticalErrorOccured() ) {
ACGL::Utils::error() << "could not generate texture object for texture buffer!" << std::endl;
}
mDataType = _dataType;
attachBufferToTexture();
}
~TextureBuffer() {
setBufferObject( SharedBufferObject() ); // detach the Buffer
glDeleteTextures(1, &mTextureObjectName);
}
//! the GL buffer can get changed at any time
void setBufferObject( SharedBufferObject _pBuffer ) {
Buffer::setBufferObject( _pBuffer );
......@@ -100,17 +131,14 @@ public:
}
}
~TextureBuffer() {
setBufferObject( SharedBufferObject() ); // detach the Buffer
glDeleteTextures(1, &mTextureObjectName);
}
//! Bind the texture part to access it from a shader
void bindTexture(GLuint _textureUnit = 0) const {
glActiveTexture(GL_TEXTURE0 + _textureUnit);
glBindTexture(GL_TEXTURE_BUFFER, mTextureObjectName);
openGLRareError();
}
//! Bind the buffer part to change the data
void bindBuffer() const {
Buffer::bind();
}
......
......@@ -95,8 +95,8 @@ bool doesSupportTessellationShader();
bool doesSupportComputeShader();
// define the shader kinds for older GL versions so the file extension detection
// can work correctly
// Define the shader kinds for older and embedded GL versions so the file extension detection
// can work correctly.
#ifndef GL_GEOMETRY_SHADER
#define GL_GEOMETRY_SHADER 0x8DD9
#endif
......
......@@ -9,7 +9,6 @@
using namespace ACGL::OpenGL;
#ifndef ACGL_OPENGLES_VERSION_20
void Texture::setWrapS( GLenum _wrapS )
{
......
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