WIN32 and Window-Resize

Hello,

I develope an OpenGL-App with the WIN32-API, but my problem is, when I resize the Window of my application, the graphics are not resized. Under Glut there is no problem.
My code:

GetClientRect(hWnd, &rect);
glViewport(0, 0, (GLsizei)rect.right, (GLsizei)rect.bottom);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, rect.right, 0, rect.bottom);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
//Draw Code
SwapBuffers(hDC);

Can anybody help me?

Bye

Hello,
You just have to put the resize routine in the OnResize event of your project…(ifit is not done yet)

Maxime.

Originally posted by Maxime:
[b]Hello,
You just have to put the resize routine in the OnResize event of your project…(ifit is not done yet)

Maxime.[/b]

In WIN32 API I have no OnResize Function, but I put these “Resize”-commands into the CALLBACK-Function of my OpenGL-Window, like this:

LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {

switch(msg) {

case WM_PAINT: //or WM_SIZE
GetClientRect(hWnd, &rect);
glViewport(0, 0, (GLsizei)rect.right, (GLsizei)rect.bottom); glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, rect.right, 0, rect.bottom); glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
return 0;

}

}

… but it didn’t work. I really don’t know why.

Bye

I put these

I use this code :
In the windows proc :

case WM_SIZE:
wi->Reshape(LOWORD(lParam), HIWORD(lParam));
return 0;

The reshape function of my gl window class :

BOOL GL_Window::Reshape(UINT32 width,UINT32 height)
{
w=width;
h=height;
glViewport (0, 0, w, h);
firstmove=TRUE;
return TRUE;
}

Works fine for ages now, enjoy it

Originally posted by paddy:
[b]I use this code :
In the windows proc :

case WM_SIZE:
wi->Reshape(LOWORD(lParam), HIWORD(lParam));
return 0;

The reshape function of my gl window class :

BOOL GL_Window::Reshape(UINT32 width,UINT32 height)
{
w=width;
h=height;
glViewport (0, 0, w, h);
firstmove=TRUE;
return TRUE;
}

Works fine for ages now, enjoy it [/b]

I think it is almost the same like mine. But this don’t work. I think, maybe I do something wrong, when I define my windowclass, or when I create my window. But I don’t know what. The other GL-commands works fine.

Bye