Jump to content
  • Advertisement
Sign in to follow this  
usb2killer

OpenGL Eye vector doesn't change!

This topic is 3185 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

My eye vector doesn't change when i rotate the camera. I cant figure out why.... The Camera Moves but the eye vector doesn't change and the specular light act like a diffuse light (doesn't react to the camera). Even in the default shade model in OpenGL and my GLSL code. i tried many GLSL shaders in the internet and all of them act the same with the eye vector. What should I do? Here is my camera code:
// Change to projection matrix.
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();

// Perspective.
float widthHeightRatio = (float) canvas.getWidth() / (float) canvas.getHeight();
glu.gluPerspective(45, widthHeightRatio, 1, distance);
glu.gluLookAt(
                          position.X, position.Y, position.Z,
                          lookat.X, lookat.Y, lookat.Z,
                          0, 1, 0);

// Change back to model view matrix.
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();



One exclamation point is sufficient. -- jpetrie

Share this post


Link to post
Share on other sites
Advertisement
Just picking random shaders off the web isn't likely going to work out, as shaders are typically written to have at least some dependency on the CPU-side code as well.

I don't see any eye vector there. You're going to have to provide more information. OpenGL has no concept of an "eye vector," so any such concept is entirely your own (or one used by one of the shaders, which is one of those dependencies I mentioned -- the shader is expecting you to set it). So if it's not updating the way you expect, that's because you are not updating it.

I do see that you're doing all your work with the matrix mode set to projection -- this is manipulating only the projection matrix, not the modelview matrix. You probably want to call glLookAt() while the mode is set to modelview, because most shaders will assume the modelview matrix contains the world->view transform, because that's typical OpenGL behavior. In your case the entire world->clipspace transform is in the projection matrix.

Provide more details.

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!