Download presentation
Presentation is loading. Please wait.
Published byConrad Lionel Charles Modified over 6 years ago
1
Geb Thomas Adapted from the OpenGL Programming Guide
Pixels and Textures Geb Thomas Adapted from the OpenGL Programming Guide
2
Learning Objectives Learn how to copy information from the framebuffer
Learn what a texture is Learn how to use textures
3
Copying Framebuffers glReadPixels() - Reads a rectangular array of pixels from the framebuffer and stores the data in processor memory. glDrawPixels() - Writes a rectangular array of pixels from data kept in processor memory into the framebuffer at the current raster position specified by glRasterPos*().
4
ReadPixels void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); Reads pixel data from the framebuffer rectangle whose lower-left corner is at (x, y) and whose dimensions are width and height and stores it in the array pointed to by pixels. format indicates the kind of pixel data elements that are read, and type indicates the data type of each element.
5
Format GL_COLOR_INDEX: A single color index
GL_RGB: A red color component, followed by a green color component, followed by a blue color component GL_RGBA: A red color component, followed by a green color component, followed by a blue color component, followed by an alpha color component
6
Data Type GL_UNSIGNED_BYTE: unsigned 8-bit integer
GL_BYTE: signed 8-bit integer GL_BITMAP: single bits in unsigned 8-bit integers using the same format as glBitmap()
7
Texture Mapping Create the texture Decide how to apply the texture
Enable texture mapping Draw the scene, providing texture coordinates
8
Creating the Texture Normally you read in an image and create the texture pattern buffer OpenGL does not provide convenient ways to read in an image, you have to use an external library for this, such as this free library for reading and writing JPEG files.
9
Decide how to apply the texture
Decal? Modify the current colors? Blend with the current colors? Modify the current normals? Repeat at edges, or clip?
10
Learning Objectives Learn how to copy information from the framebuffer
Learn what a texture is Learn how to use textures
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.