Title: 3D Computer Game Design
1????????3D Computer Game Design
- Chapter 6
- Bitmaps and Images with OpenGL
- ????? ???
2In this chapter, you will learn
- How to use OpenGL bitmaps
- OpenGL pixel functions
- How to load and save the Targa image format
3The OpenGL Bitmap
- Bitmap
- A rectangular array of pixels
- One bit of information (a 0 or 1)
- Example
- 16 x 16 bitmaps
- Drawn by OpenGL as the letter X
4The OpenGL Bitmap
- Draw the bitmap
- At the lower-left corner
- Working its way up, row by row
- The bottom of the bitmap is the first set of data
- The top of the bitmap is the last set of data
5(No Transcript)
6Positioning the Bitmap
- The glRasterPos( ) function
- Specify the current raster coordinates
- Define the bottom-left corner of the bitmaps
rectangle - Set the current raster coordinates to (30, 10)
- glRasterPos2i(30, 10)
7Drawing the Bitmap
- After you set the current raster position
- You can draw your bitmap with the glBitmap()
function
8Drawing the Bitmap
- Draw your bitmap with glBitmap() function
void glBitmap(GLsizei width, GLsizei height,
GLfloat xOrigin, GLfloat yOrigin, GLfloat
xIncream, GLfloat yIncream, const GLubyte
Xbitmap) width and height in pixels at the
coordinates(xOrigin, yOrigin) relative to the
current raster position. The values xIncream and
yIncream specify step increments that are added
to the current raster position after the bitmap
is drawn.
9An OpenGL Bitmap Example
- Display 50 16x16 bitmaps in random locations
during each frame
10(No Transcript)
11(No Transcript)
12Targa Image Files
- Targa image format
- Simple to work with
- Incorporate transparency
- Other cool special effects
13The Targa File Format
- Two parts
- The header and the data
14Loading Targa Files
- An example - LoadTGA
- Load 24-bit and 32-bit compressed and
uncompressed Targa images
15Summary
- You have learned about
- How to set the current OpenGL raster position and
draw the bitmaps - How to load and draw Targa images
16References
- Dave Astle and Kevin Hawkins, Beginning OpenGL
Game Programming, 1st Edition, Course Technology
PTR, 2004. - http//glbook.gamedev.net