Manual modification of texture pixel data.

Started by
0 comments, last by V-man 15 years, 10 months ago
Hello. First off, let me say im a beginner with OpenGL. What im trying to do is to render to target texture, then modify its pixels. From what i gather, for rendering to texture i need to use frame buffer object, and for texture modification - pixel buffer object. To be honest, im overwhelmed by all the information i need to gather and understand, wish there was some kind of tutorial for all this, but i guess ill manage. What im really confused about is how to use PBO for modifying textures. The only reference ive found so far is this: http://www.songho.ca/opengl/gl_pbo.html#unpack What i dont understand is how to copy pixels from texture to buffer, and how to actually modify said pixels while theyre in PBO. Im also not sure how to copy pixel data from buffer to texture. Am i right thinking that i just need to use glTexSubImage2D, using pointer to the target of PBO from glBindBufferARB for const GLvoid *pixels parameter?
Advertisement
FBO based render to texture can be used if you will be using GL commands to render.
If you want to update the texture yourself, use glTexSubImage2D which is a sync operation.
PBO just helps to make that into a async operation so glTexSubImage2D returns immediately without the texture being updated. Sometime in the future, it gets updated.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement