Jump to content

  • Log In with Google      Sign In   
  • Create Account


OpenGL (lwjgl) wont disable texturing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Oblivion165   Members   -  Reputation: 107

Like
0Likes
Like

Posted 31 January 2013 - 04:00 PM

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?



Sponsor:

#2 Maus   Members   -  Reputation: 541

Like
0Likes
Like

Posted 31 January 2013 - 06:02 PM

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

Edited by MausGames, 31 January 2013 - 06:11 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS