简体   繁体   中英

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). 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).

What could possibly be wrong with it? Am I using SOIL incorrectly?

From source: glBindTexture(PadImg , GL_TEXTURE_2D);

This is way wrong, it should be glBindTexture(GL_TEXTURE_2D, PadImg);

You should get familiar with glGetError, it will help you find problems like this.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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