question about using display list for text print

Started by
1 comment, last by corgan 17 years, 1 month ago
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??
Advertisement
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
It is helpful of your explanation, thx.

This topic is closed to new replies.

Advertisement