Advertisement

Drawing pixels in OpenGL

Started by April 26, 2002 02:11 PM
1 comment, last by Gravity 22 years, 10 months ago
probably a dumb question but I''ve only used OpenGL to draw polygons and textures. But how do I just write an array of pixels to the screen? The obvious solution would be (from RedBook): "glDrawPixels() - Writes a rectangular array of pixels from data kept in processor memory into the framebuffer at the current raster position specified by glRasterPos*(). " Also: "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(). (For legal values for format and type, see Table 8-1 and Table 8-2.) The array pointed to by pixels contains the pixel data to be drawn. If the current raster position is invalid, nothing is drawn, and the raster position remains invalid" say I set the format to GL_RGB, and the type to GL_UNSIGNED_BYTE that means every pixel will be 3*8 = 24 bits. So the GLvoid *pixels will have to point to an array of structures the size of width * height? I think I answered my own question and should probably just use trial and error. But, thanks in advance.
Sounds like you''ve figured it out.

Billy - BillyB@mrsnj.com
(Hey, I''''m no longer anonymous!)
Advertisement
GL_RGB = (8 + 8 + 8) = 24 bits.

so array size = (widht * height * 3) bytes.

this function is also affected by....

glPixelRasterPos
glPixelStore
glPixelTransfer
glPixelMap
glPixelZoom

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

This topic is closed to new replies.

Advertisement