OpenGL texture mapping stubbornly refuses to work

若如初见. 提交于 2019-12-01 13:13:12

One common mistake is to create/use an incomplete texture, see here.

Your code does not show any call to :

glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR/*or GL_NEAREST*/);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR/*or GL_NEAREST*/);

and also does not show any mipmap creation.

You problem may be related to your texture being incomplete.

Just a vague theory here: have you tried drawing the vertices counter-clockwise instead of clockwise?

glTexCoord2i(0, 0); glVertex2i(0, 0);
glTexCoord2i(0, 1); glVertex2i(0, 64);
glTexCoord2i(1, 1); glVertex2i(64, 64);
glTexCoord2i(1, 0); glVertex2i(64, 0);

Don't you need a glOrtho(0., 800, 600, 0., 0., 1.); in the paintGL function?

Try enabling GL_COLOR_MATERIAL? I haven't used the fixed-functionality pipeline in a while, but I think that might do it.

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