Texture Binding to both cubes when called after the first one is rendererd

Started by tattyseal, December 31, 2013, 13:14:58

Previous topic - Next topic

tattyseal

Hello,

public void renderTestingCubes()
	{
		/***
		 * Do not use this method unless a SealGames team member. It is not for modding.
		 */
		
		CubeRenderer.getInstance().renderCube(0.0f, -3.0f, -5.0f, 1.0f, 1.0f, 1.0f);
		
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, ResourceLocations.cubeTextures.get(Cube.dirt).getTextureID());
		
		CubeRenderer.getInstance().renderCube(-2f, 0f, 0f, 1.0f, 1.0f, 1.0f);
	}


As you can see, I render one cube, then bind a  texture, then it runs itself again, from the while loop in main. If I use texture.release(); both cubes go white, but if I use TextureImpl.unbind(); nothing happens, and both of them get the texture, which is not what I wanted.

Does anyone know why this is happening?

quew8

The OpenGL context does not reset after each render loop, so the texture that is bound at the end of one loop is still bound at the beginning of the next one. So you can unbind the texture before rendering the first one by calling glBindTexture(0). This is the reserved id for the "default" texture which should be empty. I'm not sure what TextureImpl.unbind() does but apparently it doesn't do that.