limit framebuffer, no error context on release, catching init errors
This commit is contained in:
parent
94ce701dae
commit
81015b1079
38
src/main.c
38
src/main.c
@ -175,13 +175,29 @@ static bool initialize(void) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: recognize cli parameter to turn it on on release */
|
||||||
|
/* debug mode _defaults_ to being enabled on debug builds. */
|
||||||
|
/* you should be able to enable it at runtime on any build */
|
||||||
|
#ifndef NDEBUG
|
||||||
|
ctx.debug = true;
|
||||||
|
#else
|
||||||
|
ctx.debug = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||||
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
|
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
|
|
||||||
|
if (ctx.debug)
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
|
||||||
|
else
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_NO_ERROR);
|
||||||
|
|
||||||
/* init got far enough to create a window */
|
/* init got far enough to create a window */
|
||||||
ctx.window = SDL_CreateWindow("townengine",
|
ctx.window = SDL_CreateWindow("townengine",
|
||||||
SDL_WINDOWPOS_CENTERED,
|
SDL_WINDOWPOS_CENTERED,
|
||||||
@ -202,11 +218,15 @@ static bool initialize(void) {
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_MakeCurrent(ctx.window, ctx.gl_context);
|
if (SDL_GL_MakeCurrent(ctx.window, ctx.gl_context)) {
|
||||||
|
CRY_SDL("GL context binding failed.");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SDL_GL_SetSwapInterval(-1))
|
||||||
SDL_GL_SetSwapInterval(1);
|
SDL_GL_SetSwapInterval(1);
|
||||||
|
|
||||||
int glad_status = gladLoadGL();
|
if (gladLoadGL() == 0) {
|
||||||
if (glad_status == 0) {
|
|
||||||
CRY("Init", "GLAD failed");
|
CRY("Init", "GLAD failed");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -261,14 +281,6 @@ static bool initialize(void) {
|
|||||||
/* you could change this at runtime if you wanted */
|
/* you could change this at runtime if you wanted */
|
||||||
ctx.update_multiplicity = 1;
|
ctx.update_multiplicity = 1;
|
||||||
|
|
||||||
/* debug mode _defaults_ to being enabled on debug builds. */
|
|
||||||
/* you should be able to enable it at runtime on any build */
|
|
||||||
#ifndef NDEBUG
|
|
||||||
ctx.debug = true;
|
|
||||||
#else
|
|
||||||
ctx.debug = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* hook up opengl debugging callback */
|
/* hook up opengl debugging callback */
|
||||||
if (ctx.debug) {
|
if (ctx.debug) {
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
|
Loading…
Reference in New Issue
Block a user