Configure SDL2 to use OpenGL #4

Merged
paoda merged 7 commits from opengl into main 2022-10-20 01:41:51 +00:00
3 changed files with 32 additions and 19 deletions
Showing only changes of commit 325208d460 - Show all commits

View File

@ -236,7 +236,8 @@ pub const Gui = struct {
pub fn deinit(self: *Self) void { pub fn deinit(self: *Self) void {
self.audio.deinit(); self.audio.deinit();
// TODO: Buffer deletions
gl.deleteProgram(self.program_id);
SDL.SDL_GL_DeleteContext(self.ctx); SDL.SDL_GL_DeleteContext(self.ctx);
SDL.SDL_DestroyWindow(self.window); SDL.SDL_DestroyWindow(self.window);
SDL.SDL_Quit(); SDL.SDL_Quit();

View File

@ -1,13 +1,25 @@
#version 330 core #version 330 core
out vec4 FragColor; out vec4 frag_color;
in vec3 ourColor; in vec3 color;
in vec2 TexCoord; in vec2 uv;
// texture sampler uniform sampler2D screen;
uniform sampler2D texture1;
void main() { void main() {
FragColor = texture(texture1, TexCoord); // https://near.sh/video/color-emulation
// Thanks to Talarubi + Near for the Colour Correction
// Thanks to fleur + mattrb for the Shader Impl
vec4 color = texture(screen, uv);
color.rgb = pow(color.rgb, vec3(4.0)); // LCD Gamma
frag_color = vec4(
pow(vec3(
0 * color.b + 50 * color.g + 255 * color.r,
30 * color.b + 230 * color.g + 10 * color.r,
220 * color.b + 10 * color.g + 50 * color.r
) / 255, vec3(1.0 / 2.2)), // Out Gamma
1.0);
} }

View File

@ -1,13 +1,13 @@
#version 330 core #version 330 core
layout (location = 0) in vec3 aPos; layout (location = 0) in vec3 pos;
layout (location = 1) in vec3 aColor; layout (location = 1) in vec3 in_color;
layout (location = 2) in vec2 aTexCoord; layout (location = 2) in vec2 in_uv;
out vec3 ourColor; out vec3 color;
out vec2 TexCoord; out vec2 uv;
void main() { void main() {
gl_Position = vec4(aPos, 1.0); color = in_color;
ourColor = aColor; uv = in_uv;
TexCoord = aTexCoord; gl_Position = vec4(pos, 1.0);
} }