problem: colors blended with textures

Started by
7 comments, last by hvor3 18 years, 4 months ago
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?
Advertisement
Set the color to white, or TexEnv to something other than MODULATE. DECAL is maybe the right choice not sure though.
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);
The problem persists. The white blends with the texture.
can you post more of your code?especially where you define the textures.
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...
Yes, I have some Color3f, to color a polygon a draw before drawing the gui. The full code is here.
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.
If at first you don't succeed, redefine success.
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]

This topic is closed to new replies.

Advertisement