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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:29:44+00:00 2026-05-27T08:29:44+00:00

I have mipmapping working properly. But for some reason, after I apply the texture,

  • 0

I have mipmapping working properly. But for some reason, after I apply the texture, all other objects in my application take on what seems to be the average color of the texture. Even the HUD. Is there something i need to account for? Here is the code:

GLuint LoadTexture( const char * filename, int width, int height )
{
    GLuint texture;
    unsigned char * data;
    FILE * file;

    file = fopen( filename, "rb" );
    if ( file == NULL ) return 0;
    data = (unsigned char *)malloc( width * height * 3 );
    fread( data, width * height * 3, 1, file );
    fclose( file );

    glGenTextures( 1, &texture );
    glBindTexture( GL_TEXTURE_2D, texture );
    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR );

    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );

    gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, GL_RGB, GL_UNSIGNED_BYTE, data ); 
    free( data );
    return texture;
}

That gets called before the loop and freed afterwords. This next portion of code happens inside my while loop. It is called before all other objects in the scene.

void makeGround() {

    glBindTexture( GL_TEXTURE_2D, texture );

    GLfloat mat_specular[]      = { 0.5, 0.5, 0.5, 1.0 };
    GLfloat mat_diffuse[]       = { 0.8, 0.8, 0.8, 1.0 };
    GLfloat mat_shininess[]     = { 100.0 };

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

    //glColor3f(1.0, 1.0, 1.0);

    glPushMatrix();
        glTranslatef(-(size/2), 0.0f, -(size/2));
        glCallList(LIST1);
    glPopMatrix();
}

What should I be doing between drawing my different elements to keep this from happening?

  • 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-27T08:29:44+00:00Added an answer on May 27, 2026 at 8:29 am

    I would guess that you fogot to unbind the texture or disable texturing after you finished rendering the parts which should be textured. When you try to render untextured Objects they still get the texture, but due to the lack of texture coordinates they all use the same texcoord, so it will get just one color from the texture.

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

Sidebar

Related Questions

Have a n-tire web application and search often times out after 30 secs. How
I am creating a simple opengl application which obviously includes some 3d-objects and textures.
Have tried all the embedding approaches listed on W3 schools and then some more.
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
I'm completely new in Open GL, so have a question. I need to apply
I have a billboard quad with a texture mapped onto it. This is basically
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
Have finally got a responsive site working (of a fashion). What I want to
Have some code: using (var ctx = new testDataContext()) { var options = new
Have posting working wonderfully, and reading the response happily EXCEPT when one of the

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.