ref: fc0653e5aaefc94f4c610cfb5d4370cd0db6b039
parent: 3b20c5f3b8ec056bd252e946d4256037256bfbb9
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sat Aug 10 14:05:01 EDT 2019
Back to OpenGL 3.2 (I really want the core profile) In OpenGL 3.1, compatibility mode was an extension, meaning it could never actually be disabled. 3.2 fixed that with the introduction of profiles.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@
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)
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@
* `-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 @@
* `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
--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -82,7 +82,7 @@
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 @@
";
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 @@
";
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 @@
";
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 @@
";
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 @@
";
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 @@
";
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 @@
";
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 @@
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 @@
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);