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

cleanups and additional TextureBuffer constructor

parent e703e047
...@@ -46,8 +46,24 @@ public: ...@@ -46,8 +46,24 @@ public:
glDeleteTextures(1, &mObjectName); glDeleteTextures(1, &mObjectName);
} }
inline GLuint getObjectName () const { return mObjectName; } GLuint getObjectName () const { return mObjectName; }
inline GLenum getTarget () const { return mTarget; } 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. //! Activate texture unit and bind this texture.
void bind(GLuint _textureUnit = 0) const void bind(GLuint _textureUnit = 0) const
...@@ -78,7 +94,7 @@ ACGL_SMARTPOINTER_TYPEDEFS(TextureNG) ...@@ -78,7 +94,7 @@ ACGL_SMARTPOINTER_TYPEDEFS(TextureNG)
class TextureBuffer : public Buffer class TextureBuffer : public Buffer
{ {
public: 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) { TextureBuffer( GLenum _dataType, size_t _reservedMemory = 1 ) : Buffer(GL_TEXTURE_BUFFER) {
glGenTextures(1, &mTextureObjectName); glGenTextures(1, &mTextureObjectName);
if (openGLCriticalErrorOccured() ) { if (openGLCriticalErrorOccured() ) {
...@@ -89,6 +105,21 @@ public: ...@@ -89,6 +105,21 @@ public:
attachBufferToTexture(); 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 //! the GL buffer can get changed at any time
void setBufferObject( SharedBufferObject _pBuffer ) { void setBufferObject( SharedBufferObject _pBuffer ) {
Buffer::setBufferObject( _pBuffer ); Buffer::setBufferObject( _pBuffer );
...@@ -100,17 +131,14 @@ public: ...@@ -100,17 +131,14 @@ public:
} }
} }
~TextureBuffer() { //! Bind the texture part to access it from a shader
setBufferObject( SharedBufferObject() ); // detach the Buffer
glDeleteTextures(1, &mTextureObjectName);
}
void bindTexture(GLuint _textureUnit = 0) const { void bindTexture(GLuint _textureUnit = 0) const {
glActiveTexture(GL_TEXTURE0 + _textureUnit); glActiveTexture(GL_TEXTURE0 + _textureUnit);
glBindTexture(GL_TEXTURE_BUFFER, mTextureObjectName); glBindTexture(GL_TEXTURE_BUFFER, mTextureObjectName);
openGLRareError(); openGLRareError();
} }
//! Bind the buffer part to change the data
void bindBuffer() const { void bindBuffer() const {
Buffer::bind(); Buffer::bind();
} }
......
...@@ -95,8 +95,8 @@ bool doesSupportTessellationShader(); ...@@ -95,8 +95,8 @@ bool doesSupportTessellationShader();
bool doesSupportComputeShader(); bool doesSupportComputeShader();
// define the shader kinds for older GL versions so the file extension detection // Define the shader kinds for older and embedded GL versions so the file extension detection
// can work correctly // can work correctly.
#ifndef GL_GEOMETRY_SHADER #ifndef GL_GEOMETRY_SHADER
#define GL_GEOMETRY_SHADER 0x8DD9 #define GL_GEOMETRY_SHADER 0x8DD9
#endif #endif
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
using namespace ACGL::OpenGL; using namespace ACGL::OpenGL;
#ifndef ACGL_OPENGLES_VERSION_20 #ifndef ACGL_OPENGLES_VERSION_20
void Texture::setWrapS( GLenum _wrapS ) 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