Closed acdemiralp closed 9 years ago
Hi, You can for example use the Optional<Object>
wrapper (implemented in oglplus/object/optional.hpp
). The default constructor of Optional
does not attempt to initialize the GL object and can be move-assigned later.
Ah this is exactly what I was seeking, thank you very much.
Hello, I am attempting to write a simple graphics sandbox using oglplus. However even just declaring most of the structures (all except oglplus::Context) prior to setting up a GL context results in a runtime error. This prevents my engine structures to carry any oglplus members such as:
This will fail the first time I reference it in the code such as:
This is because window and context are not initialized at the time the constructor of Mesh_Renderer is called (and hence all the VertexArray and Buffer's constructors are called prior to context creation).
Everything obviously works fine if I convert VertexArray and Buffer members to pointers to objects and summon them separately on the heap after creating the context, e.g. in the start() method.
I know that oglplus is a thin wrapper, and I know that it does OGL calls in the constructor in order to closely couple the object with its OGL counterpart.
But could there be a way to delay the initialization of the oglplus structures to the context creation so I can declare them as members of objects?