English 中文(简体)
Working with Lights
原标题:

Trying to get a grasp on lights and working through the OpenGL Superbible book. Below is what I am currently using for my lighting. It s placed in the SetupRC function.

The lighting is mostly working as I expected as per position etc but I am confused on why when I turn the camera, it gets brighter on places where it was previously darker. I have not moved the camera position s but the light still moves.

Why is this? Sort of confused here.

    GLfloat ambient[] = { 0.7f, 0.7f, 0.7f, 0.5f };
    GLfloat diffuse[] = { 1.0, 1.0f, 1.0f, 1.0f };

    glEnable(GL_LIGHTING);

    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);

    glEnable(GL_LIGHT0);


    GLfloat ambientLight[] = {1.0f, 0.0f, 1.0f, 0.5f};
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);

    glEnable(GL_COLOR_MATERIAL);

    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); //GL_AMBIENT_AND_DIFFUSE
问题回答

The reflected lights has a direction, set by the normal to the surface.
The position of the light, surface and camera affect how much light the camera sees.

Or possibly see OpenGL lighting problem when rotating the camera





相关问题
OpenGL 3D Selection

I am trying to create a 3D robot that should perform certain actions when certain body parts are clicked. I have successfully (sort of) implemented picking in that if you click on any x-plane part, it ...

CVDisplayLink instead of NSTimer

I have started to implement cvDisplayLink to drive the render loop instead of nstimer, as detailed in this technical note https://developer.apple.com/library/archive/qa/qa1385/_index.html Is it ...

Can the iPhone simulator handle PVR textures?

I have a really weird problem with PVR textures on the iPhone simulator- the framerate falls through the floor on the iPhone simulator, but on the iPhone itself it works just fine. Has anyone had any ...

Calculate fps (frames per second) for iphone app

I am using an opengl es iphone application. What is the most accurate way to calculate the frames per second of my application for performance tuning?

Java - Zoom / 3D Data Visualization Libraries

What are the best libraries/frameworks for doing 3D and/or Zoom interfaces in Java? I d like to be able to do some prototyping of creating new types of interfaces for navigating within data and ...

FLTK in Cygwin using Eclipse (Linking errors)

I have this assignment due that requires the usage of FLTK. The code is given to us and it should compile straight off of the bat, but I am having linking errors and do not know which other libraries ...

热门标签