OpenGl texture goes too dark

六眼飞鱼酱① 提交于 2019-12-11 05:50:54

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/13670259/opengl-texture-goes-too-dark

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!