简体   繁体   English

OpenGL(使用SOIL)始终加载相同的图像

[英]OpenGL (using SOIL) always loads the same image

When I load an image, the next image loaded for something else is the same image. 当我加载图像时,为其他图像加载的下一个图像是相同的图像。

Basically: 基本上:

I'm making a Pong replica and there is a texture for the paddle and for the ball (yes I have made sure that they are both different). 我正在制作一个Pong复制品,并且有一个用于球拍和球的纹理(是的,我确保它们都是不同的)。 You can find the source code here. 你可以在这里找到源代码。 The paddle loads an image fine, but when it comes to the ball it loads the same exact image as the paddle (Paddle = Paddle.cpp , Ball = Ball.cpp). 桨叶可以很好地加载图像,但是当它出现在球上时,它会加载与桨叶相同的精确图像(Paddle = Paddle.cpp,Ball = Ball.cpp)。

What could possibly be wrong with it? 可能有什么问题呢? Am I using SOIL incorrectly? 我错误地使用SOIL了吗?

From source: glBindTexture(PadImg , GL_TEXTURE_2D); 来自: glBindTexture(PadImg , GL_TEXTURE_2D);

This is way wrong, it should be glBindTexture(GL_TEXTURE_2D, PadImg); 这是错误的,它应该是glBindTexture(GL_TEXTURE_2D, PadImg);

You should get familiar with glGetError, it will help you find problems like this. 你应该熟悉glGetError,它会帮你找到这样的问题。

Also, these calls are in the wrong order: 此外,这些调用的顺序错误:

glVertex2f(-w,-10);
glTexCoord2f(0,0);

glVertex should always be the last function called per vertex (normals and texcoords come first). glVertex应该始终是每个顶点调用的最后一个函数(法线和texcoords排在第一位)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM