From 01f9b6c2b535fb3c2974b76b44de0bfb4840410a Mon Sep 17 00:00:00 2001 From: Arisotura Date: Fri, 6 Dec 2019 11:52:58 +0100 Subject: [PATCH] make it more functional and betterer atleast now it's not worse than what it was before, so we can start building real shit --- src/GPU_OpenGL.cpp | 8 ++++++++ src/GPU_OpenGL_shaders.h | 2 +- src/libui_sdl/main.cpp | 32 ++++++++++++++++---------------- src/libui_sdl/main_shaders.h | 4 ++-- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/GPU_OpenGL.cpp b/src/GPU_OpenGL.cpp index 75f8be58..f93542e7 100644 --- a/src/GPU_OpenGL.cpp +++ b/src/GPU_OpenGL.cpp @@ -51,6 +51,8 @@ bool Init() for (int i = 0; i < 1; i++) { + GLint uni_id; + glBindAttribLocation(CompShader[i][2], 0, "vPosition"); glBindFragDataLocation(CompShader[i][2], 0, "oColor"); @@ -58,6 +60,12 @@ bool Init() return false; CompScaleLoc[i] = glGetUniformLocation(CompShader[i][2], "u3DScale"); + + glUseProgram(CompShader[i][2]); + uni_id = glGetUniformLocation(CompShader[i][2], "ScreenTex"); + glUniform1i(uni_id, 0); + uni_id = glGetUniformLocation(CompShader[i][2], "_3DTex"); + glUniform1i(uni_id, 1); } #define SETVERTEX(i, x, y) \ diff --git a/src/GPU_OpenGL_shaders.h b/src/GPU_OpenGL_shaders.h index b5d243cb..07260cc1 100644 --- a/src/GPU_OpenGL_shaders.h +++ b/src/GPU_OpenGL_shaders.h @@ -33,7 +33,7 @@ void main() fpos.w = 1.0; gl_Position = fpos; - fTexcoord = (vPosition + vec2(1.0, -1.0)) * (vec2(256.0, -384.0) / 2.0); + fTexcoord = (vPosition + vec2(1.0, 1.0)) * (vec2(256.0, 384.0) / 2.0); } )"; diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index f94a8082..0ab44a4d 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -410,31 +410,31 @@ void GLScreen_DrawScreen() switch (ScreenRotation) { case 0: - s0 = 0; t0 = 192; - s1 = scwidth; t1 = 192; - s2 = 0; t2 = 192+scheight; - s3 = scwidth; t3 = 192+scheight; + s0 = 0; t0 = scheight; + s1 = scwidth; t1 = scheight; + s2 = 0; t2 = scheight+scheight; + s3 = scwidth; t3 = scheight+scheight; break; case 1: - s0 = 0; t0 = 192+scheight; - s1 = 0; t1 = 192; - s2 = scwidth; t2 = 192+scheight; - s3 = scwidth; t3 = 192; + s0 = 0; t0 = scheight+scheight; + s1 = 0; t1 = scheight; + s2 = scwidth; t2 = scheight+scheight; + s3 = scwidth; t3 = scheight; break; case 2: - s0 = scwidth; t0 = 192+scheight; - s1 = 0; t1 = 192+scheight; - s2 = scwidth; t2 = 192; - s3 = 0; t3 = 192; + s0 = scwidth; t0 = scheight+scheight; + s1 = 0; t1 = scheight+scheight; + s2 = scwidth; t2 = scheight; + s3 = 0; t3 = scheight; break; case 3: - s0 = scwidth; t0 = 192; - s1 = scwidth; t1 = 192+scheight; - s2 = 0; t2 = 192; - s3 = 0; t3 = 192+scheight; + s0 = scwidth; t0 = scheight; + s1 = scwidth; t1 = scheight+scheight; + s2 = 0; t2 = scheight; + s3 = 0; t3 = scheight+scheight; break; } diff --git a/src/libui_sdl/main_shaders.h b/src/libui_sdl/main_shaders.h index 093e3740..d9a436c3 100644 --- a/src/libui_sdl/main_shaders.h +++ b/src/libui_sdl/main_shaders.h @@ -63,11 +63,11 @@ out vec4 oColor; void main() { - ivec4 pixel = ivec4(texelFetch(ScreenTex, ivec2(fTexcoord), 0)); + //ivec4 pixel = ivec4(texelFetch(ScreenTex, ivec2(fTexcoord), 0)); // TODO: filters - oColor = vec4(vec3(pixel.bgr) / 255.0, 1.0); + //oColor = vec4(vec3(pixel.bgr) / 255.0, 1.0); oColor = texelFetch(ScreenTex, ivec2(fTexcoord), 0); } )";