Jump to content
  • Advertisement
Sign in to follow this  

strange glsl behavior (texturing)

This topic is 3502 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm using a simple shader in my app that implements per-pixel lighting and texturing. Here's the frag shader:
varying vec3 N;
varying vec3 v;
uniform sampler2D tex;

void main (void)
vec3 L = normalize(gl_LightSource[0].position.xyz - v); 
vec3 E = normalize(-v); // we are in Eye Coordinates, so EyePos is (0,0,0)
vec3 R = normalize(-reflect(L,N)); 

//calculate Ambient Term:
vec4 Iamb = gl_FrontLightProduct[0].ambient;

//calculate Diffuse Term:
vec4 Idiff = texture2D(tex, vec2(gl_TexCoord[0])) * gl_FrontLightProduct[0].diffuse * max(dot(N,L), 0.0);

// calculate Specular Term:
vec4 Ispec = gl_FrontLightProduct[0].specular 
                  * pow(max(dot(R,E),0.0),0.3*gl_FrontMaterial.shininess);
// write Total Color:
gl_FragColor = gl_FrontLightModelProduct.sceneColor + Iamb + Idiff + Ispec; 

Before drawing the object, I'm doing:
glBindTexture(GL_TEXTURE_2D, _texture->getId());

And it works! Shouldn't GLSL complain because I'm not sending the tex uniform?? And even if it doesn't complain... wy does it work? Edit: actually, setting the uniform gives me gl error #1282 (invalid operation) :( Thanks! [Edited by - FreJa on December 17, 2008 1:42:45 PM]

Share this post

Link to post
Share on other sites
I noticed I was using glUniform1f to pass the sampler, which was wrong. HOWEVER! the error persists when just after glUseProgram(0) is used.

Any help?


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!