PDA

View Full Version : Drawing a pixel



dzoni
11-01-2002, 12:29 PM
I just wanted to draw pixels in window coordinates, but it doesn't seem to work (i get nothing on screen). What did I do wrong? Thanks.

GLubyte pixel[4];

void setPixel(int posx,int posy) {
glRasterPos2i(posx,posy);
glDrawPixels(1,1,GL_RGBA,GL_UNSIGNED_BYTE,pixel);
};

void setColor(GLubyte r,GLubyte g,GLubyte b,GLubyte a) {
pixel[0]=r;
pixel[1]=g;
pixel[2]=b;
pixel[3]=a;
};

Bob
11-01-2002, 12:32 PM
Did you set the modelview and projection matrix correct so the raster position is actually mapped to window coordinates?

dzoni
11-01-2002, 12:39 PM
Thanks, you're right,
I left them be default (loadIdentity()). But is there a way to draw a pixel on a specific window position (in colorbuffer) regardless of modelview / projection matrices?

Bob
11-01-2002, 01:13 PM
There's an extension called ARB_window_pos you can use. It's in the core of OpenGL 1.4 in case it's not in your extension list.

dzoni
11-02-2002, 01:41 AM
Thanks,
I'll try it.