I’m not entirely sure if I’m doing everything correct…
All I want is to load a texture using GLSL and apply it on a surface of points. Shouldn’t be too difficult right?
This is what I have:
Assume I’ve used genTextures on buffers beforehand, that the shaders have been compiled properly, and the loadBitmap method has been tested and works fine.
The result I get is the texture does not render, instead it turns out all white. Have I missed something out?
Have you actually enabled the shader for use again after compiling etc.?
It’s needs to be active and enabled when you bind the Uniform and the texture.
Other than that it looks ok to me.
And perhaps other sampler states such as:
GL_TEXTURE_MAG_FILTER
GL_TEXTURE_WRAP_S
GL_TEXTURE_WRAP_T
(I think these have default values that work though)
Check the following:
-glGetError() after each line: there is probably error somewhere
-activation of a shader before drawing
-have the shaders linked properly
-‘my_sampler_uniform_location’ is a valid uniform ID
-passing correct vertex attributes: position & texcoord
-setting correct matrices: modelview & projection
-clear color & depth, depth check & write
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); <- no difference
glGetError(); <- no errors
shaders work properly. I can for e.g. have gl_FragColor = vec4(0,1,0) and my “terrain” will turn green. This means - shaders have been activated, & shaders are linked properly.
my_sampler_uniform_location <- from my code in the first post, does it look right?
The position & texcoords are most probably wrong. I need the steps for this…do I require glTexCoord2f when using shaders?
You test the shader linkage by modifying ti and see the result? hah, it’s not the right way. You need to call glGetObjectParameteriv followed by glGetInfoLog and print this log some where to be sure that your original shaders are linked properly.
Your code is correct, but I’m asking about actual returned value of glGetUniformLocation.
For immediate mode - yes, you need to call glTexCoord*. I prefer VBO way (which may be a little more difficult to setup, if you didn’t use it)