Drawing to Win32 Window Pixels

Hi,

Is there a way to specify a color for each pixel of a window and tell GL to draw it as so? Code example would be nice.

I’ve been borrowing the framework of the nehe.gamedev.net VC++ code.

thanx for any help,

-n

ok, i found a way to do this, altho’ i’m pretty sure it’s not very efficient. any feedback or suggestions?

in ResizeGLScene i have:

gluOrtho2D(-(GLfloat)width/2.0, (GLfloat)width/2.0, -(GLfloat)height/2.0,(GLfloat)height/2.0);

so each pixel is one unit in the GL coordinate axes.

i use gluUnProject to get the coordinates of a window pixel into GL coordinates.

// xPos and yPos are i.e. from a mouse-click
int xPos = LOWORD(lParam);
int yPos = HIWORD(lParam);
GLdouble x, y, z;
GLdouble mvm[16], pm[16];
GLint vp[4];
glGetDoublev(GL_MODELVIEW_MATRIX, mvm);
glGetDoublev(GL_PROJECTION_MATRIX, pm);
glGetIntegerv(GL_VIEWPORT, vp);
gluUnProject(xPos, yPos, 0, mvm, pm, vp, &x,&y, &z);

then i do my 2D drawing with x, y, and z (z is always 1.0).

-n