I highly recommend that you take a look at some OpenGL tutorials ( http://nehe.gamedev.net/ is a good site, it will tell you everything you need to know), but if you had OpenGL configured correctly in your code, you would have done that something like that in my DrawRectWithOpenGL function (I'm not a C ++ programmer, but I think my code looks right for C ++):
void DrawRectWithOpenGL(RECT* pRect) { glPushMatrix();
OpenGL does not have a 2D drawing API, but it is easy to execute 2D objects by simply ignoring the Z axis (or simply using the Z axis to ensure that the sprites are drawn at the correct depth, i.e. you can draw a background after the foreground, because the background depth is set so that it lies behind the foreground). Hope this helps. Definitely take the time to look at some lessons and everything will become clear.
EDIT : To configure OpenGL for a 2D drawing, you need to set up spelling projection (the tutorials I linked use predictive projection, sorry, without mentioning this). Here is an example of my code that does this (which should be somewhere in your InitOpenGL function after creating your window):
glClearColor(0.0, 0.0, 0.0, 0.0); //Set the cleared screen colour to black glViewport(0, 0, screenwidth, screenheight); //This sets up the viewport so that the coordinates (0, 0) are at the top left of the window //Set up the orthographic projection so that coordinates (0, 0) are in the top left //and the minimum and maximum depth is -10 and 10. To enable depth just put in //glEnable(GL_DEPTH_TEST) glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, screenwidth, screenheight, 0, -10, 10); //Back to the modelview so we can draw stuff glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); //Clear the screen and depth buffer
So, initialization sorting. You should be able to use values โโsuch as 100 and 200, and display them correctly on the screen, i.e. Coordinates are in pixels.
To handle window resizing, you have to find the window size (using an external library. I'm not sure you can do it in OpenGL, although glutGet (GLUT_WINDOW_WIDTH) and glutGet (GLUT_WINDOW_HEIGHT) from GLUT may work, but I haven't tested it), and then call glViewport and glOrtho again with the updated window size.
Again, you will have to use an external library to find out when the window is resized. I'm not sure what you could use, although if you use SDL then it might have some event handling (and maybe it will be able to return the width and height of the screen if glutGet doesn't work).
Hope this helps!