kaspersky
kaspersky

Reputation: 4117

OpenGl texture goes too dark

Basically I have a render function which draws a rectangle using textures:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glShadeModel(GL_SMOOTH);

glEnable(GL_TEXTURE_2D);   
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);   
glDepthFunc(GL_LEQUAL);    
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_QUADS);
{                                                        
    glTexCoord2f(0, 0);
    glVertex3f(points[0]->x, points[0]->y, 0);
    glTexCoord2f(1, 0);   
    glVertex3f(points[1]->x, points[1]->y, 0);   
    glTexCoord2f(1, 1);   
    glVertex3f(points[2]->x, points[2]->y, 0);   
    glTexCoord2f(0, 1);   
    glVertex3f(points[3]->x, points[3]->y, 0);   
}                         
glEnd();                                         
glDisable(GL_TEXTURE_2D);

After running it, I can see the texture image, but it is too dark. Also, at the beginning, I can see it's normal color just for a fraction of second.

Does anyone know how to fix it?

Upvotes: 1

Views: 3525

Answers (1)

kaspersky
kaspersky

Reputation: 4117

After more search, I figured out, I needed to set the color to white:

glColor3f(1.0f, 1.0f, 1.0f);

inserted at the beginning.

Upvotes: 3

Related Questions