# Child window winth GLFW3 blocking OpenGL Main application

**URL:** <https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108>\
**Category:** support\
**Created:** [December 19, 2014, 4:19pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108 "2014-12-19T16:19:32Z")\
**Posts on this page:** 13\
**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:** [December 19, 2014, 4:19pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/1 "2014-12-19T16:19:32Z")

</div>

**[karistouf](https://sourceforge.net/u/karistouf/)** wrote on [Friday, December 19, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#cc73):

Hello, i have choosen GLFW3 to generate from an existing application i m developping a separate renderer

i m on windows, with Codeblocks and mingw, and i m using for my main app an old lib called OpenLayer, based on AllegroGL and allegro 4.4 gamelibrary.

My main app is quite hudge, opensource, and is used in theatre to handle lights , sound and is used professionnaly quite widely.

Openlayer is an old OpenGl wrapper for 2D usage, you can find it there:

> **[ChristophGuillermet/WHITECAT\_opensource](https://github.com/ChristophGuillermet/WHITECAT_opensource/tree/master/openlayer-2.1)**
>
> The free open source lighting software. Contribute to ChristophGuillermet/WHITECAT\_opensource development by creating an account on GitHub.

  
and my software can be seen there: [http://www.le-chat-noir-numerique.fr/](http://www.le-chat-noir-numerique.fr/)

I m trying to get GLFW 3.0 working but i have a real problem:  
creating a window is disabling refreshment of the main app. keyboard is working, but when i create a window it kills the refreshing process.

is there any trick to avoid it ?

thxs

Does anyone has any on how to allow from the same main loop the two rendering ?

---

<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:** [December 19, 2014, 5:02pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/2 "2014-12-19T17:02:47Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Friday, December 19, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#0648):

I think it’s likely that the issue you’re seeing is that to render with opengl you need to specify the context prior to sending commands - [see the manual for glfw on contexts](http://www.glfw.org/docs/latest/context.html) and [I think this is the Allegro documentation for similar](https://www.allegro.cc/manual/5/al_set_current_opengl_context).

---

<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:** [December 19, 2014, 5:14pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/3 "2014-12-19T17:14:46Z")

</div>

**[karistouf](https://sourceforge.net/u/karistouf/)** wrote on [Friday, December 19, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#0648/308e):

hello doug, thx for answer.

Helas this is a 5.0 feature, i m using the allegro 4.4, wich is in fact a complete different library. so it doens t exist.

what could be a solution ?

---

<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:** [December 19, 2014, 6:00pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/4 "2014-12-19T18:00:03Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Friday, December 19, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#be7c):

Then I think your solutions are one of:

1. Write a cross platform API for context setting, and use that. See the GLFW example code - on Windows the function you need to get the context is wglGetCurrentContext and the set function is wglMakeCurrent.
2. Upgrade to Allegro 5.0
3. Move all windowing to GLFW.
4. Ask on the Allegro forums (as the issue is Allegro 4.4 not being able to set the current context by the sounds).

---

<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:** [December 19, 2014, 6:25pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/5 "2014-12-19T18:25:57Z")

</div>

**[karistouf](https://sourceforge.net/u/karistouf/)** wrote on [Friday, December 19, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#651d):

hum… point 2 and 3 are not possible. despite it should be a better solution  
Actually TOO much work ( its a big big big app)

ok i will work around the wglGetCurrentContext 🙂 thanks a lot !!!

btw: all examples are in a while loop, how are you handling multiple windows with refreshment ?

---

<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:** [December 19, 2014, 7:51pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/6 "2014-12-19T19:51:25Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Friday, December 19, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#487a):

For refreshment, use [glfwSetWindowRefreshCallback](http://www.glfw.org/docs/latest/group__window.html#ga4569b76e8ac87c55b53199e6becd97eb) to get the refresh callback, this receives the GLFWwindow pointer of the window to be refreshed and then you refresh it.

For Allegro, no idea!

---

<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:** [December 20, 2014, 10:46am UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/7 "2014-12-20T10:46:28Z")

</div>

**[karistouf](https://sourceforge.net/u/karistouf/)** wrote on [Saturday, December 20, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#3d10):

hello Doug, is there any simple example ( i m not used to those concepts) to see how to use this structure ?

---

<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:** [December 20, 2014, 12:26pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/8 "2014-12-20T12:26:08Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Saturday, December 20, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#959c):

I don’t think there is a multi-window example available, but if you’re struggling with the callback syntax look at the [splitview example](https://github.com/glfw/glfw/blob/master/examples/splitview.c) main function. Line 471 sets the callback to the function static void windowRefreshFun(GLFWwindow\* window).

---

<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:** [December 20, 2014, 12:50pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/9 "2014-12-20T12:50:03Z")

</div>

**[karistouf](https://sourceforge.net/u/karistouf/)** wrote on [Saturday, December 20, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#a45d):

thanks a lot doug, i will keep you informed

---

<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:** [December 21, 2014, 9:00am UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/10 "2014-12-21T09:00:27Z")

</div>

**[karistouf](https://sourceforge.net/u/karistouf/)** wrote on [Sunday, December 21, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#4425):

Hum… i m reconsidering completly the approach. child widow of my app will be tto much ressources consumming.

so i would like to write a second app with child window with GLFW and GLEW.

My main question actually is: where can i found a sample to have a main window and a child window, to understand how to call them ?

“just” in need of a GUI, and a rendering window

---

<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:** [December 21, 2014, 11:20am UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/11 "2014-12-21T11:20:56Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Sunday, December 21, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#4425/1b92):

I do not know of any such samples, though a quick google search did find a  
tutorial:  
[http://blog.gvnott.com/2013/05/18/tutorial-multiple-windows-with-glfw3-and-glew-mx/](http://blog.gvnott.com/2013/05/18/tutorial-multiple-windows-with-glfw3-and-glew-mx/)

On 21 December 2014 at 10:00, CHRISTOPH [karistouf@users.sf.net](mailto:karistouf@users.sf.net) wrote:

> Hum… i m reconsidering completly the approach. child widow of my app  
> will be tto much ressources consumming.
> 
> so i would like to write a second app with child window with GLFW and GLEW.
> 
> ## My main question actually is: where can i found a sample to have a main window and a child window, to understand how to call them ?
> 
> ## Child window winth GLFW3 blocking OpenGL Main application [https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/?limit=25#4425](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/?limit=25#4425)
> 
> Sent from [sourceforge.net](http://sourceforge.net) because you indicated interest in  
> [GLFW / Discussion / Using GLFW](https://sourceforge.net/p/glfw/discussion/247562/)
> 
> To unsubscribe from further messages, please visit  
> [SourceForge.net: Log In to SourceForge.net](https://sourceforge.net/auth/subscriptions/)

---

<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:** [December 21, 2014, 3:18pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/12 "2014-12-21T15:18:30Z")

</div>

**[karistouf](https://sourceforge.net/u/karistouf/)** wrote on [Sunday, December 21, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#ccfa):

yep, but MSVC, no code blocks…

---

<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:** [December 21, 2014, 3:20pm UTC](https://discourse.glfw.org/t/child-window-winth-glfw3-blocking-opengl-main-application/108/13 "2014-12-21T15:20:08Z")

</div>

**[dougbinks](https://sourceforge.net/u/dougbinks/)** wrote on [Sunday, December 21, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/#ccfa/7323):

The basics should remain the same - it’s all code, you just need to figure  
out project settings which should be the same for a single window app.

On 21 December 2014 at 16:18, CHRISTOPH [karistouf@users.sf.net](mailto:karistouf@users.sf.net) wrote:

> ## yep, but MSVC, no code blocks…
> 
> ## Child window winth GLFW3 blocking OpenGL Main application [https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/?limit=25#ccfa](https://sourceforge.net/p/glfw/discussion/247562/thread/e364b14a/?limit=25#ccfa)
> 
> Sent from [sourceforge.net](http://sourceforge.net) because you indicated interest in  
> [GLFW / Discussion / Using GLFW](https://sourceforge.net/p/glfw/discussion/247562/)
> 
> To unsubscribe from further messages, please visit  
> [SourceForge.net: Log In to SourceForge.net](https://sourceforge.net/auth/subscriptions/)
