View Full Version : glDrawPixels() help

10-14-2012, 12:06 PM
So, I am trying to use glDrawPixels() to draw points on the screen but can't get it to work properly. Right now it draws the points I want, but then repeats the points in the same position on the y-axis but translated over a few pixels on the x-axis repeatedly.

I am creating a pixel buffer like so:

struct RGBType {
float r;
float g;
float b;

RGBType *pixel_buffer = new RGBType[800 * 1200];

Then filling in the rgb components I want to show up on the screen

pixel_buffer[800*y + x].r=0.5;
pixel_buffer[800*y + x].g=0.5;
pixel_buffer[800*y + x].b=0.5;

and then calling drawpixels and swapping the buffers

glDrawPixels(window_width, window_height, GL_RGB, GL_FLOAT, pixel_buffer);
delete[] pixel_buffer;

All my other code is simply setting up a window with glut.

10-16-2012, 10:57 PM
Maybe you are using some other function that is causing the raster position to change. Call glRasterPos before calling glDrawPixels.