I’m looking to set-up a basic loading screen and have all the graphics loaded dynamicly in a second thread but im getting a error saying there is no openGL context in the current thread… i understand why this problem is happening, but i am wanting to know how can i achieve the desired effect im looking for, any ideas?
OpenGL is “bound” to a single thread. This means that you need to do all OpenGL calls from the main thread, which obviously also is the one that draws the loading screen (using OpenGL). It is possible to create a second context for the loading thread that shares (some) data with the main context. However, due to an unfathomably stupid design decision only OpenGL objects that contain data are shared. For example textures and VBOs are shared, but FBOs and VAOs aren’t because they only reference other objects. If you design your engine/game around this from the start, it is relatively easy to work around this (load VBOs and texture in shared context, load cheap FBOs and VAOs in the main thread). Another much more complicated solution would be to have the second thread place work that the main thread has to do in a queue which the main thread queries each time it redraws the loading screen. This is much more time-consuming to implement but can work really well.
For such a small part it seems like overkill, i have made somewhat of a solution where in the Display Thread, once the loading screen is loaded it will begin rendering graphics but obviously i will get like 1 Frame Per 30 seconds xD