Jump to content
  • Advertisement
Sign in to follow this  

OpenGL lights opengles 1

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

This is an opengl version without shaders so i can only use the GL_LIGHT 's.

My scene contains a model with textures on it and there is 1 light.

When my light has a diffuse value of 1.0f, 0.0f, 0.0f

It is completly red ... which is normal ofcourse.

But when I set it to 0.5f, 0.0f, 0.0f ... its the same as when it was 1.0f ... no matter what value I set it, it is always fully red unless I set it to 0.0f, than it becomes black.

glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );

GLfloat specular[] = {0.2, 0.2, 0.2, 1.0};
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);

GLfloat ambient[] = {0.1, 0.1, 0.1, 1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);

GLfloat diffuse[] = { 0.7, 0.0, 0.0, 1.0};
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);

GLfloat position[] = {3.0, 5.0, -2.0, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, position);


glDisable( GL_LIGHTING );
glDisable( GL_LIGHT0 );

I also tried disabling the normals but that didn't help it just made the entire object red.

Edit: Ok it does work but it only works with very small values, between 0.0 and 0.1 which is very strange ? Is it because of it being a directional light? Or the object being to close to the light? Edited by JefS

Share this post

Link to post
Share on other sites
Lets just say i want to place a 3 point lighting in my scene, what lights should i use for that?

Share this post

Link to post
Share on other sites
nvm:) had to do this:


Share this post

Link to post
Share on other sites
If you are using uniform scale on your modelview matrix, use GL_RESCALE_NORMAL.
If you are using not uniform scale, GL_NORMALIZE.
That will normalize the normals of your objects so that the lighting calculations turn out correct.

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!