jeudi 6 mars 2014

OpenGL texture1D


Vote count:

0




I'm trying to read from a fragment shader a texture1d:



uniform sampler1D world;


...



texelFetch(world, 0, 0);


I upload w, where w[0]=123.0f w[1]=123.0f...:



glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &pt->world);
glBindTexture(GL_TEXTURE_1D, pt->world);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 2, 0, GL_RGBA, GL_FLOAT, &w);


Binding:



glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_1D, pt->world);
glUniform1i(glbPTworld, 0);


However, the fragment shader read vec4(0,0,0,1) instead of vec4(123,123,123,123) when I use a width in glTexImage1D different from one. Also, if I use:



glGetTexImage(GL_TEXTURE_1D, 0, GL_RGBA, GL_FLOAT, x);


To get the texture back I see the expected values.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire