Title: Characters, Display Lists
1Characters, Display Lists
2Drawing Characters
- Often need to display text
- Classification
- Typeface Different designs eg.
- Courier, Times Roman, Arial, Microsoft Sans Serif
- Font Typeface and size fixed eg.
- 28-point Courier italic
3Serif and sans-serif
- Two broad groups of typeface serif and
sans-serif, eg. - Palatino serif
- Lucina Sans sans serif
- Notice that sans serif does not have extra
flourishes at the end of strokes. - Serif is easier to read lots of. Sans serif is
easier to recognize single characters
4Proportionally-spaced or constant-spaced
- Is this proportionally-spaced or constant spaced?
- XGMXXKWWW
- iiitttlll
5Computer Representation
- 2 types
- Bitmap (raster)
- Outline (stroke,vector)
- Bitmap fonts represented as bitmaps
- Need one bitmap for each style
- Multiples of pixel size
- Blocky when expanded
- Outline fonts Represented as curve functions
- Slow needs to be rasterized
- Flexible size can be adjusted, good quality
6OpenGL Character Functions
- For bitmapped fonts can use
- glRasterPos2i(x,y)
- font GLUT_BITMAP_9_BY_15
- characterb
- glutBitmapCharacter(font, character)
- glutBitmapCharacter(font, o)
- For Stroke Characters you can use
- fontGLUT_STROKE_MONO_ROMAN
- glutStrokeCharacter(font,b)
Stroke Character example (function to draw a
string)
void output(GLfloat x, GLfloat y, char text)
char p glPushMatrix() glTranslatef(x,
y, 0) for (p text p p)
glutStrokeCharacter(GLUT_STROKE_ROMAN, p)
glPopMatrix()
7OpenGL Characters
Note For stroke characters, the maximum top
character in the font is 119.05 units the bottom
descends 33.33 units. For GLUT_STROKE_MONO_ROMAN,
each character is 104.76 units wide.
8OpenGL Display Lists
- Store some set of OpenGL commands
- Then you can call it later at any time, eg.
- Make display list describing scene
- Then call the list using different viewing
parameters
GLuint ID ID glGenLists(1) glNewList (ID,
GL_COMPILE) // or GL_COMPILE_AND_EXECUTE glE
ndList() glCallList(ID)
glColor3f(1.0,0.0,0.0) glBegin(GL_QUADS) glVertex
3f(1.0,0.0,0.0) glVertex3f(1.0,1.0,0.0) glVertex
3f(0.0,1.0,0.0) glVertex3f(0.0,0.0,0.0) glEnd()