Download presentation
Presentation is loading. Please wait.
Published byClifford Lane Modified over 9 years ago
2
Bitmap: A bitmap is a rectangular array of 0s and 1s that serves as a drawing mask for a corresponding rectangular portion of the window. Applications: The most application of bitmaps in OpenGL is to display Fonts on the screen. Raster Position: Points to a location on the screen where the bitmap is drawn(Lower Left Corner). Note: Raster Position is affected by MODEL_VIEW matrix Use glRasterPos to set Raster Position
3
Drawing Bitmaps: ◦ First setup the position that you want to draw using glRasterPos2i(x, y). ◦ Then use glBitmap as follow to draw the bitmap: glBitmap(width, height, xbo, ybo, xbi, ybi, const GLubyte *bitmap)
4
Display lists are very useful when used with fonts. A new list can be generated for each character and be called correspondingly when needed. By using display lists, you can define a function that takes a text as input and prints out the input on screen.
5
Reading, Writing, and Copying Pixel: ◦ Use three basic commands that manipulate image data 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*(). glCopyPixels() - Copies a rectangular array of pixels from one part of the framebuffer to another. This command behaves similarly to a call to glReadPixels() followed by a call to glDrawPixels(), but the data is never written into processor memory.
7
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. Note: If you are using double-buffer, you have to specify which buffer are you using front buffer or back buffer.
8
void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) Draws a rectangle of pixel data with dimensions width and height. The pixel rectangle is drawn with its lower-left corner at the current raster position. format and type have the same meaning as with glReadPixels(). Note: If the current raster position is invalid, nothing is drawn, and the raster position remains invalid.
9
Packing and unpacking refer to the way that pixel data is written to and read from processor memory. During Packing and Unpacking, we are enable to manipulate the data read. Such modifications consist of: ◦ Controlling Pixel-Storage Modes ◦ Pixel-Transfer Operations ◦ Pixel Mapping
10
Packing and unpacking refer to the way that pixel data is written to and read from processor memory. Sometimes you may be dealing with packing/unpacking a sub-image instead of the whole image. In such conditions, controlling byte alignment may be very useful: ◦ Different machines have different byte orders ◦ Some machines have special hardware that works only if data is aligned in 2, 4 or 8 byte boundaries in processor memory. ◦ In such cases, we use glPixelStore to align the data
13
Before the data is written to frame-buffer or processor memory, OpenGL can perform several operations on it. The range of a component can be changed, e.g. you may want to change the range of red component to be other than [0,1] Or, could be that the data you are using comes from a different graphic system which stores the RGB components in a different range rather than [0,1] In these situations use glPixelTransfer function in order to transform the data as you need.
14
QUESTIONS?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.