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?