Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

AMBIENT AND SPOT LIGHT IN OPENGL

Posted on 2005-05-07
7
Medium Priority
?
2,528 Views
Last Modified: 2013-12-06
Hi,

Actually i have done a program will have a a room(Where all the walls are a 10 X 10 grid).And actually implemented a ambient light.but when i runt the program i can see that only the 1 wall changes color.

And anybody tell me how should i use spot light and what are the steps i need to use.And how to bring shining to  the surface.

Regards
Hari
0
Comment
Question by:srihari1986
  • 3
5 Comments
 
LVL 8

Expert Comment

by:_corey_
ID: 13961964
Are the walls textured at all?  Also, did you set the material values (ambient/diffuse/etc) for those objects?

corey
0
 

Author Comment

by:srihari1986
ID: 13965284
Yes my walls are textured.What are the values we need to set for ambient and spot light.Below is the code o have done for the ambient light.The ambient light actually works only on the wall that has no texture.


// method to setup the lighting
   void set_light ( void)
   {


        // controlling the ambient light
        GLfloat ambientVal;
        if(!nightMode)
              ambientVal = 2.0;
        else
                ambientVal = 0.2;

        GLfloat lmodel_ambient[] = {ambientVal,ambientVal,ambientVal, 1.0 };
        glClearColor(0.0,0.0,0.0,1.0);
        glShadeModel(GL_SMOOTH);

      // enable ambient light
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);

            glLightModeli ( GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE );
      glLightModeli ( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );

       // enable all the lighting
        glEnable ( GL_LIGHTING ); // ambient
        glEnable (GL_DEPTH_TEST);
        glEnable(GL_COLOR_MATERIAL); // to enable proper transparency and color after the lighting
   }

Regards
Hari
0
 
LVL 6

Expert Comment

by:guitaristx
ID: 13988080
I'd recommend keeping a browser window open to:
http://rush3d.com/reference/opengl-redbook-1.1/
Whenever you're doing OpenGL programming.  The chapter on lighting (#6) is probably going to be most helpful to you.  Can you post a bit more code, specifically, your draw function?
0
 
LVL 8

Expert Comment

by:_corey_
ID: 13988181
I've been away with work, I'll try to answer your question soon.

corey
0
 
LVL 8

Accepted Solution

by:
_corey_ earned 2000 total points
ID: 13997316
Ok Hari,

  It looks like you are not setting any material color values that would affect the ambient/diffuse lighting.  You're simply enabling the lighting.

  Try using http://developer.3dlabs.com/GLmanpages/glmaterial.htm and GL_FRONT_AND_BACK and setting the ambient and diffuse colors for the model before sending the verticies/etc.

corey
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question