Reputation: 18228
I'm using a simple 1D texture to pass a dynamically array of values to my pixel shader. I want to be able to update these array values (as well as the size of the array) from time to time. Currently, I'm using the sequence
glBindTexture(GL_TEXTURE_1D, myTexture);
glTexImage1D(GL_TEXTURE_1D, 0, GL_R32F, arraySize, 0, GL_RED, GL_FLOAT, array);
for that. While this works fine at initialization, executing these lines during rendering (on keyboard input) yields GL_INVALID_OPERATION
after glTexImage1D
.
So, do I need to deactivate or unbind the texture before updating it?
Upvotes: 0
Views: 362
Reputation: 18228
I finally found the error cause. Since I've updated the texture data on keyboard input, the corresponding code was executed from another thread (different from the main rendering thread).
The solution is to store this action in a queue which can be accessed and executed by the main rendering thread.
Upvotes: 0
Reputation: 29240
Actually the texture must be bound in order to update it, otherwise how does OpenGL know what texture to update (notice that the texture ID isn't used anywhere in the glTexImage* functions)?
If you're getting GL_INVALID_OPERATION at some point after calling that function, it could be something else which is triggering the error. I would start adding glGetError() methods to your code until you find the exact function that is causing the error.
Upvotes: 4