PDA

View Full Version : The problem with Buffer Texture



LangFox
01-29-2010, 11:42 PM
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_BUFFER, texture);
glTexBuffer(GL_TEXTURE_BUFFER, internalformat, buffer);
//glBindTexture(GL_TEXTURE_BUFFER, 0);


Hi, guys

The code to create a buffer texture works fine for now. But if I uncomment the last line, there is no data displayed. Is that a right thing?

Alfonse Reinheart
01-30-2010, 12:09 AM
Is that a right thing?

Yes. A texture must be bound to the context in order to be used. If you unbind it (by binding a different texture to that target and texture unit), then you have to bind it again before you can use it.

LangFox
01-30-2010, 02:42 AM
Oh, it's my fault that mislead you. The full process is like this:



void Create()
{
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_BUFFER, texture);
glTexBuffer(GL_TEXTURE_BUFFER, internalformat, buffer);
//glBindTexture(GL_TEXTURE_BUFFER, 0);
}

void Display()
{
glActiveTexture(GL_Texture0);
glBindTexture(GL_TEXTURE_BUFFER, texture);
// Use shader to render data.
...
}


While in Create(), if I unbind the buffer texture after glTexBuffer, there is no data displayed. It's so weird.