Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'beginning opengl game programming 2004 phần 9', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Outline Fonts 253 setting up the bitmap font for use with Windows through the wglUseFontBitmaps function the CreateBitmapFont method returns the base ID for the character display list. Next is the RenderFont method which displays a string of text using the selected bitmap font at a specified raster position void CGfxOpenGL RenderFont int xPos int yPos unsigned int base char str if base 0 str return glRasterPos2i xPos yPos glPushAttrib GL_LIST_BIT glListBase base - 32 glCallLists int strlen str GL_UNSIGNED_BYTE str glPopAttrib The RenderFont method is very simple in that it verifies the base ID and string it receives before setting the raster position and rendering the text display list. Finally we have the ReleaseFont method which simply cleans up the font display list void CGfxOpenGL ReleaseFont unsigned int base if base 0 glDeleteLists base 96 The rest of the code uses these functions to display the screenshot shown in Figure 11.1. The example is set up in orthographic projection. We recommend orthographic projection when rendering with bitmap fonts because it enables you to specify the raster position coordinates in window coordinates and you don t need to worry about the perspective projection affecting the raster position. That s all for bitmap fonts Let s look at another technique for putting text on the screen outline fonts. Outline Fonts Outline fonts are very similar to the bitmap fonts we just discussed but they are much more fun to play around with Outline fonts define characters in a font as a series of lines and curves which means they can be scaled up and down without a loss in quality. With TLFeBOOK 254 Chapter 11 Displaying Text OpenGL you can move outline font text around the screen in 3D give the font text some thickness and essentially turn any font on the current system into a 3D font with all the functionality of other 3D objects. To use outline fonts you first need to declare an array of 256 GLYPHMETRICSFLOAT variables which hold information .