Jump to content
  • Advertisement
Sign in to follow this  

Lighting problem

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

I'm trying to put a directional light however when I change the direction of my light source there is no change in lighting. I mean light is always directed towards +z. Here is the code I have written for lighting: GL.glShadeModel(GL.GL_SMOOTH); GL.glEnable(GL.GL_LIGHTING); GL.glEnable(GL.GL_LIGHT0); float[] lightpos = { 0.0f, 1.0f, 0.0f, 0.0f }; //directional light float[] lAmb = { 0.9f, 0.9f, 0.9f, 1.0f }; float[] lDif = { 0.1f, 0.1f, 0.1f, 1.0f }; float[] lSpec = { 0.0f, 0.0f, 0.0f, 1.0f }; GL.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, lightpos); GL.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, lAmb); GL.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, lDif); GL.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, lSpec); When I change lightpos array to {1.0, 0.0, 0.0, 0.0}, shouldn't the direction of the light be +x?

Share this post


Link to post
Share on other sites
Advertisement
It seems like you are implemeting your own small OGL rendering engine i.e you have GL.xxx. Maybe the problem is your how you are impementing the GL.glLightfv(...) function. Anyway what you have provided isn't enough for me to tell you where the problem could be, but I doubt it's OGL. Show the implementation of your GL.glLightfv(...)

Share this post


Link to post
Share on other sites
Thanks Hamster, I can't believe I have made such a mistake. Everytime I copy a code from an another project I make such funny mistakes :) I think I'll never copy codes from my other projects :)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!