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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:49:20+00:00 2026-05-23T02:49:20+00:00

So the question is: when I switch from ColorPointers to Textures, it seems that

  • 0

So the question is: when I switch from ColorPointers to Textures, it seems that the lightning/shadows effects are greatly reduced. Some solution that I have found but doesnt do that much is setting glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR ). Is there anything more I could do to get closer effects to what I would get without textures?

This is how I init my lights/scene:

    glClearColor (0.0, 0.0, 0.0, 0.5);                       # Black Background
    glClearDepth (1.0);                                      # Depth Buffer Setup
    glDepthFunc(GL_LEQUAL)                                   # The Type Of Depth Testing 
    glEnable(GL_DEPTH_TEST);                                
    glShadeModel(GL_SMOOTH);                                 # Select Smooth Shading       
    glColor4f(0.90, 6.0, 6.0, 1.0)
    glEnable(GL_LIGHTING)
    glEnable(GL_LIGHT0)   
    #glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0)  
    glEnable(GL_COLOR_MATERIAL);        
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [0.7, 0.7, 0.7, 0])
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [0.8, 0.8, 0.7, 0])
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [0.8, 0.8, 0.8, 0])
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 30)
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);    
    glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR );
    glLightfv(GL_LIGHT0, GL_POSITION, [0.85, 0.8, 0.75, 0])
    glLightfv(GL_LIGHT0, GL_AMBIENT, [0.8, 0.8, 0.7, 0])
    glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.7, 0.7, 0.7, 0])
    glLightfv(GL_LIGHT0, GL_SPECULAR, [0.8, 0.8, 0.8, 0])

And for the actual drawing.

    glEnableClientState(GL_VERTEX_ARRAY)         
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferVertices)
    glVertexPointer(3, GL_FLOAT, 0, None)          
    glEnableClientState(GL_NORMAL_ARRAY);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferNormals)
    glNormalPointer(GL_FLOAT, 0, None)           
    #glEnableClientState(GL_COLOR_ARRAY)
    #glColorPointer(3, GL_FLOAT, 0, None)

    glEnableClientState(GL_TEXTURE_COORD_ARRAY)        
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, self.bufferTextureIndex)
    glTexCoordPointer(1, GL_FLOAT, 0, None);
    glBindTexture(GL_TEXTURE_1D, self.texture)
    glEnable(GL_TEXTURE_1D)
    glDrawElements(GL_TRIANGLES, len(self.triangles) , GL_UNSIGNED_SHORT, ADT.voidDataPointer(self.triangles))

For the colors of each vertex I was using the normals as dummy colors, since that was just a step in the way of integrating textures. The texture is a self generated one , basically the values are from:

   def getColor(self, value):
    if value < 0:
        return [1, 0, 0]
    if value >=0 and value < 0.8:
        return [1, 0.5, 0]
    if value >= 0.8 and value < 1:
        return [1, 1, 0]
    if value >=1 and value < 1.2:
        return [0.5, 1, 0]
    if value >=1.2 and value < 1.4:
        return [0, 1, 0]
    if value >= 1.4 and value < 1.6:
        return [0, 1, 0.5]
    if value >= 1.6 and value < 1.8:
        return [0, 1, 1]
    if value >= 1.8 and value < 2:
        return [0, 0.5, 1]
    if value >= 2:
        return [0, 0, 1]

The actual creation:

    glBindTexture(GL_TEXTURE_1D, self.texture)
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
    glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 190, 0, GL_RGB , GL_FLOAT, textureArray)

Regards,
Bogdan

EDIT

Ok I got close to the effect I wanted but it was purely by trying different combinations of glColor4f with materials and ligths in the following part.

    glColor4f(2.2, 2.2, 2.2, 1.0)
    glEnable(GL_LIGHTING)
    glEnable(GL_LIGHT0)   
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0)  
    glEnable(GL_COLOR_MATERIAL)        
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [0.6, 0.6, 0.6, 1.0])
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [0.6, 0.6, 0.6, 1.0])
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, [0.8, 0.8, 0.8, 1.0])
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, 30)
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)    
    glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR )
    glLightfv(GL_LIGHT0, GL_POSITION, [0, -10, -400, 0])
    glLightfv(GL_LIGHT0, GL_AMBIENT, [0, 0, 0, 0])
    glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.7, 0.7, 0.7, 0])
    glLightfv(GL_LIGHT0, GL_SPECULAR, [0.8, 0.8, 0.8, 0])

Is there some kind of formula of how all of these (glColor4f + Materials + Lights + Texture) influence the final color/shadow/shininess effects ?

  • 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-23T02:49:20+00:00Added an answer on May 23, 2026 at 2:49 am

    If you are using your shader in your other question here OpenGL shaders questions

    then the answer is that you are not handling lighting in your shader which disables the fixed function lighting routines when you enable your shader.

    If I am jumping the gun on this conclusion and you are seeing thing without the shader, I apologize.

    Edit

    Yes, there is a formula. It is covered extensively in the orange book and briefly in the red book http://glprogramming.com/red/chapter05.html. Older version are freely available of the red, book.

    Basically it depends on the texture of the object, if there is a color and how it is applied, modulated, added, multiplied. The material and how it reflects lights of different colors, plus any emisions the material makes ( think glow in the dark sticker material for emission ), and the color of the light and the angle the light is striking the face. "Shiny" comes from specular reflection of light.

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

Sidebar

Related Questions

Background Trying to switch from using Interceptor to Events. I have a ValidationInterceptor that
I have this idea that I should switch over from cmd.exe to powershell. It's
In this question the answer was to flip on a switch that is picked
i have a question about fopen() and base64 comunication. The scenario is that: i
(This question has been rewritten from an issue with NSTextView following some further research)
I see this question but it's from 2008. Seems like many version control systems
This question is kind of an add-on to this question In C#, a switch
Question Can I build a image database/library that has an e-commerce style checkout system
My team is looking to switch from source safe to something else (finally). I
I recently decided to switch to clang from gcc and I’m getting the following

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.