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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:56:08+00:00 2026-05-27T07:56:08+00:00

My current openGL application is just a sphere and a floor, with lighting and

  • 0

My current openGL application is just a sphere and a floor, with lighting and shading working properly.

After adding a 2d texture to the floor via the redbook tutorial: http://fly.cc.fer.hr/~unreal/theredbook/chapter09.html

.. my shading becomes disabled. If I disable GL_TEXTURE_2D, everything renders correctly, but the texture obviously does not show up. Is this a known issue with with a known workaround? Here is a bit of the code for reference:

#define    checkImageWidth 64
#define    checkImageHeight 64
GLubyte checkImage[checkImageWidth][checkImageHeight][3];

void makeCheckImage(void)
{
    int i, j, c;

       for (i = 0; i < checkImageWidth; i++) {
        for (j = 0; j < checkImageHeight; j++) {
            c = ((((i&0x8)==0)^(((j&0x8))==0)))*255;
            checkImage[i][j][0] = (GLubyte) c;
            checkImage[i][j][1] = (GLubyte) c;
            checkImage[i][j][2] = (GLubyte) c;
        }
    }
}


void initImage() {

    makeCheckImage();
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth, 
        checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, 
        &checkImage[0][0][0]);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
        GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
        GL_NEAREST);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
}

And then of coarse the ground draw function:

void makeGround() {

    GLfloat mat_specular[]      = { 0.5, 0.5, 0.5, 0.5 };
    GLfloat mat_diffuse[]       = { 0.3, 0.3, 0.3, 0.3 };
    GLfloat mat_shininess[]     = { 25.0 };

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

    glColor3f(0.2, 0.2, 0.2);

    glBegin(GL_QUADS);
        glTexCoord2f(0.0, 0.0); glVertex3f(-100.0f, -1.0f, -100.0f);
        glTexCoord2f(0.0, 1.0); glVertex3f(-100.0f, -1.0f,  100.0f);
        glTexCoord2f(1.0, 1.0); glVertex3f( 100.0f, -1.0f,  100.0f);
        glTexCoord2f(1.0, 0.0); glVertex3f( 100.0f, -1.0f, -100.0f);
    glEnd();
    glFlush();

}

if you need to see any additional portions of the code, just let me know

  • 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-27T07:56:09+00:00Added an answer on May 27, 2026 at 7:56 am
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    

    Decal is a weird environment mode. For GL_RGB textures (like yours) it replaces the color. For RGBA textures, it blends it with the Alpha coming from the texture.

    If you just want to modulate your texture with the lighting, use GL_MODULATE

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

Sidebar

Related Questions

I am developing a CAD application using Delphi2010 and OpenGL. Currently, i am working
I am working on an opengl application and implementing a bezier surface in the
Current Application Server Configuration: IIS 6.0 Windows 2003 Server Standard Edition SP2 .NET Framework
I wrote a simple opengl application in C which plots sin(x). This is my
I've got a multithreaded OpenGL application using PBOs for data transfers between cpu and
I'm using OpenGL to render a game view in my android application. The game
I'm creating a drawing application that renders OpenGL when it gets a WM_SCROLL or
In OpenGL, one often writes code like this: glPushMatrix(); // modify the current matrix
I just want to do a simple animation (for example in C++ using OpenGL)
In my current OpenGL project I am trying to make the links of a

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.