View Full Version : Plotting Pixels--how?

01-19-2001, 05:24 PM
Is there a simple command, like PlotPixel(x,y,color) in OpenGL? Or do I need to load as a textrue?

Tim Stirling
01-20-2001, 12:51 AM
Use glVertex in orthographic projection or use glDrawPixels(x,y); use glColor to set the color. I havn't actualy used glDrawPixels but I will any day now. http://www.opengl.org/discussion_boards/ubb/smile.gif


01-22-2001, 06:22 PM
It took me a while, but I finally figured out
how to write individual pixels to the framebuffer. glDrawPixels is nice, but its slow, and you can't control each and every pixel. Doing it the following way overcomes that problem:

BYTE *aBitmap = some bitmap data;

for (y=0.0;y<128.0;y=y+1) {
for (x=0.0;x<256.0;x=x+1) {
glColor3f((float)((float)aBitmap[index+2]/255.0), (float)((float)aBitmap[index+1]/255.0), (float)((float)aBitmap[index]/255.0));
// calculate the index for an x and y.
index = ((int)x + ((int)y * 256)) * 3;

This is for a 256X128 texutre at 24 bit
resolution, hence the need to step by three bytes everytime. Hope this helps... it sure helps me. http://www.opengl.org/discussion_boards/ubb/smile.gif

01-22-2001, 06:33 PM
A couple things I forgot to metion:
(1) the image data is in BGR format, that is
blue byte, green byte, red byte.

(2) the x * .999, and y * .999 is required on
at least my 3d card in order to keep the
vertices packed together (no spaces).

Let me know if anyone can find a way to speed this up.