mirror of
https://github.com/open-goal/jak-project
synced 2026-06-16 06:46:07 -04:00
40e2f113e6
## Problem OpenGOAL uses OpenGL 4.3. Apple stopped upgrading OpenGL after 4.1, so the way OpenGOAL currently works will never be playable on Macs using OpenGL. ## Solution Luckily, downgrading to OpenGL 4.1 is not a huge change (at least it doesn't seem like it to my untrained eyes). ## Changes * set hints for OpenGL 4.1 instead of 4.3 for __APPLE__ * skip the OpenGL debugging callback setup for macOS (requires 4.3) * bump down the version string for all shaders * stop using the `binding` layout qualifier in shader code * move the `flat` qualifier first (not sure if this is a 4.1 thing or just Macs being more strict) * don't mix signed and unsigned ints in shaders (not sure if this is a 4.1 thing or just Macs being more strict) * add some hacky CPP to the Shader constructor for binding texture units and bones buffers based on variable names in the shader code ## Results   
27 lines
704 B
GLSL
27 lines
704 B
GLSL
#version 410 core
|
|
|
|
out vec4 color;
|
|
|
|
in vec4 fragment_color;
|
|
in vec4 gs_scissor;
|
|
uniform int scissor_enable;
|
|
// game width, game height, viewport width, viewport height
|
|
uniform vec4 game_sizes;
|
|
|
|
void main() {
|
|
if (scissor_enable == 1) {
|
|
float x = gl_FragCoord.x;
|
|
float y = gl_FragCoord.y;
|
|
float w = (game_sizes.z / game_sizes.x);
|
|
float h = (game_sizes.w / game_sizes.y);
|
|
float scax0 = gs_scissor.x * w + 0.5;
|
|
float scax1 = gs_scissor.y * w + 0.5;
|
|
float scay0 = (game_sizes.y - gs_scissor.w) * h + 0.5;
|
|
float scay1 = (game_sizes.y - gs_scissor.z) * h + 0.5;
|
|
if (x < scax0 || x > scax1) discard;
|
|
if (y < scay0 || y > scay1) discard;
|
|
}
|
|
|
|
color = fragment_color;
|
|
}
|