+ ogl_LoadFunctions();
+
+ // Why is this so horribly broken?
+ if (ogl_IsVersionGEQ(3,0))
+ {
+ Fatal("We require OpenGL 3.1, but you have version %d.%d!",ogl_GetMajorVersion(), ogl_GetMinorVersion());
+ }
+
+ if (!SDL_GL_ExtensionSupported("GL_ARB_shading_language_420pack"))
+ {
+ Fatal("Your system does not support the ARB_shading_language_420pack extension, which is required.");
+ }
+
+ if (!SDL_GL_ExtensionSupported("GL_ARB_explicit_attrib_location"))
+ {
+ Fatal("Your system does not support the ARB_explicit_attrib_location extension, which is required.");
+ }
+
+ m_frame_begin_time = SDL_GetPerformanceCounter();
+ m_last_frame_time = 0;
+ m_last_frame_gpu_timer = 0;
+ glGenQueries(1, &m_frame_gpu_timer);
+ glBeginQuery(GL_TIME_ELAPSED, m_frame_gpu_timer);
+
+ glDebugMessageCallback(opengl_debug_callback, 0);
+
+ GLuint default_vao;
+ glGenVertexArrays(1, &default_vao);
+ glBindVertexArray(default_vao);
+
+ //TODO: Error checking.
+ m_texture_prog.AttachVertexProgram(BASICTEX_VERT);
+ m_texture_prog.AttachFragmentProgram(BASICTEX_FRAG);
+ m_texture_prog.Link();
+ m_texture_prog.Use();
+
+ // We always want to use the texture bound to texture unit 0.
+ GLint texture_uniform_location = m_texture_prog.GetUniformLocation("tex");
+ glUniform1i(texture_uniform_location, 0);
+
+ m_colour_uniform_location = m_texture_prog.GetUniformLocation("colour");
+
+ m_viewport_ubo.SetUsage(GraphicsBuffer::BufferUsageDynamicDraw);
+ m_viewport_ubo.SetType(GraphicsBuffer::BufferTypeUniform);
+