I've been some research on a bug i'm facing right now, it turns out that C++ initializes classes before runtime (and calling the main function). My program however, is an opengl program which requires certain things to be set up before anything else is done.... Is there any way to fix this? The problem is simple, but here's some pseudo/c++ code anyways:
class shader
{
shader() { /* constructor... DEPENDS ON GL SET UP! But called first!*/ }
}
// global/static shaders
shader geometry;
shader lighting;
int main()
{
glewInit(); // initialize opengl
}
Edit: Added some more info based off comments. Yes, my shader classes are static and they are the problem. The only solution is to make these static classes into pointers and allocate them after main's initialization is finished? Or is there a way to delay initialization?