So I work these days with sdl, and I wanted to make a little easy my work, so I started to make with class. The real problem showed up when I declared window
so from this constructor, I get errors like C2597 illegal reference to non-static member "Display::window" - for all window instances and "Display::GLContext" and "Display::running"
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <string.h>
class Display
{
public:
Display(string& title, int width, int height);
~Display();
void Run();
bool running = true;
private:
SDL_Window* window;
SDL_GLContext GLcontext;
};
thats my header, and every non-functions/non-methods get this error every time it's used
Did you try making the private SDL_Window* window; a static member?
static SDL_Window* window;
If that works you can probably guess what I'll ask about the GLContext...
As far as I understand it, SDL_Init(SDL_INIT_EVERYTHING); should only be called once, I don't know if an error occurs if it's called more than once, I'm not near a computer with SDL installed at the moment.
If so you might be able to wrap it in an #ifndef macro like you would a header file.
Anyone know if that would do the trick inside a class function?