|
|
|
|
@ -28,9 +28,10 @@
|
|
|
|
|
// forward declarations
|
|
|
|
|
void openglDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, |
|
|
|
|
GLsizei length, const GLchar* message, const void* userParam); |
|
|
|
|
bool initSDL(SDL_Handles& handles, v2i& viewport_dims); |
|
|
|
|
bool initContext(SDL_Handles& handles); |
|
|
|
|
bool initGL(); |
|
|
|
|
bool initSDL(SDL_Handles& handles); |
|
|
|
|
bool createWindow(SDL_Handles& handles, v2i& viewport_dims); |
|
|
|
|
bool initGlContext(SDL_Handles& handles); |
|
|
|
|
bool initGlOptions(); |
|
|
|
|
bool initDebugRenderGroup(render_state* rs); |
|
|
|
|
void setDefaults(render_state* rs); |
|
|
|
|
|
|
|
|
|
@ -43,9 +44,10 @@ renInit()
|
|
|
|
|
render_state* rs = UTIL_ALLOC(1, render_state); |
|
|
|
|
setDefaults(rs); |
|
|
|
|
|
|
|
|
|
if (initSDL(rs->handles, rs->viewport_dims) && |
|
|
|
|
initContext(rs->handles) && |
|
|
|
|
initGL() && |
|
|
|
|
if (initSDL(rs->handles) && |
|
|
|
|
createWindow(rs->handles, rs->viewport_dims) && |
|
|
|
|
initGlContext(rs->handles) && |
|
|
|
|
initGlOptions() && |
|
|
|
|
rgInitShaderProgram(rs->default_shader, DEFAULT_VERTEX_SHADER, DEFAULT_FRAGMENT_SHADER) && |
|
|
|
|
initDebugRenderGroup(rs) ) |
|
|
|
|
{ |
|
|
|
|
@ -121,8 +123,13 @@ openglDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity,
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
initSDL(SDL_Handles& handles, v2i& viewport_dims) |
|
|
|
|
initSDL(SDL_Handles& handles) |
|
|
|
|
{ |
|
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) { |
|
|
|
|
LOG(Error) << "Error, SDL_Init: " << SDL_GetError() << "\n"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); |
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); |
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
|
|
|
|
@ -132,6 +139,12 @@ initSDL(SDL_Handles& handles, v2i& viewport_dims)
|
|
|
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); |
|
|
|
|
SDL_GetCurrentDisplayMode(0, &handles.currentDisplayMode); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
createWindow(SDL_Handles& handles, v2i& viewport_dims) |
|
|
|
|
{ |
|
|
|
|
uint display_id = 0; |
|
|
|
|
if (USE_SECOND_MONITOR && SDL_GetNumVideoDisplays() > 1) |
|
|
|
|
display_id = 1; |
|
|
|
|
@ -154,7 +167,7 @@ initSDL(SDL_Handles& handles, v2i& viewport_dims)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
initContext(SDL_Handles& handles) |
|
|
|
|
initGLContext(SDL_Handles& handles) |
|
|
|
|
{ |
|
|
|
|
handles.glContext = SDL_GL_CreateContext(handles.window); |
|
|
|
|
|
|
|
|
|
@ -172,7 +185,7 @@ initContext(SDL_Handles& handles)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
initGL() |
|
|
|
|
initGlOptions() |
|
|
|
|
{ |
|
|
|
|
if (glewInit()) { |
|
|
|
|
LOG(Error) << "failed to initialize OpenGL\n"; |
|
|
|
|
|