bool Renderer::Init(int width, int height) { // Create our SDL window mWindow = SDL_CreateWindow("ITP Engine 2 Demo!", 100, 100, width, height, 0); if (!mWindow) { SDL_Log("Could not create window."); return false; } mGraphicsDriver = std::make_shared<GraphicsDriver>(GetActiveWindow()); mInputLayoutCache = std::make_shared<InputLayoutCache>(); mWidth = width; mHeight = height; if (!InitFrameBuffer()) { return false; } if (!InitShaders()) { return false; } if (!InitSpriteVerts()) { return false; } return true; }
bool Renderer::Init(int width, int height) { // Tell SDL we want to use OpenGL 3.3 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); // Request some GL parameters, just in case SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // Create our SDL window mWindow = SDL_CreateWindow("Lab 3: Tower Defense", 100, 100, width, height, SDL_WINDOW_OPENGL); if (!mWindow) { SDL_Log("Could not create window."); return false; } // Create an OpenGL context mContext = SDL_GL_CreateContext(mWindow); // Start up GLEW to bind OpenGL functions glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { SDL_Log("Failed to initialize GLEW."); return false; } // Glew may still post an error, so clear it... glGetError(); mWidth = width; mHeight = height; if (!InitFrameBuffer()) { return false; } if (!InitShaders()) { return false; } if (!InitSpriteVerts()) { return false; } return true; }