summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-04-23 00:54:33 -0700
committerMichael Pavone <pavone@retrodev.com>2017-04-23 00:54:33 -0700
commit8d362430c6785dcc4b9ed3a7a97acba8ebb15950 (patch)
tree5fb1ca070d9a40b7b27579a3f88ff6efba8714d4
parent49ce0f5effa4bcaf8393cc680840e43bf9b76366 (diff)
Add config file option to disable Open GL rendering
-rw-r--r--default.cfg4
-rwxr-xr-xrender_sdl.c60
2 files changed, 39 insertions, 25 deletions
diff --git a/default.cfg b/default.cfg
index a4ff972..8074b57 100644
--- a/default.cfg
+++ b/default.cfg
@@ -138,6 +138,10 @@ video {
scanlines off
vsync off
fullscreen off
+ #setting gl to off, will force use of the SDL2 fallback renderer
+ #this is useful for those running on machines with Open GL 2.0 unavailable
+ #so the warning doesn't display on startup
+ gl on
ntsc {
overscan {
#these values will result in square pixels in H40 mode
diff --git a/render_sdl.c b/render_sdl.c
index 5e4d4c7..f00c3f5 100755
--- a/render_sdl.c
+++ b/render_sdl.c
@@ -386,41 +386,51 @@ void render_init(int width, int height, char * title, uint8_t fullscreen)
}
#ifndef DISABLE_OPENGL
- flags |= SDL_WINDOW_OPENGL;
- SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
- SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
- SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
- SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ char *gl_enabled_str = tern_find_path_default(config, "video\0gl\0", def, TVAL_PTR).ptrval;
+ uint8_t gl_enabled = strcmp(gl_enabled_str, "off") != 0;
+ if (gl_enabled)
+ {
+ flags |= SDL_WINDOW_OPENGL;
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ }
#endif
main_window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
if (!main_window) {
fatal_error("Unable to create SDL window: %s\n", SDL_GetError());
}
#ifndef DISABLE_OPENGL
- main_context = SDL_GL_CreateContext(main_window);
- GLenum res = glewInit();
- if (res != GLEW_OK) {
- warning("Initialization of GLEW failed with code %d\n", res);
- }
+ if (gl_enabled)
+ {
+ main_context = SDL_GL_CreateContext(main_window);
+ GLenum res = glewInit();
+ if (res != GLEW_OK) {
+ warning("Initialization of GLEW failed with code %d\n", res);
+ }
- if (res == GLEW_OK && GLEW_VERSION_2_0) {
- render_gl = 1;
- if (!strcmp("tear", vsync)) {
- if (SDL_GL_SetSwapInterval(-1) < 0) {
- warning("late tear is not available (%s), using normal vsync\n", SDL_GetError());
- vsync = "on";
- } else {
- vsync = NULL;
+ if (res == GLEW_OK && GLEW_VERSION_2_0) {
+ render_gl = 1;
+ if (!strcmp("tear", vsync)) {
+ if (SDL_GL_SetSwapInterval(-1) < 0) {
+ warning("late tear is not available (%s), using normal vsync\n", SDL_GetError());
+ vsync = "on";
+ } else {
+ vsync = NULL;
+ }
}
- }
- if (vsync) {
- if (SDL_GL_SetSwapInterval(!strcmp("on", vsync)) < 0) {
- warning("Failed to set vsync to %s: %s\n", vsync, SDL_GetError());
+ if (vsync) {
+ if (SDL_GL_SetSwapInterval(!strcmp("on", vsync)) < 0) {
+ warning("Failed to set vsync to %s: %s\n", vsync, SDL_GetError());
+ }
}
+ } else {
+ warning("OpenGL 2.0 is unavailable, falling back to SDL2 renderer\n");
}
- } else {
- warning("OpenGL 2.0 is unavailable, falling back to SDL2 renderer\n");
+ }
+ if (!render_gl) {
#endif
flags = SDL_RENDERER_ACCELERATED;
if (!strcmp("on", vsync) || !strcmp("tear", vsync)) {