How can I draw in two windows using OpenGL?

I am building a game engine. The structure looks like this: there is a Core class, an object of which is created when the program starts, modules (Module class) connect to the core and have workers (Worker class). Workers are divided into two types: normal and graphic. I did this to organize the game loop.

So, I create a GLFWOpenGLModule, which, as the name suggests, uses GLFW to create a window and OpenGL to draw on that window. But GLFW does not allow you to create two windows and draw in each one. I can make GLFWOpenGLModule singleton by adding this code:

static int objectsCount = 0;
objectsCount++;
if (objectsCount > 1)
   throw SomeKindOfException("error message");

      

in the constructor and don't create two windows in the module, but then I cannot make two windows (for example, to render multiple cameras, each camera in each window). How should I do it in this case? Maybe I need to use a different library instead of GLFW?

+3


source to share





All Articles