diff --git a/CMakeLists.txt b/CMakeLists.txt index 8efbff53..609b3a12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ option(JAPANESE "Enable the Japanese-language build" OFF) option(FIX_BUGS "Fix certain bugs (see src/Bug Fixes.txt)" OFF) option(NONPORTABLE "Enable bits of code that aren't portable, but are what the original game used" OFF) option(FORCE_LOCAL_LIBS "Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones" OFF) -set(RENDERER "Texture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.1 renderer, 'Texture' for SDL2's hardware-accelerated Texture API, 'Surface' for SDL2's software-rendered Surface API, and 'Software' for a handwritten software renderer") +set(RENDERER "Texture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'Texture' for SDL2's hardware-accelerated Texture API, 'Surface' for SDL2's software-rendered Surface API, and 'Software' for a handwritten software renderer") project(CSE2 LANGUAGES C CXX) diff --git a/README.md b/README.md index a71b4422..d9198892 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ You can also add the following flags: * `-DFIX_BUGS=ON` - Fix bugs in the game (see [src/Bug Fixes.txt](src/Bug%20Fixes.txt)) * `-DNONPORTABLE=ON` - Enable bits of code that aren't portable, but are what the original game used * `-DFORCE_LOCAL_LIBS=ON` - Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones -* `-DRENDERER=OpenGL3` - Use the hardware-accelerated OpenGL 3.1 renderer +* `-DRENDERER=OpenGL3` - Use the hardware-accelerated OpenGL 3.2 renderer * `-DRENDERER=Texture` - Use the hardware-accelerated SDL2 Texture API renderer (default) * `-DRENDERER=Surface` - Use the software-rendered SDL2 Surface API renderer * `-DRENDERER=Software` - Use a handwritten software renderer @@ -58,7 +58,7 @@ Run 'make' in this folder, preferably with some of the following settings: * `WINDOWS=1` - Enable Windows-only features like a unique file/taskbar icon, and system font loading (needed for the font setting in Config.dat to do anything) * `RASPBERRY_PI=1` - Enable tweaks to improve performance on Raspberry Pis * `NONPORTABLE=1` - Enable bits of code that aren't portable, but are what the original game used -* `RENDERER=OpenGL3` - Use the hardware-accelerated OpenGL 3.1 renderer +* `RENDERER=OpenGL3` - Use the hardware-accelerated OpenGL 3.2 renderer * `RENDERER=Texture` - Use the hardware-accelerated SDL2 Texture API renderer (default) * `RENDERER=Surface` - Use the software-rendered SDL2 Surface API renderer * `RENDERER=Software` - Use a hand-written software renderer diff --git a/src/Backends/Rendering/OpenGL3.cpp b/src/Backends/Rendering/OpenGL3.cpp index f706e243..a1052a85 100644 --- a/src/Backends/Rendering/OpenGL3.cpp +++ b/src/Backends/Rendering/OpenGL3.cpp @@ -82,7 +82,7 @@ static unsigned long current_vertex_buffer_slot; static RenderMode last_render_mode; static const GLchar *vertex_shader_plain = " \ -#version 140\n \ +#version 150 core\n \ in vec2 input_vertex_coordinates; \ void main() \ { \ @@ -91,7 +91,7 @@ void main() \ "; static const GLchar *vertex_shader_texture = " \ -#version 140\n \ +#version 150 core\n \ in vec2 input_vertex_coordinates; \ in vec2 input_texture_coordinates; \ out vec2 texture_coordinates; \ @@ -103,7 +103,7 @@ void main() \ "; static const GLchar *fragment_shader_texture = " \ -#version 140\n \ +#version 150 core\n \ uniform sampler2D tex; \ in vec2 texture_coordinates; \ out vec4 fragment; \ @@ -114,7 +114,7 @@ void main() \ "; static const GLchar *fragment_shader_texture_colour_key = " \ -#version 140\n \ +#version 150 core\n \ uniform sampler2D tex; \ in vec2 texture_coordinates; \ out vec4 fragment; \ @@ -130,7 +130,7 @@ void main() \ "; static const GLchar *fragment_shader_colour_fill = " \ -#version 140\n \ +#version 150 core\n \ uniform vec4 colour; \ out vec4 fragment; \ void main() \ @@ -140,7 +140,7 @@ void main() \ "; static const GLchar *fragment_shader_glyph_normal = " \ -#version 140\n \ +#version 150 core\n \ uniform sampler2D tex; \ uniform vec4 colour; \ in vec2 texture_coordinates; \ @@ -152,7 +152,7 @@ void main() \ "; static const GLchar *fragment_shader_glyph_subpixel_part1 = " \ -#version 140\n \ +#version 150 core\n \ uniform sampler2D tex; \ in vec2 texture_coordinates; \ out vec4 fragment; \ @@ -163,7 +163,7 @@ void main() \ "; static const GLchar *fragment_shader_glyph_subpixel_part2 = " \ -#version 140\n \ +#version 150 core\n \ uniform sampler2D tex; \ uniform vec4 colour; \ in vec2 texture_coordinates; \ @@ -286,8 +286,10 @@ static void FlushVertexBuffer(void) SDL_Window* Backend_CreateWindow(const char *title, int width, int height) { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); return SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL); } @@ -304,8 +306,8 @@ BOOL Backend_Init(SDL_Window *p_window) if (glewInit() != GLEW_OK) return FALSE; - // Check if the platform supports OpenGL 3.1 - if (!GLEW_VERSION_3_1) + // Check if the platform supports OpenGL 3.2 + if (!GLEW_VERSION_3_2) return FALSE; glEnable(GL_DEBUG_OUTPUT);