Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:48:50+00:00 2026-06-04T03:48:50+00:00

I’m making a small simulation game in OpenGL where there is a ball in

  • 0

I’m making a small simulation game in OpenGL where there is a ball in a field and the camera is locked to viewing the ball from an angle from the top (see the screenshots below). Everything works fine, however, when the camera passes some point, the lighting on a wall fails. It becomes as if there are “no lights” in a newly created scene.

Here is the correct one:
correct

Here is when the camera passes from some point, the lighting is reset on the left wall:

incorrect

It doesn’t occur gradually. It suddenly happens when the camera is moving. Here is my code for drawing the wall:

glBindTexture(GL_TEXTURE_2D, brickTexture);
glCallList(wallObjectID);

where the list is defined earlier:

glNewList(wallObjectID, GL_COMPILE);
glBegin(GL_QUADS);
glNormal3f(0, 90, 0);

glTexCoord2f(0, 0);
glVertex3f(0, 0, 0);
glTexCoord2f(0, 1);
glVertex3f(0, level->length, 0);
glTexCoord2f(2, 1);
glVertex3f(0,level->length, 100);
glTexCoord2f(2, 0);
glVertex3f(0, 0, 100);

glNormal3f(90, 0, 0);

glTexCoord2f(0, 0);
glVertex3f(0, 0, 100);
glTexCoord2f(0, 2);
glVertex3f(level->width, 0, 100);
glTexCoord2f(2, 2);
glVertex3f(level->width, 0, 0);
glTexCoord2f(2, 0);
glVertex3f(0, 0, 0);

glEnd();
glEndList();

And here are the OpenGL settings that are initialized in the beginning of the program:

glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DOUBLEBUFFER);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
float pos[] = { -30, -30, 30 };
float intensity[] = { 1,1,1,1 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glLightfv(GL_LIGHT0, GL_SPECULAR, intensity);
glLightfv(GL_LIGHT1, GL_POSITION, pos);
glLightfv(GL_LIGHT1, GL_SPECULAR, intensity);
float diff[] = { 0.6f, 0.6f, 0.75f };
glLightfv(GL_LIGHT1, GL_DIFFUSE, diff);

…

What could be the cause of the problem? Thank you.

UPDATE: Don’t get confused by the shadow of the ball, it’s just a transparency-enabled texture that sits below the ball, it’s NOT a real shadow.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:48:51+00:00Added an answer on June 4, 2026 at 3:48 am

    You haven’t set light’s position right. You’ve used 3D vector – position. But according to the function documentation you have to use 4D vector.

    4th (w) component indicates if light is directional or point, 1 mean’s it is point light. Other values than 1 will result in improper translation, ex. w = 500 and you’ll translate 3 points, then your light moves 1500points.

    Also you have to set each light’s position when you change ModelView matrix for world translation(camera move), because when you move world, light won’t move with world, that means light is always in front of camera, ie. it’s moving with( locked to ) camera. Read this.

    A light’s position is transformed by the current ModelView matrix at the time the position is specified with a call to glLight*()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.