I want to create a high performace 2D program.
I\'m using VC++2008. Suppose I have created the main window. What I want is to draw a red rectangle (top left: 10,20,
Thank SuperMaximo93. I fininally got my code to work. Here is my code on window's size is changed. The function below is called in WM_SIZE's handler.
void OpenGlWindow::Resize(HWND hwnd)
{
// Get new window size
RECT rect;
int width, height;
GetClientRect(hwnd, &rect);
width = rect.right;
height = rect.bottom;
glClearColor(0.0, 0.0, 0.0, 0.0); //Set the cleared screen colour to black
glViewport(0, 0, width, height); //This sets up the viewport so that the coordinates (0, 0) are at the top left of the window
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//Back to the modelview so we can draw stuff
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(180, 1.0f, 0, 0);
glTranslatef(-1.0f, -1.0f, 0);
glScalef(2.0f/width, 2.0f/height, 1);
glTranslatef(2.0f, 2.0f, 0);
}