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 981323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:31:29+00:00 2026-05-16T04:31:29+00:00

I am having trouble with OpenGL 1.1 lighting. My code works on the iPhone

  • 0

I am having trouble with OpenGL 1.1 lighting. My code works on the iPhone 4 but not the iPhone 3G. Everything appears unlit (flat colours). I don’t have a 3GS so I can’t find out if it works on that one or not.

Here is my lighting setup:

- (void)setupLighting
{
    const GLfloat           lightAmbient[] = {0.2, 0.2, 0.2, 1.0};
    const GLfloat           matAmbient[] = {0.6, 0.6, 0.6, 1.0};        
    const GLfloat           matDiffuse[] = {1.0, 1.0, 1.0, 1.0};            
    const GLfloat           matSpecular[] = {0.6, 0.6, 0.6, 0.1};       
    const GLfloat           lightPosition[] = {0.0, 0.0, 0.0, 0.0};         
    const GLfloat           lightShininess = 100.0;     
    glEnable(GL_LIGHTING);      
    glEnable(GL_LIGHT0);        
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, matAmbient);        
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiffuse);        
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matSpecular);      
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, lightShininess);       
    glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);     
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);                  
    glShadeModel(GL_SMOOTH);    
    NSLog(@"Lighting sorted");
}

I supply normal vectors and so on after that, which successfully renders on the newer iPhone… however, I would really like to support all three iPhones. (It also works on the iPad).

  • 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-05-16T04:31:30+00:00Added an answer on May 16, 2026 at 4:31 am

    Heh, to answer my own question (and provide info for anyone else with the same problem) there was a problem with the light position being (0, 0, 0, 0). Setting it to (0, 0, -1.0, 0) fixed the problem and didn’t disturb the lighting conditions on the other devices. I still don’t quite understand what I’ve done here, but I’m just glad I can provide compatibility to iPhone 3Gs…

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

Sidebar

Related Questions

I'm trying to implement picking using Pyglet's OpenGL wrapper, but I'm having trouble converting
Having a lot of trouble getting texture maps to work in openGL ES (iphone).
I'm having trouble with OpenGL lighting. My issue is this: When the object has
I am still learning the basics of OpenGL, but I am having trouble doing
I am having trouble finding information related to which i should choose, OpenGL ES
Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that
Having trouble with the following segment of code. I'm getting a parameter count mismatch.
I'm trying to draw a 3d kitchen table with openGL, I'm having trouble in
I recently started working with OpenGL ES for the iPhone, and I am having
I am new to JOGL but I am having trouble with the basics. I

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.