Is it possible to resize an openGL window (or device context) created with wglCreateContext without disabling it? If so how? Right now I have a function which resizes the DC but the only way I could get it to work was to call DisableOpenGL and then re-enable. This causes any textures and other state changes to be lost. I would like to do this without the disable so that I do not have to go through the tedious task of recreating the openGL DC state.
HWND hWnd;
HDC hDC;
void View_setSizeWin32(int width, int height) {
// resize the window
LPRECT rec = malloc(sizeof(RECT));
GetWindowRect(hWnd, rec);
SetWindowPos(
hWnd,
HWND_TOP,
rec->left,
rec->top,
rec->left+width,
rec->left+height,
SWP_NOMOVE
);
free(rec);
// sad panda
/*
DisableOpenGL( hWnd, hDC, hRC );
EnableOpenGL( hWnd, &hDC, &hRC );
*/
//EDIT - instead do this....
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-(width/2), width/2, -(height/2), height/2, -1.0, 1.0);
}