View Full Version : glTexBuffer()

09-28-2012, 01:16 AM
I want to use glTexBuffer() for the texturing. How to do this? Also which function will i have to use in shaders?

Alfonse Reinheart
09-28-2012, 07:29 AM
It works like this. (http://www.opengl.org/wiki/Buffer_Texture)

09-30-2012, 11:22 PM
It works like this. (http://www.opengl.org/wiki/Buffer_Texture)

Thank you so much Alfonse for your help..

Now there is one more problem. I am passing vec3 attribute array to vertex shader with z component as a index into pixel array of texture for each corresponding vertices.
GLfloat vertices[] =
-0.9f, -0.6f, 0.0f,
-0.9f, -0.9f, 1.0f,
-0.6f, -0.9f, 2.0f,
-0.6f, -0.6f, 3.0f
Here z component is index into GLfloat pixels[]={0.0f,1.0f,0.0f,1.0f, 0.0f,0.0f,1.0f,1.0f, 1.0f,1.0f,1.0f,1.0f, 1.0f,0.0f,1.0f,1.0f}; My texture is of RGBA type.
Now in vertex shader:
out int index=int(a_position.z);

and fragment shader:
vec4 offset=texelFetch(out_offset,index);
Color = offset;
Now i am drawing GL_Traingle_fan and when i execute it, it draws square with 2 triangles one with white color and second with pink color. It is taking 3rd and 4th offset in pixel array instead taking each index for each vertex.

I want to draw square with each vertex having color of each index in pixels array. Please correct me where i am going wrong above..