I amm following the tutorial and it works perfectly for him, I understand everything but somehow the code does not work. This time I got errors. So here are they are.
Errors:Error 1 error C2065: 'display' : undeclared identifier
Error 2 error C2228: left of '.IsClosed' must have class/struct/union
error C2761: 'bool Display::IsClosed(void)' : member function redeclaration not allowed
Display::Display(int width, int height, const std::string& title)
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); // The quality of each Prime color.
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);//8 is the best.
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);//Because we want specific number of memoryfor each so 8*4
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); //Gives space for 2 windows
m_window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
m_glContext = SDL_GL_CreateContext(m_window);//creates context so OS is influencing GPU which is drawing using Opengl.
GLenum status = glewInit();//starts glew and it searches OS for OpenGL we support.
Display::~Display()
{
SDL_GL_DeleteContext(m_glContext);//going backwards and destroying everything since we did gl context last ^
SDL_DestroyWindow(m_window);//before that, this.
SDL_Quit();
}
From the issues you're describing, it would seem a C++ language tutorial would be more advantageous for you than an OpenGL tutorial, since all of those issues are simple language/syntax misunderstandings.
1 2 3 4
int main ()
{
Display display(800, 600, "Hello World");while(!display.IsClosed())
You need to drop the semi-colon after the prototype in your definition of Display::IsClosed