Sign in to follow this  
corgan

question about using display list for text print

Recommended Posts

corgan    122
When I compile the following code, it works, the text is painted to red. Code:{ glColor3f(1.0f,0.0f,0.0f); glRasterPos2s(0,20); CharWrite("print something"); // Print GL Text To The Screen using // display lists like the method in the // red book } But when I change the code like this: Code:{ glRasterPos2s(0,20); glColor3f(1.0f,0.0f,0.0f); CharWrite("print something"); } i just change the running turn of the two methods,between which i think has no relations but the text print on the screen is not painted to red but still white. WHY??

Share this post


Link to post
Share on other sites
jouley    805
It's an often unnoticed side effect of glRasterPos. From the docs, though:
Quote:
The current raster position consists of three window coordinates (x, y, z), a clip coordinate value (w), an eye coordinate distance, a valid bit, and associated color data and texture coordinates.

...

The current raster position also includes some associated color data and texture coordinates. If lighting is enabled, then GL_CURRENT_RASTER_COLOR (in RGBA mode) or GL_CURRENT_RASTER_INDEX (in color index mode) is set to the color produced by the lighting calculation (see glLight, glLightModel, and glShadeModel). If lighting is disabled, current color (in RGBA mode, state variable GL_CURRENT_COLOR) or color index (in color index mode, state variable GL_CURRENT_INDEX) is used to update the current raster color.

Basically, the raster color is set using the current color whenever glRasterPos is called, succeeding changes to the color don't affect the raster color.

-jouley

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this