1 / 10

Pixels and Textures

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.

mahdis
Télécharger la présentation

Pixels and Textures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

More Related