• Advertisement

Archived

This topic is now archived and is closed to further replies.

Disabling Textures after glActiveTextureARB

This topic is 5099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I draw a UI (in ortho with no textures just colored quads and text) after this however its not displaying after I make this call. I think its because glDisable(GL_TEXTURE_2D) is not being executed or, most likely, is not the correct method to disable textures using glActiveTextureARB anyone shed some light?
	glDisable(GL_COLOR_MATERIAL);
	glColor4f(1, 1, 1, 0);

	glActiveTextureARB(GL_TEXTURE0_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, mtexdemo_id[0]);
	
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, mtexdemo_id[1]);

	glPushMatrix();
		
		glTranslatef(0, 0, 0);
		glRotatef(rot, 0, 1, 0);

		glBegin(GL_QUADS);

			glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);
			glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);
			glVertex3f(-2, 2, 0);

			glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f);
			glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f);
			glVertex3f(-2, -2, 0);

			glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f);
			glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f);
			glVertex3f(2, -2, 0);

			glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f);
			glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f);
			glVertex3f(2, 2, 0);

		glEnd();											

		
	glPopMatrix();

	rot += .2;

	glDisable(GL_TEXTURE_2D);
	glEnable(GL_COLOR_MATERIAL);
	

Share this post


Link to post
Share on other sites
Advertisement
You have to disable each of the texture stages you enable. So, since you enable both GL_TEXTURE0_ARB and GL_TEXTURE1_ARB, you have to select each of those texture stages and call glDisable(GL_TEXTURE_2D) in turn. It looks like you are only disabling GL_TEXTURE1_ARB in your code, since that is still the currently active texture after the loop finishes.

EDIT: For example:

glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);



Golem



Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller


[edited by - VertexNormal on February 7, 2004 12:03:33 AM]

Share this post


Link to post
Share on other sites
I was wondering that so I put two disables at the end. I just didnt select the first texture ... obviously I had the wrong implementation

That fixed it ... thanks



[edited by - Jenison on February 7, 2004 12:13:19 AM]

Share this post


Link to post
Share on other sites
dont know if thats supposed to be that way, but using fragment programs doesnt require enabling or disabling single units, as you either use it or not. but that would only be a good idea if you use fragment programs for everything thats using more than the first texture unit. in the end it would only save a few lines (no enable/disable calls, just binding all textures). talking about saving lines, shouldnt there be some extension to allow something like BindTexture(type, unit, textureId)? but then, you''ll most likely have your own texture manager taking care of all that which would expose such a function.

Share this post


Link to post
Share on other sites
that kind of extension would break the way OpenGL works, state wise, imo
Also, if you had that you''d have to have the same command for texture coodinate pointers, normal pointers, color pointers etc etc, better to force a switch to the texture unit you want and setup the state of it in a meaningfull way, code is then clear about where you are working and everything is grouped

Share this post


Link to post
Share on other sites
quote:
Original post by _the_phantom_
code is then clear about where you are working and everything is grouped


hm, a lot of time searching for bugs because somewhere someone didnt change back to unit0 and other "damn, i thought i was working on x" moments might tend to disagree. but as i said, at some point i end up with a texture manager thats keeping track of current unit, loaded and bound textures etc. anyway, that can do some checks if needed (compare the unit to the max available units and so on).

and at least for immediate mode there''s a direct way (but i guess switching through all tex units for every single vertex would have been a good shortcut to insanity).

Share this post


Link to post
Share on other sites

  • Advertisement