OpenGL (lwjgl) wont disable texturing

Started by
0 comments, last by MausGames 11 years, 2 months ago

Hello,

I come from a background of XNA and some DX9 programming and I'm trying to learn some more about OpenGL. Im currently making a JavaXNA port to make my life easier.

The problem I'm having is that OpenGL wont disable texturing with GL11.glDisable(GL11.GL_TEXTURE_2D);

I'm recreating spritebatch and this is how I draw a texture:


	public void DrawTexture2D(Texture2D Texture,int x, int y, int width,int height)
	{
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		
		y = Game.graphics.PreferredBackBufferHeight - height;
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, Texture.ID);
                GL11.glColor3f(1.0F, 1.0F, 1.0F);
                GL11.glTexCoord2f(0.0F, 1.0F); GL11.glVertex2f(x, y);
                GL11.glTexCoord2f(0.0F, 0.0F); GL11.glVertex2f(x, y + height);
                GL11.glTexCoord2f(1.0F, 0.0F); GL11.glVertex2f(x + width, y + height);
                GL11.glTexCoord2f(1.0F, 1.0F); GL11.glVertex2f(x + width, y);
        
               GL11.glDisable(GL11.GL_TEXTURE_2D);
	}

And then after it, I simply want to draw a colored rectangle like so:


	public void DrawRect(int x, int y,int width,int height,Color Color)
	{
		GL11.glDisable(GL11.GL_TEXTURE_2D);
		y = Game.graphics.PreferredBackBufferHeight - height;
                GL11.glColor3f(Color.r,Color.g,Color.b);  GL11.glVertex2f( x, y);
                GL11.glColor3f(Color.r,Color.g,Color.b);  GL11.glVertex2f( x, y + height);
                GL11.glColor3f(Color.r,Color.g,Color.b);  GL11.glVertex2f(x + width, y + height);
                GL11.glColor3f(Color.r,Color.g,Color.b);  GL11.glVertex2f(x + width, y);
	}

But even though I told OpenGL to disable texturing twice, the plain rectangle still has the texture that was used before. (just doesn't have texture coords)

This is what its supposed to look like:

But when a texture is drawn, it looks like this:


Any ideas?

Advertisement
Do you use glBegin and glEnd ?
Many operations are invalid between those functions - glBindTexture for example returns an GL_INVALID_OPERATION error.
Maybe glEnable and glDisable have a similar behavior.

Edit: Found an old Link to this topic: http://www.gamedev.net/topic/83150-glbindtexture-inside-of-glbegin/

Best regards
- Martin

This topic is closed to new replies.

Advertisement