10
Pixels and Textures Geb Thomas Adapted from the OpenGL Programming Gu ide

Pixels and Textures

  • 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

Page 1: Pixels and Textures

Pixels and Textures

Geb Thomas

Adapted from the OpenGL Programming Guide

Page 2: Pixels and Textures

Learning ObjectivesLearn how to copy information from the

framebufferLearn what a texture isLearn how to use textures

Page 3: Pixels and 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*().

Page 4: Pixels and Textures

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.

Page 5: Pixels and Textures

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

Page 6: Pixels and Textures

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()

Page 7: Pixels and Textures

Texture MappingCreate the textureDecide how to apply the textureEnable texture mappingDraw the scene, providing texture

coordinates

Page 8: Pixels and Textures

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.

Page 9: Pixels and Textures

Decide how to apply the textureDecal?Modify the current colors?Blend with the current colors?Modify the current normals?Repeat at edges, or clip?

Page 10: Pixels and Textures

Learning ObjectivesLearn how to copy information from the

framebufferLearn what a texture isLearn how to use textures