OpenGl 纹理太暗 [英] OpenGl texture goes too dark

查看:229
本文介绍了OpenGl 纹理太暗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有一个使用纹理绘制矩形的渲染函数:

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.

有人知道怎么解决吗?

推荐答案

经过多番搜索,我想通了,我需要将颜色设置为白色:

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

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

在开头插入.

这篇关于OpenGl 纹理太暗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆