Reputation: 16345
If I use a glTexImage2D
call to create a texture with a buffer like this:
glTexImage2D(GL_TEXTURE_2D /* target*/,
0 /* level */,
GL_RGBA /* internal format */,
width /* w */,
height /* h */,
0 /* border */,
GL_RGBA /* format (RGBA 4)*/,
GL_UNSIGNED_BYTE /* type */,
buffer /* pixel buffer */);
Can I modify the buffer and expect the texture to change with it?
Or is the texture finalized after the call?
Upvotes: 1
Views: 408
Reputation: 6535
If you want to change a portion of the texture, you'll often use glTexSubImage2D
. Note that this function expects the new data to be contiguous; so if you've only changed a small square in the middle of your texture, it's not the best idea to make the change in your original buffer because then you'd have to send all of the pixels for the rows you've changed instead of just the affected columns.
Upvotes: 2
Reputation: 36567
No, OpenGL will create it's own copy of the texture so you can't modify it without copying it back and forth (but this also means you're able to reuse or free the buffer.
Upvotes: 6