Skip to main content
gamedev.net
🔒 Locked

[Solved]Text to screen problem

Started by Winegums 3 replies 950+ views
Original Post
Winegums
Winegums
Hi, I've taken the text to screen tutorial from the NeHe example and fiddled about with it a little so it fits into the code i've written. While the text does get to the screen, it seems to take on the colour of the last used texture. I've tried setting the colour with glColor3f(), and setting the bound texture to null, but it doesn't seem to work. Heres the code:


	glBindTexture(NULL, NULL);
	
	ViewOrtho(0,0);

	glDisable(GL_DEPTH_TEST);	//Disable depth testing and masking
	glDisable(GL_TEXTURE);
	glDepthMask(GL_FALSE);
	glDisable(GL_LIGHTING);
	glRasterPos2f(-1.0f, 0.9f);	//Set our draw position
	glColor3f(0.0f,1.0f,0.0f);	//Set our draw colour
	sprintf(buffer, "Blarhg!");
	glPrint(buffer);

	ViewPerspective();

	glEnable(GL_DEPTH_TEST);	//Re-enable depth testing and masking
	glEnable(GL_TEXTURE);
	glDepthMask(GL_TRUE);
	glEnable(GL_LIGHTING);



[Edited by - Winegums on February 17, 2007 10:57:15 AM]
jouley
jouley
Quote:
Original post by Winegums
I've tried setting the colour with glColor3f(), and setting the bound texture to null, but it doesn't seem to work.
A call to glBindTexture(GL_TEXTURE_2D, 0) used to handle things, but it's not so anymore. (I'm not sure what binding a null (0) texture to a texture target of NULL (0) would do... normally one binds to a specific target. Does a value of 0 in this case catch them all?) You have to actually disable textures if you don't want one to be applied. Calling glDisable(GL_TEXTURE_2D) (I'm not sure if that's what you meant by "glDisable(GL_TEXTURE)" or not, but you should check to make sure) before you render the text should work.

Did that clear it up?
-jouley
Kalidor
Kalidor
Just to clarify a little more...
Quote:
Original post by jouley
A call to glBindTexture(GL_TEXTURE_2D, 0) used to handle things, but it's not so anymore.
That is incorrect. Ever since texture objects were introduced (OpenGL 1.1 or before with GL_EXT_texture_object), in order to disable texturing you've needed to actually disable texturing. Texture object 0 is just the initial texture object of the specified dimensionality.
Quote:
From the OpenGL Spec
In the initial state, TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, and TEXTURE_CUBE_MAP have one-, two-, three-dimensional, and cube map texture state vectors respectively associated with them. In order that access to these initial textures not be lost, they are treated as texture objects all of whose names are 0. The initial one-, two-, three-dimensional, and cube map texture is therefore operated upon, queried, and applied as TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, or TEXTURE_CUBE_MAP respectively while 0 is bound to the corresponding targets.
The same paragraph has been in the OpenGL specs since version 1.1, aside from the addition of 3d and cube map textures.

Trying to bind to a NULL or 0 target will generate a GL_INVALID_ENUM error.
jouley
jouley
Quote:
Original post by Kalidor
Just to clarify a little more...
Quote:
Original post by jouley
A call to glBindTexture(GL_TEXTURE_2D, 0) used to handle things, but it's not so anymore.
That is incorrect. Ever since texture objects were introduced (OpenGL 1.1 or before with GL_EXT_texture_object), in order to disable texturing you've needed to actually disable texturing. Texture object 0 is just the initial texture object of the specified dimensionality.

I think we're on the same page... hence my used to. Before texture objects, didn't binding a NULL texture effectively disable textures for things rendered afterwards?
Brother Bob
Brother Bob
Before texture objects, there was no such thing as "binding a texture" at all. "Binding a texture" was intoduced with texture objects. It doesn't make sense to talk about binding objects when there is no object mechanism in the first place. To go back to pre-texture object behaviour, you bind texture ID 0. This means the default textrure is used. Note that; the default texture is used.

If anything is disabled by binding ID 0, it is the texture object mechanism, nothing else. You can still, just like the pre-object days, load a valid texture into the default texture (ID 0 when talking about objects) and get the expected result just like if it was loaded into any other valid ID.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.