(LWJGL)Switching Textures(Sort of animation)

I’m trying to make some kind of a basic animation with lwjl without the slick.jar. I want the texture to change its’ appearance whenever a certain Boolean is true, and change back when it’s false.

if (change == false)  {
				//PLAYER
				tex1.bind();
				tex2.release();
				glBegin(GL_QUADS);

				glTexCoord2f(0, 0);
				glVertex2i(p.getx(), p.gety()); // Upper-left
				glTexCoord2f(1, 0);
				glVertex2i(p.getx() + 32, p.gety()); // Upper-right
				glTexCoord2f(1, 1);
				glVertex2i(p.getx() + 32, p.gety() + 32); // Bottom-right
				glTexCoord2f(0, 1);
				glVertex2i(p.getx(), p.gety() + 32); // Bottom-left

				glEnd();
				}
if (change == true)  {
				//PLAYER
				tex2.bind();
				tex1.release();
				glBegin(GL_QUADS);

				glTexCoord2f(0, 0);
				glVertex2i(p.getx(), p.gety()); // Upper-left
				glTexCoord2f(1, 0);
				glVertex2i(p.getx() + 32, p.gety()); // Upper-right
				glTexCoord2f(1, 1);
				glVertex2i(p.getx() + 32, p.gety() + 32); // Bottom-right
				glTexCoord2f(0, 1);
				glVertex2i(p.getx(), p.gety() + 32); // Bottom-left

				glEnd();
				}

I’ve tried switching them around, and the Boolean does work properly.

You are releasing the texture, that means you are deleting it. You can simplify it like


if (change)
    tex1.bind();
else
    tex2.bind();

glBegin(GL_QUADS);
{
    glTexCoord2f(0, 0);
    glVertex2i(p.getx(), p.gety()); // Upper-left
    glTexCoord2f(1, 0);
    glVertex2i(p.getx() + 32, p.gety()); // Upper-right
    glTexCoord2f(1, 1);
    glVertex2i(p.getx() + 32, p.gety() + 32); // Bottom-right
    glTexCoord2f(0, 1);
    glVertex2i(p.getx(), p.gety() + 32); // Bottom-left
}
glEnd();

Thanks so much! You’re very helpful. I realized due to my lack of organization, I had also drawn the image already.