When porting code that involves pixel operations, keep the following points in mind:
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 | Read a block of pixels from the frame buffer. |
| lrectwrite, rectwrite | glDrawPixels | Write a block of pixels to the frame buffer. |
| rectcopy | glCopyPixels | Copy pixels in the frame buffer. |
| rectzoom | glPixelZoom | Specify pixel zoom factors for glDrawPixels and glCopyPixels. |
| cmov | glRasterPos | Specify raster position for pixel operations. |
| readsource | glReadBuffer | Select a color buffer source for pixels. |
| pixmode | glPixelStore, glPixelTransfer |
Set pixel storage modes. Set pixel transfer modes. |
| logicop | glLogicOp | Specify a logical operation for pixel writes. |
| — | glEnable(GL_LOGIC_OP) | Turn 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);