Basically im trying to create an interface using the windows api and opengl to display the graphics so i can have a file menu at the top etc..
Hard for me to explain this only just begun to learn the basics of the api but this is what ive gathered so far..
Heres my main loop,
hdc = GetDC(hwnd);
EnableOpenGL(hwnd, &hdc, &hrc);
while(!Done)
{
if(!PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )){ //if no messages then redraw window
UpdateWindow(hwnd);
}
else{
if(msg.message == WM_QUIT)
Done = true;
}
TranslateMessage(&msg); //translate keyboard messages
DispatchMessage(&msg); //sends the message to our window procedure message handler
}
DisableOpenGL(hwnd, hdc, hrc);
So here i thought if windows is not processing any messages then draw the window a sort of idle msg is that right ?
Then in my message handler function i thought i would do something like,
switch(message)
{
case WM_PAINT:
GetClientRect(hwnd, &rect); //gets the current dimensions of the window
DrawText(hdc, TEXT("Some text in the middle of the screen!!"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); //draw some text in the center of the screen
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT );
glPushMatrix();
glBegin( GL_TRIANGLES );
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f );
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f );
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f );
glEnd();
glPopMatrix();
SwapBuffers( hdc );
return 0;
break;
}
My problem is the window is not refreshing properly because at the moment its drawing wierdly like if you move the window around you can see the window flashing black then drawing the triangle... As if its not taking into account the double buffering.
Thx alot for any help.
fishy.