From d442813de8005f0a973d9d9e9a7ed20610e0f019 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Wed, 21 Feb 2018 14:29:32 +0300 Subject: [PATCH] no message --- data/shaders/crt-lottes.frag | 4 +++- src/system.c | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/data/shaders/crt-lottes.frag b/data/shaders/crt-lottes.frag index 892c03a..570126b 100644 --- a/data/shaders/crt-lottes.frag +++ b/data/shaders/crt-lottes.frag @@ -2,11 +2,13 @@ in vec2 texCoord; out vec4 fragColor; uniform sampler2D tex; +uniform float trg_w; +uniform float trg_h; // Emulated input resolution. vec2 res=vec2(256.0,144.0); -vec2 trg=res*4.0; +vec2 trg=vec2(trg_w, trg_h); // Hardness of scanline. // -8.0 = soft diff --git a/src/system.c b/src/system.c index 5196f9d..fdb0998 100644 --- a/src/system.c +++ b/src/system.c @@ -206,6 +206,17 @@ static void initTouchGamepad() } static void calcTextureRect(SDL_Rect* rect) +{ + s32 w, h; + SDL_GetWindowSize(platform.window, &w, &h); + + rect->x = OFFSET_LEFT * w / TIC80_FULLWIDTH; + rect->y = OFFSET_TOP * h / TIC80_FULLHEIGHT; + rect->w = TIC80_WIDTH * w / TIC80_FULLWIDTH; + rect->h = TIC80_HEIGHT * h / TIC80_FULLHEIGHT; +} + +static void calcTextureRect2(SDL_Rect* rect) { SDL_GetWindowSize(platform.window, &rect->w, &rect->h); @@ -1170,6 +1181,7 @@ static s32 start(s32 argc, char **argv, const char* folder) u32 crt_shader = 0; load_shader_program(&crt_shader, "data/shaders/common.vert", "data/shaders/crt-lottes.frag"); + { u64 nextTick = SDL_GetPerformanceCounter(); const u64 Delta = SDL_GetPerformanceFrequency() / TIC_FRAMERATE; @@ -1192,7 +1204,15 @@ static s32 start(s32 argc, char **argv, const char* folder) GPU_UpdateImageBytes(texture, NULL, (const u8*)tic->screen, TIC80_FULLWIDTH * sizeof(u32)); - blitGpuTexture(screen, texture); + { + s32 w, h; + SDL_GetWindowSize(platform.window, &w, &h); + + GPU_SetUniformf(GPU_GetUniformLocation(crt_shader, "trg_w"), w); + GPU_SetUniformf(GPU_GetUniformLocation(crt_shader, "trg_h"), h); + + GPU_BlitScale(texture, NULL, screen, 0, 0, (float)w / TIC80_FULLWIDTH, (float)h / TIC80_FULLHEIGHT); + } } GPU_Flip(screen);