Upload
mahdis
View
22
Download
3
Embed Size (px)
DESCRIPTION
Pixels and Textures. Geb Thomas Adapted from the OpenGL Programming Guide. Learning Objectives. Learn how to copy information from the framebuffer Learn what a texture is Learn how to use textures. Copying Framebuffers. - PowerPoint PPT Presentation
Citation preview
Pixels and Textures
Geb Thomas
Adapted from the OpenGL Programming Guide
Learning ObjectivesLearn how to copy information from the
framebufferLearn what a texture isLearn how to use textures
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*().
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.
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
Data TypeGL_UNSIGNED_BYTE: unsigned 8-bit
integerGL_BYTE: signed 8-bit integerGL_BITMAP: single bits in unsigned 8-
bit integers using the same format as glBitmap()
Texture MappingCreate the textureDecide how to apply the textureEnable texture mappingDraw the scene, providing texture
coordinates
Creating the TextureNormally you read in an image and
create the texture pattern bufferOpenGL 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.
Decide how to apply the textureDecal?Modify the current colors?Blend with the current colors?Modify the current normals?Repeat at edges, or clip?
Learning ObjectivesLearn how to copy information from the
framebufferLearn what a texture isLearn how to use textures