Drawing a pixel

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;
};

Did you set the modelview and projection matrix correct so the raster position is actually mapped to window coordinates?

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?

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.

Thanks,
I’ll try it.