diff --git a/src/GPU_OpenGL.cpp b/src/GPU_OpenGL.cpp index f93542e7..e8fb7091 100644 --- a/src/GPU_OpenGL.cpp +++ b/src/GPU_OpenGL.cpp @@ -157,26 +157,26 @@ void UpdateDisplaySettings() void RenderFrame() -{printf("0: error %04X\n", glGetError()); +{ glBindFramebuffer(GL_FRAMEBUFFER, CompScreenOutputFB); -printf("1: error %04X\n", glGetError()); + glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); glDisable(GL_BLEND); glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glViewport(0, 0, ScreenW, ScreenH); -printf("2: error %04X\n", glGetError()); + // TODO: select more shaders (filtering, etc) OpenGL_UseShaderProgram(CompShader[0]); glUniform1ui(CompScaleLoc[0], Scale); -printf("3: error %04X\n", glGetError()); + //if (RunningSomething) { int frontbuf = GPU::FrontBuffer; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, CompScreenInputTex); -printf("4: error %04X\n", glGetError()); + if (GPU::Framebuffer[frontbuf][0] && GPU::Framebuffer[frontbuf][1]) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256*3 + 1, 192, GL_RGBA_INTEGER, @@ -184,14 +184,13 @@ printf("4: error %04X\n", glGetError()); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 192, 256*3 + 1, 192, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][1]); } -printf("5: error %04X\n", glGetError()); + glActiveTexture(GL_TEXTURE1); GPU3D::GLRenderer::SetupAccelFrame(); -printf("6: error %04X\n", glGetError()); + glBindBuffer(GL_ARRAY_BUFFER, CompVertexBufferID); glBindVertexArray(CompVertexArrayID); glDrawArrays(GL_TRIANGLES, 0, 4*3); - printf("7: error %04X\n", glGetError()); } } diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 0ab44a4d..ec003d07 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -261,8 +261,8 @@ bool GLScreen_Init() if (!GLScreen_InitShader(GL_ScreenShader, kScreenFS)) return false; - if (!GLScreen_InitShader(GL_ScreenShaderAccel, kScreenFS_Accel)) - return false; + //if (!GLScreen_InitShader(GL_ScreenShaderAccel, kScreenFS_Accel)) + // return false; if (!GLScreen_InitOSDShader(GL_ScreenShaderOSD)) return false; @@ -358,8 +358,8 @@ void GLScreen_DrawScreen() x1 = TopScreenRect.X + TopScreenRect.Width; y1 = TopScreenRect.Y + TopScreenRect.Height; - scwidth = 256 * GL_3DScale; - scheight = 192 * GL_3DScale; + scwidth = 1.0;//256 * GL_3DScale; + scheight = 0.5;//192 * GL_3DScale; switch (ScreenRotation) { @@ -404,8 +404,8 @@ void GLScreen_DrawScreen() x1 = BottomScreenRect.X + BottomScreenRect.Width; y1 = BottomScreenRect.Y + BottomScreenRect.Height; - scwidth = 256 * GL_3DScale; - scheight = 192 * GL_3DScale; + scwidth = 1.0;//256 * GL_3DScale; + scheight = 0.5;//192 * GL_3DScale; switch (ScreenRotation) { @@ -489,6 +489,18 @@ void GLScreen_DrawScreen() glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 192, 256*3 + 1, 192, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GPU::Framebuffer[frontbuf][1]);*/ } + + // filtering + if (Config::ScreenFilter == 1) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } } //glActiveTexture(GL_TEXTURE1); diff --git a/src/libui_sdl/main_shaders.h b/src/libui_sdl/main_shaders.h index d9a436c3..274d5e0d 100644 --- a/src/libui_sdl/main_shaders.h +++ b/src/libui_sdl/main_shaders.h @@ -68,134 +68,8 @@ void main() // TODO: filters //oColor = vec4(vec3(pixel.bgr) / 255.0, 1.0); - oColor = texelFetch(ScreenTex, ivec2(fTexcoord), 0); -} -)"; - -const char* kScreenFS_Accel = R"(#version 140 - -layout(std140) uniform uConfig -{ - vec2 uScreenSize; - uint u3DScale; - uint uFilterMode; -}; - -uniform usampler2D ScreenTex; -uniform sampler2D _3DTex; - -smooth in vec2 fTexcoord; - -out vec4 oColor; - -void main() -{ - ivec4 pixel = ivec4(texelFetch(ScreenTex, ivec2(fTexcoord), 0)); - - ivec4 mbright = ivec4(texelFetch(ScreenTex, ivec2(256*3, int(fTexcoord.y)), 0)); - int dispmode = mbright.b & 0x3; - - if (dispmode == 1) - { - ivec4 val1 = pixel; - ivec4 val2 = ivec4(texelFetch(ScreenTex, ivec2(fTexcoord) + ivec2(256,0), 0)); - ivec4 val3 = ivec4(texelFetch(ScreenTex, ivec2(fTexcoord) + ivec2(512,0), 0)); - - int compmode = val3.a & 0xF; - int eva, evb, evy; - - if (compmode == 4) - { - // 3D on top, blending - - float xpos = val3.r + fract(fTexcoord.x); - float ypos = mod(fTexcoord.y, 192); - ivec4 _3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra - * vec4(63,63,63,31)); - - if (_3dpix.a > 0) - { - eva = (_3dpix.a & 0x1F) + 1; - evb = 32 - eva; - - val1 = ((_3dpix * eva) + (val1 * evb)) >> 5; - if (eva <= 16) val1 += ivec4(1,1,1,0); - val1 = min(val1, 0x3F); - } - else - val1 = val2; - } - else if (compmode == 1) - { - // 3D on bottom, blending - - float xpos = val3.r + fract(fTexcoord.x); - float ypos = mod(fTexcoord.y, 192); - ivec4 _3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra - * vec4(63,63,63,31)); - - if (_3dpix.a > 0) - { - eva = val3.g; - evb = val3.b; - - val1 = ((val1 * eva) + (_3dpix * evb)) >> 4; - val1 = min(val1, 0x3F); - } - else - val1 = val2; - } - else if (compmode <= 3) - { - // 3D on top, normal/fade - - float xpos = val3.r + fract(fTexcoord.x); - float ypos = mod(fTexcoord.y, 192); - ivec4 _3dpix = ivec4(texelFetch(_3DTex, ivec2(vec2(xpos, ypos)*u3DScale), 0).bgra - * vec4(63,63,63,31)); - - if (_3dpix.a > 0) - { - evy = val3.g; - - val1 = _3dpix; - if (compmode == 2) val1 += ((ivec4(0x3F,0x3F,0x3F,0) - val1) * evy) >> 4; - else if (compmode == 3) val1 -= (val1 * evy) >> 4; - } - else - val1 = val2; - } - - pixel = val1; - } - - if (dispmode != 0) - { - int brightmode = mbright.g >> 6; - if (brightmode == 1) - { - // up - int evy = mbright.r & 0x1F; - if (evy > 16) evy = 16; - - pixel += ((ivec4(0x3F,0x3F,0x3F,0) - pixel) * evy) >> 4; - } - else if (brightmode == 2) - { - // down - int evy = mbright.r & 0x1F; - if (evy > 16) evy = 16; - - pixel -= (pixel * evy) >> 4; - } - } - - pixel.rgb <<= 2; - pixel.rgb |= (pixel.rgb >> 6); - - // TODO: filters - - oColor = vec4(vec3(pixel.rgb) / 255.0, 1.0); + //oColor = texelFetch(ScreenTex, ivec2(fTexcoord), 0); + oColor = texture(ScreenTex, fTexcoord); } )";