//[-------------------------------------------------------] //[ Public methods ] //[-------------------------------------------------------] TextureBufferDsa::TextureBufferDsa(OpenGLRenderer &openGLRenderer, uint32_t numberOfBytes, Renderer::TextureFormat::Enum textureFormat, const void *data, Renderer::BufferUsage bufferUsage) : TextureBuffer(openGLRenderer) { if (openGLRenderer.getExtensions().isGL_ARB_direct_state_access()) { { // Buffer part // Create the OpenGL texture buffer glCreateBuffers(1, &mOpenGLTextureBuffer); // Upload the data // -> Usage: These constants directly map to "GL_ARB_vertex_buffer_object" and OpenGL ES 2 constants, do not change them glNamedBufferData(mOpenGLTextureBuffer, static_cast<GLsizeiptr>(numberOfBytes), data, static_cast<GLenum>(bufferUsage)); } { // Texture part // Create the OpenGL texture instance glCreateTextures(GL_TEXTURE_BUFFER_ARB, 1, &mOpenGLTexture); // Attach the storage for the buffer object to the buffer texture glTextureBuffer(mOpenGLTexture, Mapping::getOpenGLInternalFormat(textureFormat), mOpenGLTextureBuffer); } } else { // Create the OpenGL texture buffer glGenBuffersARB(1, &mOpenGLTextureBuffer); // Create the OpenGL texture instance glGenTextures(1, &mOpenGLTexture); // Buffer part // -> Upload the data // -> Usage: These constants directly map to "GL_ARB_vertex_buffer_object" and OpenGL ES 2 constants, do not change them glNamedBufferDataEXT(mOpenGLTextureBuffer, static_cast<GLsizeiptr>(numberOfBytes), data, static_cast<GLenum>(bufferUsage)); { // Texture part #ifndef OPENGLRENDERER_NO_STATE_CLEANUP // Backup the currently bound OpenGL texture GLint openGLTextureBackup = 0; glGetIntegerv(GL_TEXTURE_BINDING_BUFFER_ARB, &openGLTextureBackup); #endif // Make this OpenGL texture instance to the currently used one glBindTexture(GL_TEXTURE_BUFFER_ARB, mOpenGLTexture); // Attaches the storage for the buffer object to the active buffer texture // -> Sadly, there's no direct state access (DSA) function defined for this in "GL_EXT_direct_state_access" glTexBufferARB(GL_TEXTURE_BUFFER_ARB, Mapping::getOpenGLInternalFormat(textureFormat), mOpenGLTextureBuffer); #ifndef OPENGLRENDERER_NO_STATE_CLEANUP // Be polite and restore the previous bound OpenGL texture glBindTexture(GL_TEXTURE_BUFFER_ARB, static_cast<GLuint>(openGLTextureBackup)); #endif } } }
void bind( InternalFormat internalformat, gl::NamedBuffer buffer ){ glTextureBuffer( texture_, GLenum(internalformat), GLuint(buffer) ); }
void BufferTexture::setBufferImplementationDSA(const BufferTextureFormat internalFormat, Buffer& buffer) { glTextureBuffer(id(), GLenum(internalFormat), buffer.id()); }