opengl - GLFW - One context for all windows -
i want draw opengl graphics multiple windows. windows 'lead' same 'world' far know there 2 options:
share context between windows. it's pretty straightforward task glfw , have progress that, however, code becomes more , more obscure , know opengl isn't multithreaded there no benefit rendering multiple contexts multiple threads.
i saw advice have single context , use rendering of windows 1 one, i.e. render first window, swap buffers, render second one, swap buffers, render first 1 again , on.
however, cannot determine possible go option 2 glfw. window , context tightly tied each other in library's concept.
you can create multiple contexts , "share lists", see the documentation:
when creating window , opengl or opengl es context
glfwcreatewindow
, can specify window context new 1 should share objects (textures, vertex , element buffers, etc.) with.
glfwwindow* second_window = glfwcreatewindow(640, 480, "second window", null, first_window);
this allow avoid duplicating of assets textures , buffers each window.
you assert opengl not multithreaded. multiple threads can simultaneously use multiple contexts. modern gpus have multiple command queues, parallelism depend on display driver , hardware capabilities. in case, utilizing multiple processors net gain, if overhead introduced using multiple threads, assuming render threads not trivial.
even if did make 1 context current on each window 1 @ time, introduces overhead well, being synchronous , sequential. i'll take concurrency + overhead on sequential + overhead anyday.
Comments
Post a Comment