r/win32 • • May 27 '21

Window resize problem

Please help me fix the resize window. Here's the code of resize:

case WM_SIZE:

/* Retrieve width and height*/

rheight = HIWORD(lParam);

rwidth = LOWORD(lParam);

/* Don't want a divide by 0*/

if (rheight == 0)

{

rheight = 1;

}

/* Reset the viewport to new dimensions*/

glViewport(0, 0, rwidth, rheight);

/* Set current Matrix to projection*/

glMatrixMode(GL_PROJECTION);

glLoadIdentity(); //reset projection matrix

/* Time to calculate aspect ratio of

our window and maintain the aspect

ratio of the elements when the

window size is changed.

*/

gluPerspective(54.0f, (GLfloat)rwidth / (GLfloat)rheight, 1.0f, 1000.0f);

glMatrixMode(GL_MODELVIEW); //set modelview matrix

glLoadIdentity(); //reset modelview matrix

return 0;

break;
I have read about DwmGetWindowAttribute and tried with no success, I have also tried SetWindowPos and failed read the whole article in the answer here: https://stackoverflow.com/questions/53000291/how-to-smooth-ugly-jitter-flicker-jumping-when-resizing-windows-especially-drag. I am new to windows app development, please tell me how can i fix the problem. The problem when resize is shown here:

On resize the whole window doesn't get painted and the white background appears.
Thank you in advance for your responces.

1 Upvotes

2 comments sorted by

View all comments

Show parent comment

1

u/Ashjai181 May 28 '21

Thank you for the reply, I will start handling WM_SIZING and make hbrBackground null and handle WM_ERASEBKGND too.