Porting Pixel Operations

When porting code that involves pixel operations, keep the following points in mind:

  • Logical pixel operations are not applied to RGBA color buffers. For more information, see glLogicOp.
  • In general, IRIS GL uses the format ABGR for pixels, whereas OpenGL uses RGBA. You can change the format with glPixelStore.
  • When porting lrectwrite functions, be careful to note where lrectwrite is writing (for example, it could be writing to the depth buffer).

OpenGL gives you some additional flexibility in pixel operations. The following table lists IRIS GL functions for pixel operations and their equivalent OpenGL functions.

IRIS GL function OpenGL function Meaning
lrectread, rectread,readRGB
glReadPixels Reads a block of pixels from the framebuffer.
lrectwrite, rectwrite glDrawPixels Writes a block of pixels to the framebuffer.
rectcopy glCopyPixels Copies pixels in the framebuffer.
rectzoom glPixelZoom Specifies pixel zoom factors for glDrawPixels and glCopyPixels.
cmov glRasterPos Specifies raster position for pixel operations.
readsource glReadBuffer Selects a color buffer source for pixels.
pixmode glPixelStore,glPixelTransfer Sets pixel storage modes.Set pixel transfer modes.
logicop glLogicOp Specifies a logical operation for pixel writes.
glEnable ( GL_LOGIC_OP ) Turns on pixel logic operations.

For a complete list of possible logical operations, see glLogicOp.

This IRIS GL code sample shows a typical pixel write:

unsigned long *packedRaster; 
packedRaster[k] = 0x00000000; 
lrectwrite(0, 0, xSize, ySize, packedRaster);

The preceding code looks like this when translated to OpenGL:

glRasterPos2i( 0, 0); 
glDrawPixels( xSize + 1, ySize + 1, GL_RGBA, GL_UNSIGNED_BYTE, packedRaster);