# Refreshing a window during a resize event

**URL:** <https://discourse.glfw.org/t/refreshing-a-window-during-a-resize-event/357>\
**Category:** support\
**Created:** [September 4, 2005, 10:31pm UTC](https://discourse.glfw.org/t/refreshing-a-window-during-a-resize-event/357 "2005-09-04T22:31:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [September 4, 2005, 10:31pm UTC](https://discourse.glfw.org/t/refreshing-a-window-during-a-resize-event/357/1 "2005-09-04T22:31:25Z")

</div>

**nobody** wrote on [Sunday, September 04, 2005](https://sourceforge.net/p/glfw/discussion/247562/thread/65212190/#f4cc):

Hello everyone!

Suppose we have following code:

void GLFWCALL windowResize( int w, int h )  
{  
glClear( GL\_COLOR\_BUFFER\_BIT );  
std::cout \<\< w \<\< ’ ’ \<\< h \<\< std::endl;  
// glfwSwapBuffers /\* 1 \*/  
}

int main( int argc, char \*\*argv )  
{  
…  
while( !finished ) {  
doSomething();  
glfwSwapBuffers();  
}  
…  
}

Now, events are processed during glfwSwapBuffers() call in the main loop. While resizing the program’s window I can see that windowResize( int w, int h ) is being called several times until I release the mouse button. However window’s content doesn’t get redraw. It’s updated (by glClear()) after I stop to resize the window. Things are yet different if I uncomment line marked “1”: now window’s content gets updated instantly, I don’t need to release the button. How come?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [September 18, 2005, 10:43am UTC](https://discourse.glfw.org/t/refreshing-a-window-during-a-resize-event/357/2 "2005-09-18T10:43:31Z")

</div>

**nobody** wrote on [Sunday, September 18, 2005](https://sourceforge.net/p/glfw/discussion/247562/thread/65212190/#f4cc/82f2):

I would have to see more of the code to give you an exact answer but what I think is happening (going on the info that you gave) is that the glfwSwapBuffers is instantly fliping the buffers. I do a similar thing in my code if the window is resized using glfwSetWindowRefreshCallback. Also try taking out the swapbuffers and the glClear and then see what happens.
