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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:56:43+00:00 2026-06-04T07:56:43+00:00

I am currently trying to get into OpenGL shading and lighting to display a

  • 0

I am currently trying to get into OpenGL shading and lighting to display a 3D model exported from Blender in a simple GLUT window.

I tried to display the typical glutSolidTeapot to validate my OpenGL settings.
With the Teapot everything looks perfectly fine as can be seen in the pic below.

enter image description here

If I now want to replace the teapot with my own Blender-exported model, the shading doesn’t work. The model ( a car rim ) just looks solid-colored.
The color changes when the model is rotated, but it stays solid all the time.

enter image description here

What does glutSolidTeapot do under the hood to draw the teapot model?

Here’s the code I’m using to set up OpenGL :

void SetupRC()
{
    glClearColor(0.4, 0.4, 0.4, 1.0);

    // Enable lighting and the light we have set up
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_DEPTH_TEST);

    //Set lighting parameters
    glLightfv(GL_LIGHT0,GL_POSITION,light_position);
    glLightfv(GL_LIGHT0, GL_AMBIENT,light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);

    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // Enable shading
    glShadeModel(GL_SMOOTH);

    // Set up the projection parameters
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    glFrustum(-1.0, 1.0, -1.0, 1.0, 2.0, 20.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glEnable(GL_AUTO_NORMAL);
    glEnable(GL_NORMALIZE);
}

And the code to repaint the frames :

void RenderScene(void)
{
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);

    glTranslatef(0.0, 0.0, -2.5f);

    glRotatef(xRot, 1.0f, 0.0f, 0.0f);
    glRotatef(yRot, 0.0f, 1.0f, 0.0f);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // set input data to arrays
    glVertexPointer(3, GL_FLOAT, 0, BlenderGuru_CarWheelVerts);

    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    GLfloat ambConst[] = { 0.24725, 0.1995, 0.0745, 1.0};
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambConst);

    GLfloat diffConst[] = { 0.75164, 0.60648, 0.22648, 1.0 };
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffConst);

    GLfloat specConst[] = { 0.628281, 0.555802, 0.366065, 1.0 };
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specConst);

    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 51.2);

    // draw data
    glEnableClientState(GL_VERTEX_ARRAY);
        glDrawArrays(GL_TRIANGLES, 0, BlenderGuru_CarWheelNumVerts);
    glDisableClientState(GL_VERTEX_ARRAY);

    glFlush();
}
  • 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-04T07:56:44+00:00Added an answer on June 4, 2026 at 7:56 am

    Since you are exporting from Blender, your exported data will most likely also contain normals. If not, make sure you generate them for your model and export them. You need normal data for your lighting to work.

    The call to glEnable(GL_AUTO_NORMAL); does not do what you might think it does. It will only

    generate normal vectors when either GL_MAP2_VERTEX_3 or GL_MAP2_VERTEX_4 is used to generate vertices.

    So export normal data yourself and use this, or perhaps calculate the normals from the mesh data that is available to you.

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

Sidebar

Related Questions

I'm currently trying to get into Java Web Development in general in Spring more
I am currently trying to get multiple xml files into my xsl file to
I'm currently trying to get the output of an executable console-app into an other
I'm currently trying to get the most popular productID from my MSSQL Database. This
I'm currently trying to get into QT4 and figure out a workflow for myself.
I'm currently trying to get into foreach loops and I'm trying to get some
I'm currently trying to get this C code converted into C#. Since I'm not
Currently i am trying to get into jQuery and jQtouch for the development of
I'm currently trying to get an iCloud-enabled app into the App store. The actual
I'm currently trying to get users to submit data via PHP/HTML forms and into

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.