Sign in to follow this  

problem: colors blended with textures

This topic is 4355 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

After asking here I found that my problem of weird looking textures were because of previously used colors being blended with the texture and that I should disable blending. But I get the same problem even if I disable blending. Here is my gl initialization code
   glViewport(0, 0, 640, 480);
  
    glEnable(GL_TEXTURE_2D);          // Enable Texture Mapping

  // set up light number 1.
    glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);  // add lighting. (ambient)
    glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);  // add lighting. (diffuse).
    glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // set light position.
    glEnable(GL_LIGHT1);

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);     // This Will Clear The Background Color To Black
    glClearDepth(1.0);                // Enables Clearing Of The Depth Buffer
    glDepthFunc(GL_LESS);             // The Type Of Depth Test To Do
    glEnable(GL_DEPTH_TEST);          // Enables Depth Testing
    glShadeModel(GL_SMOOTH);          // Enables Smooth Color Shading
    glDisable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //To allow transparent textures

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();             // Reset The Projection Matrix

    gluPerspective(45.0f,(GLfloat)640/(GLfloat)480,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window
     glMatrixMode(GL_MODELVIEW);

Can somebody find what Im doing wrong?

Share this post


Link to post
Share on other sites
If you don't want, that the color of a polygon affects the texture you should make sure that you define the texture enviroment properly:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

Share this post


Link to post
Share on other sites
But you have lightning on, right? That means that light info will be added to pixels on your polys. And try to check for glColor3f() or glColor4f() in your code that may interfere with texture color...

Share this post


Link to post
Share on other sites
Quote:
Original post by rogerdv
Yes, I have some Color3f, to color a polygon a draw before drawing the gui. The full code is here.


Where? Are you sure you're not just alpha-blending with a white poly that's all ready in the framebuffer?

Edit: Fixed your link.

Share this post


Link to post
Share on other sites
There is too much code to analyse ;)
Before drawing your polygon, do the following:
a) disable lightning
b) disable coloring material
c) make sure that your texture mode is REPLACE
if that doesn't work, then we will try something other...

[Edited by - hvor3 on January 11, 2006 8:23:14 AM]

Share this post


Link to post
Share on other sites

This topic is 4355 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this