# HG changeset patch # User Michael Pavone # Date 1492934073 25200 # Node ID 70faad89d491a6a8efaece17d0c59b7240fb0232 # Parent 57637d17b59e44cb47b34af1951db52b8a7c7d7e Add config file option to disable Open GL rendering diff -r 57637d17b59e -r 70faad89d491 default.cfg --- a/default.cfg Sat Apr 22 01:22:47 2017 -0700 +++ b/default.cfg Sun Apr 23 00:54:33 2017 -0700 @@ -138,6 +138,10 @@ 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 -r 57637d17b59e -r 70faad89d491 render_sdl.c --- a/render_sdl.c Sat Apr 22 01:22:47 2017 -0700 +++ b/render_sdl.c Sun Apr 23 00:54:33 2017 -0700 @@ -386,41 +386,51 @@ } #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()); + } + } + } else { + warning("OpenGL 2.0 is unavailable, falling back to SDL2 renderer\n"); } - 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"); + } + if (!render_gl) { #endif flags = SDL_RENDERER_ACCELERATED; if (!strcmp("on", vsync) || !strcmp("tear", vsync)) {