From 85198c9dfa675ef9b7d176b646f4de2c87407a05 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Tue, 20 Feb 2018 10:24:56 +0300 Subject: [PATCH 01/11] Cannot select tile palette in map editor #533 --- src/map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/map.c b/src/map.c index 16a5a34..a40891e 100644 --- a/src/map.c +++ b/src/map.c @@ -1006,9 +1006,10 @@ static void copyFromClipboard(Map* map) static void processKeyboard(Map* map) { tic_mem* tic = map->tic; - map->sheet.show = false; if(tic->ram.input.keyboard.data == 0) return; + + map->sheet.show = false; bool shift = tic->api.key(tic, tic_key_shift); bool ctrl = tic->api.key(tic, tic_key_ctrl); From ea8c269b57dfae1b414a76e8664fc45baf9c234c Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Tue, 20 Feb 2018 17:43:46 +0300 Subject: [PATCH 02/11] fixed PRO build in Visual Studio --- .gitignore | 1 + build/windows/studio/studio.vcxproj | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index bd3d33d..5845692 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,4 @@ build/uwp/studio/Release/ build/uwp/studio/Release Pro/ build/uwp/studio/ARM/ build/uwp/studio/x64/ +build/windows/studio/x64/ diff --git a/build/windows/studio/studio.vcxproj b/build/windows/studio/studio.vcxproj index 32b1618..ea20fd2 100644 --- a/build/windows/studio/studio.vcxproj +++ b/build/windows/studio/studio.vcxproj @@ -168,7 +168,7 @@ Level3 Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions) + TIC80_PRO;WIN32;_DEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions) ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\wren-0.1.0\src\include MultiThreadedDebug @@ -198,7 +198,7 @@ Level3 Disabled - _DEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions) + TIC80_PRO;_DEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions) ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\wren-0.1.0\src\include MultiThreadedDebug @@ -234,7 +234,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions) + TIC80_PRO;WIN32;NDEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions) ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\wren-0.1.0\src\include MultiThreaded @@ -272,7 +272,7 @@ MaxSpeed true true - NDEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions) + TIC80_PRO;NDEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions) ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\wren-0.1.0\src\include MultiThreaded From 59454711d258fda4d89600106aa5d114fc905206 Mon Sep 17 00:00:00 2001 From: Jed Date: Tue, 20 Feb 2018 11:47:06 -0500 Subject: [PATCH 03/11] fixing textri now use constant slope vs per line ( less wibble ) now use fixed point math for inner loops removed right edge U,V buffer --- .gitignore | 1 + src/tic.c | 51 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 5845692..a254acb 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,4 @@ build/uwp/studio/Release Pro/ build/uwp/studio/ARM/ build/uwp/studio/x64/ build/windows/studio/x64/ +3rd-party diff --git a/src/tic.c b/src/tic.c index 355edec..3f55c4a 100644 --- a/src/tic.c +++ b/src/tic.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "ticapi.h" #include "tools.h" @@ -823,10 +824,8 @@ static struct { s16 Left[TIC80_HEIGHT]; s16 Right[TIC80_HEIGHT]; - float ULeft[TIC80_HEIGHT]; - float VLeft[TIC80_HEIGHT]; - float URight[TIC80_HEIGHT]; - float VRight[TIC80_HEIGHT]; + s32 ULeft[TIC80_HEIGHT]; + s32 VLeft[TIC80_HEIGHT]; } SidesBuffer; static void initSidesBuffer() @@ -852,14 +851,12 @@ static void setSideTexPixel(s32 x, s32 y, float u, float v) if (x < SidesBuffer.Left[yy]) { SidesBuffer.Left[yy] = x; - SidesBuffer.ULeft[yy] = u; - SidesBuffer.VLeft[yy] = v; + SidesBuffer.ULeft[yy] = u*65536.0f; + SidesBuffer.VLeft[yy] = v*65536.0f; } if (x > SidesBuffer.Right[yy]) { SidesBuffer.Right[yy] = x; - SidesBuffer.URight[yy] = u; - SidesBuffer.VRight[yy] = v; } } } @@ -1015,22 +1012,37 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, V0.x = (float)x1; V0.y = (float)y1; V0.u = (float)u1; V0.v = (float)v1; V1.x = (float)x2; V1.y = (float)y2; V1.u = (float)u2; V1.v = (float)v2; V2.x = (float)x3; V2.y = (float)y3; V2.u = (float)u3; V2.v = (float)v3; + + // calculate the slope of the surface + // use floats here + double denom = (V0.x - V2.x) * (V1.y - V2.y) - (V1.x - V2.x) * (V0.y - V2.y); + if (denom == 0.0) + { + return; + } + double id = 1.0 / denom; + float dudx, dvdx; + // this is the UV slope across the surface + dudx = ((V0.u - V2.u) * (V1.y - V2.y) - (V1.u - V2.u) * (V0.y - V2.y)) * id; + dvdx = ((V0.v - V2.v) * (V1.y - V2.y) - (V1.v - V2.v) * (V0.y - V2.y)) * id; + // convert to fixed + s32 dudxs = dudx * 65536.0f; + s32 dvdxs = dvdx * 65536.0f; + initSidesBuffer(); ticTexLine(memory, &V0, &V1); ticTexLine(memory, &V1, &V2); ticTexLine(memory, &V2, &V0); - + { for (s32 y = 0; y < TIC80_HEIGHT; y++) { float width = SidesBuffer.Right[y] - SidesBuffer.Left[y]; if (width > 0) { - float du = (SidesBuffer.URight[y] - SidesBuffer.ULeft[y]) / width; - float dv = (SidesBuffer.VRight[y] - SidesBuffer.VLeft[y]) / width; - float u = SidesBuffer.ULeft[y]; - float v = SidesBuffer.VLeft[y]; + s32 u = SidesBuffer.ULeft[y]; + s32 v = SidesBuffer.VLeft[y]; for (s32 x = (s32)SidesBuffer.Left[y]; x <= (s32)SidesBuffer.Right[y]; ++x) { @@ -1040,8 +1052,8 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, { enum {MapWidth = TIC_MAP_WIDTH * TIC_SPRITESIZE, MapHeight = TIC_MAP_HEIGHT * TIC_SPRITESIZE}; - s32 iu = (s32)u % MapWidth; - s32 iv = (s32)v % MapHeight; + s32 iu = (u >> 16) % MapWidth; + s32 iv = (v >> 16) % MapHeight; while (iu < 0) iu += MapWidth; while (iv < 0) iv += MapHeight; @@ -1056,16 +1068,16 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, { enum{SheetWidth = TIC_SPRITESHEET_SIZE, SheetHeight = TIC_SPRITESHEET_SIZE * TIC_SPRITE_BANKS}; - s32 iu = (s32)(u) & (SheetWidth - 1); - s32 iv = (s32)(v) & (SheetHeight - 1); + s32 iu = (u>>16) & (SheetWidth - 1); + s32 iv = (v>>16) & (SheetHeight - 1); const u8 *buffer = &ptr[((iu >> 3) + ((iv >> 3) << 4)) << 5]; u8 color = tic_tool_peek4(buffer, (iu & 7) + ((iv & 7) << 3)); if (color != chroma) setPixel(machine, x, y, color); } } - u += du; - v += dv; + u += dudxs; + v += dvdxs; } } } @@ -1073,6 +1085,7 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, } + static void api_sprite(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count) { drawSprite(memory, src, index, x, y, colors, count, 1, tic_no_flip, tic_no_rotate); From 92389e1b0589eaf6e3f8e7650aefe628889e1646 Mon Sep 17 00:00:00 2001 From: MonstersGoBoom Date: Tue, 20 Feb 2018 11:49:30 -0500 Subject: [PATCH 04/11] Revert "fixing textri" This reverts commit 59454711d258fda4d89600106aa5d114fc905206. --- .gitignore | 1 - src/tic.c | 51 +++++++++++++++++++-------------------------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index a254acb..5845692 100644 --- a/.gitignore +++ b/.gitignore @@ -112,4 +112,3 @@ build/uwp/studio/Release Pro/ build/uwp/studio/ARM/ build/uwp/studio/x64/ build/windows/studio/x64/ -3rd-party diff --git a/src/tic.c b/src/tic.c index 3f55c4a..355edec 100644 --- a/src/tic.c +++ b/src/tic.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "ticapi.h" #include "tools.h" @@ -824,8 +823,10 @@ static struct { s16 Left[TIC80_HEIGHT]; s16 Right[TIC80_HEIGHT]; - s32 ULeft[TIC80_HEIGHT]; - s32 VLeft[TIC80_HEIGHT]; + float ULeft[TIC80_HEIGHT]; + float VLeft[TIC80_HEIGHT]; + float URight[TIC80_HEIGHT]; + float VRight[TIC80_HEIGHT]; } SidesBuffer; static void initSidesBuffer() @@ -851,12 +852,14 @@ static void setSideTexPixel(s32 x, s32 y, float u, float v) if (x < SidesBuffer.Left[yy]) { SidesBuffer.Left[yy] = x; - SidesBuffer.ULeft[yy] = u*65536.0f; - SidesBuffer.VLeft[yy] = v*65536.0f; + SidesBuffer.ULeft[yy] = u; + SidesBuffer.VLeft[yy] = v; } if (x > SidesBuffer.Right[yy]) { SidesBuffer.Right[yy] = x; + SidesBuffer.URight[yy] = u; + SidesBuffer.VRight[yy] = v; } } } @@ -1012,37 +1015,22 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, V0.x = (float)x1; V0.y = (float)y1; V0.u = (float)u1; V0.v = (float)v1; V1.x = (float)x2; V1.y = (float)y2; V1.u = (float)u2; V1.v = (float)v2; V2.x = (float)x3; V2.y = (float)y3; V2.u = (float)u3; V2.v = (float)v3; - - // calculate the slope of the surface - // use floats here - double denom = (V0.x - V2.x) * (V1.y - V2.y) - (V1.x - V2.x) * (V0.y - V2.y); - if (denom == 0.0) - { - return; - } - double id = 1.0 / denom; - float dudx, dvdx; - // this is the UV slope across the surface - dudx = ((V0.u - V2.u) * (V1.y - V2.y) - (V1.u - V2.u) * (V0.y - V2.y)) * id; - dvdx = ((V0.v - V2.v) * (V1.y - V2.y) - (V1.v - V2.v) * (V0.y - V2.y)) * id; - // convert to fixed - s32 dudxs = dudx * 65536.0f; - s32 dvdxs = dvdx * 65536.0f; - initSidesBuffer(); ticTexLine(memory, &V0, &V1); ticTexLine(memory, &V1, &V2); ticTexLine(memory, &V2, &V0); - + { for (s32 y = 0; y < TIC80_HEIGHT; y++) { float width = SidesBuffer.Right[y] - SidesBuffer.Left[y]; if (width > 0) { - s32 u = SidesBuffer.ULeft[y]; - s32 v = SidesBuffer.VLeft[y]; + float du = (SidesBuffer.URight[y] - SidesBuffer.ULeft[y]) / width; + float dv = (SidesBuffer.VRight[y] - SidesBuffer.VLeft[y]) / width; + float u = SidesBuffer.ULeft[y]; + float v = SidesBuffer.VLeft[y]; for (s32 x = (s32)SidesBuffer.Left[y]; x <= (s32)SidesBuffer.Right[y]; ++x) { @@ -1052,8 +1040,8 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, { enum {MapWidth = TIC_MAP_WIDTH * TIC_SPRITESIZE, MapHeight = TIC_MAP_HEIGHT * TIC_SPRITESIZE}; - s32 iu = (u >> 16) % MapWidth; - s32 iv = (v >> 16) % MapHeight; + s32 iu = (s32)u % MapWidth; + s32 iv = (s32)v % MapHeight; while (iu < 0) iu += MapWidth; while (iv < 0) iv += MapHeight; @@ -1068,16 +1056,16 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, { enum{SheetWidth = TIC_SPRITESHEET_SIZE, SheetHeight = TIC_SPRITESHEET_SIZE * TIC_SPRITE_BANKS}; - s32 iu = (u>>16) & (SheetWidth - 1); - s32 iv = (v>>16) & (SheetHeight - 1); + s32 iu = (s32)(u) & (SheetWidth - 1); + s32 iv = (s32)(v) & (SheetHeight - 1); const u8 *buffer = &ptr[((iu >> 3) + ((iv >> 3) << 4)) << 5]; u8 color = tic_tool_peek4(buffer, (iu & 7) + ((iv & 7) << 3)); if (color != chroma) setPixel(machine, x, y, color); } } - u += dudxs; - v += dvdxs; + u += du; + v += dv; } } } @@ -1085,7 +1073,6 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, } - static void api_sprite(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count) { drawSprite(memory, src, index, x, y, colors, count, 1, tic_no_flip, tic_no_rotate); From 847d848c887c95f6683b9e7dcc762f067938aa1c Mon Sep 17 00:00:00 2001 From: MonstersGoBoom Date: Tue, 20 Feb 2018 11:56:17 -0500 Subject: [PATCH 05/11] textri: constant slope fix, removed more floating point code, saved some data --- src/tic.c | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/tic.c b/src/tic.c index 355edec..3f55c4a 100644 --- a/src/tic.c +++ b/src/tic.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "ticapi.h" #include "tools.h" @@ -823,10 +824,8 @@ static struct { s16 Left[TIC80_HEIGHT]; s16 Right[TIC80_HEIGHT]; - float ULeft[TIC80_HEIGHT]; - float VLeft[TIC80_HEIGHT]; - float URight[TIC80_HEIGHT]; - float VRight[TIC80_HEIGHT]; + s32 ULeft[TIC80_HEIGHT]; + s32 VLeft[TIC80_HEIGHT]; } SidesBuffer; static void initSidesBuffer() @@ -852,14 +851,12 @@ static void setSideTexPixel(s32 x, s32 y, float u, float v) if (x < SidesBuffer.Left[yy]) { SidesBuffer.Left[yy] = x; - SidesBuffer.ULeft[yy] = u; - SidesBuffer.VLeft[yy] = v; + SidesBuffer.ULeft[yy] = u*65536.0f; + SidesBuffer.VLeft[yy] = v*65536.0f; } if (x > SidesBuffer.Right[yy]) { SidesBuffer.Right[yy] = x; - SidesBuffer.URight[yy] = u; - SidesBuffer.VRight[yy] = v; } } } @@ -1015,22 +1012,37 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, V0.x = (float)x1; V0.y = (float)y1; V0.u = (float)u1; V0.v = (float)v1; V1.x = (float)x2; V1.y = (float)y2; V1.u = (float)u2; V1.v = (float)v2; V2.x = (float)x3; V2.y = (float)y3; V2.u = (float)u3; V2.v = (float)v3; + + // calculate the slope of the surface + // use floats here + double denom = (V0.x - V2.x) * (V1.y - V2.y) - (V1.x - V2.x) * (V0.y - V2.y); + if (denom == 0.0) + { + return; + } + double id = 1.0 / denom; + float dudx, dvdx; + // this is the UV slope across the surface + dudx = ((V0.u - V2.u) * (V1.y - V2.y) - (V1.u - V2.u) * (V0.y - V2.y)) * id; + dvdx = ((V0.v - V2.v) * (V1.y - V2.y) - (V1.v - V2.v) * (V0.y - V2.y)) * id; + // convert to fixed + s32 dudxs = dudx * 65536.0f; + s32 dvdxs = dvdx * 65536.0f; + initSidesBuffer(); ticTexLine(memory, &V0, &V1); ticTexLine(memory, &V1, &V2); ticTexLine(memory, &V2, &V0); - + { for (s32 y = 0; y < TIC80_HEIGHT; y++) { float width = SidesBuffer.Right[y] - SidesBuffer.Left[y]; if (width > 0) { - float du = (SidesBuffer.URight[y] - SidesBuffer.ULeft[y]) / width; - float dv = (SidesBuffer.VRight[y] - SidesBuffer.VLeft[y]) / width; - float u = SidesBuffer.ULeft[y]; - float v = SidesBuffer.VLeft[y]; + s32 u = SidesBuffer.ULeft[y]; + s32 v = SidesBuffer.VLeft[y]; for (s32 x = (s32)SidesBuffer.Left[y]; x <= (s32)SidesBuffer.Right[y]; ++x) { @@ -1040,8 +1052,8 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, { enum {MapWidth = TIC_MAP_WIDTH * TIC_SPRITESIZE, MapHeight = TIC_MAP_HEIGHT * TIC_SPRITESIZE}; - s32 iu = (s32)u % MapWidth; - s32 iv = (s32)v % MapHeight; + s32 iu = (u >> 16) % MapWidth; + s32 iv = (v >> 16) % MapHeight; while (iu < 0) iu += MapWidth; while (iv < 0) iv += MapHeight; @@ -1056,16 +1068,16 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, { enum{SheetWidth = TIC_SPRITESHEET_SIZE, SheetHeight = TIC_SPRITESHEET_SIZE * TIC_SPRITE_BANKS}; - s32 iu = (s32)(u) & (SheetWidth - 1); - s32 iv = (s32)(v) & (SheetHeight - 1); + s32 iu = (u>>16) & (SheetWidth - 1); + s32 iv = (v>>16) & (SheetHeight - 1); const u8 *buffer = &ptr[((iu >> 3) + ((iv >> 3) << 4)) << 5]; u8 color = tic_tool_peek4(buffer, (iu & 7) + ((iv & 7) << 3)); if (color != chroma) setPixel(machine, x, y, color); } } - u += du; - v += dv; + u += dudxs; + v += dvdxs; } } } @@ -1073,6 +1085,7 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2, } + static void api_sprite(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count) { drawSprite(memory, src, index, x, y, colors, count, 1, tic_no_flip, tic_no_rotate); From 551d33351192366ce82d6f7e08bc27ff2b914e31 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Wed, 21 Feb 2018 20:07:07 +0300 Subject: [PATCH 06/11] UWP works --- .gitignore | 7 + build/uwp/sdl-gpu/packages.config | 4 + build/uwp/sdl-gpu/sdl-gpu.vcxproj | 241 ++++++++++++++++++ build/uwp/sdl-gpu/sdl-gpu.vcxproj.filters | 34 +++ build/uwp/tic/tic.sln | 14 + build/uwp/tic/tic.vcxproj | 15 +- build/uwp/tic/tic.vcxproj.user | 2 +- data/shaders/common.frag | 11 - data/shaders/crt-geom.frag | 23 -- data/shaders/crt-simple.frag | 15 -- {data/shaders => src/ext/shader}/common.vert | 16 +- .../ext/shader}/crt-lottes.frag | 15 +- src/system.c | 94 ++----- 13 files changed, 357 insertions(+), 134 deletions(-) create mode 100644 build/uwp/sdl-gpu/packages.config create mode 100644 build/uwp/sdl-gpu/sdl-gpu.vcxproj create mode 100644 build/uwp/sdl-gpu/sdl-gpu.vcxproj.filters delete mode 100644 data/shaders/common.frag delete mode 100644 data/shaders/crt-geom.frag delete mode 100644 data/shaders/crt-simple.frag rename {data/shaders => src/ext/shader}/common.vert (57%) rename {data/shaders => src/ext/shader}/crt-lottes.frag (94%) diff --git a/.gitignore b/.gitignore index 183df4b..a8ba750 100644 --- a/.gitignore +++ b/.gitignore @@ -115,3 +115,10 @@ build/windows/sdl-gpu/Debug/ build/windows/sdl-gpu/Debug Pro/ build/windows/sdl-gpu/Release/ build/windows/sdl-gpu/Release Pro/ +build/uwp/sdl-gpu/Debug/ +build/uwp/sdl-gpu/Debug Pro/ +build/uwp/sdl-gpu/Release/ +build/uwp/sdl-gpu/Release Pro/ +build/uwp/sdl-gpu/ARM/ +build/uwp/sdl-gpu/x64/ +build/uwp/tic/packages/ diff --git a/build/uwp/sdl-gpu/packages.config b/build/uwp/sdl-gpu/packages.config new file mode 100644 index 0000000..70c3dea --- /dev/null +++ b/build/uwp/sdl-gpu/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/build/uwp/sdl-gpu/sdl-gpu.vcxproj b/build/uwp/sdl-gpu/sdl-gpu.vcxproj new file mode 100644 index 0000000..38ec2cb --- /dev/null +++ b/build/uwp/sdl-gpu/sdl-gpu.vcxproj @@ -0,0 +1,241 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + {89e9b32e-a86a-47c3-a948-d2b1622925ce} + + + + {3d303f81-f49f-4d63-be32-370c07e271b7} + DynamicLibrary + sdl_gpu + en-US + 14.0 + true + Windows Store + 10.0.14393.0 + 10.0.14393.0 + 10.0 + + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + false + false + + + + NotUsing + false + _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + false + + + Console + false + false + WindowsApp.lib;%(AdditionalDependencies) + + + + + NotUsing + false + _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + false + + + Console + false + false + WindowsApp.lib;%(AdditionalDependencies) + + + + + NotUsing + false + _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + false + + + Console + false + false + WindowsApp.lib;%(AdditionalDependencies) + + + + + NotUsing + false + _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + false + + + Console + false + false + WindowsApp.lib;%(AdditionalDependencies) + + + + + NotUsing + false + _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + false + + + Console + false + false + WindowsApp.lib;%(AdditionalDependencies) + + + + + NotUsing + false + _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + false + + + Console + false + false + WindowsApp.lib;%(AdditionalDependencies) + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/build/uwp/sdl-gpu/sdl-gpu.vcxproj.filters b/build/uwp/sdl-gpu/sdl-gpu.vcxproj.filters new file mode 100644 index 0000000..f52f9f0 --- /dev/null +++ b/build/uwp/sdl-gpu/sdl-gpu.vcxproj.filters @@ -0,0 +1,34 @@ + + + + + {d9d32195-021b-46b4-8ea0-ab03b10402b7} + + + + + src + + + src + + + src + + + src + + + src + + + src + + + src + + + + + + \ No newline at end of file diff --git a/build/uwp/tic/tic.sln b/build/uwp/tic/tic.sln index 3623212..c70f171 100644 --- a/build/uwp/tic/tic.sln +++ b/build/uwp/tic/tic.sln @@ -19,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren", "..\wren\wren.vcxpro EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "studio", "..\studio\studio.vcxproj", "{6A22403A-6CF5-49F2-A012-EC04C9496306}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl-gpu", "..\sdl-gpu\sdl-gpu.vcxproj", "{3D303F81-F49F-4D63-BE32-370C07E271B7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -131,6 +133,18 @@ Global {6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x64.Build.0 = Release|x64 {6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x86.ActiveCfg = Release|Win32 {6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x86.Build.0 = Release|Win32 + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|ARM.ActiveCfg = Debug|ARM + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|ARM.Build.0 = Debug|ARM + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|x64.ActiveCfg = Debug|x64 + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|x64.Build.0 = Debug|x64 + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|x86.ActiveCfg = Debug|Win32 + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|x86.Build.0 = Debug|Win32 + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|ARM.ActiveCfg = Release|ARM + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|ARM.Build.0 = Release|ARM + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|x64.ActiveCfg = Release|x64 + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|x64.Build.0 = Release|x64 + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|x86.ActiveCfg = Release|Win32 + {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/uwp/tic/tic.vcxproj b/build/uwp/tic/tic.vcxproj index d6dfff2..8bf38cb 100644 --- a/build/uwp/tic/tic.vcxproj +++ b/build/uwp/tic/tic.vcxproj @@ -109,7 +109,7 @@ 4453;28204 false NotUsing - ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) _WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) @@ -125,7 +125,7 @@ 4453;28204 false NotUsing - ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) _WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) @@ -141,7 +141,7 @@ 4453;28204 false NotUsing - ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) _WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -157,7 +157,7 @@ 4453;28204 false NotUsing - ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) _WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -173,7 +173,7 @@ 4453;28204 false NotUsing - ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) _WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -189,7 +189,7 @@ 4453;28204 false NotUsing - ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) _WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -219,6 +219,9 @@ {89e9b32e-a86a-47c3-a948-d2b1622925ce} + + {3d303f81-f49f-4d63-be32-370c07e271b7} + {6a22403a-6cf5-49f2-a012-ec04c9496306} diff --git a/build/uwp/tic/tic.vcxproj.user b/build/uwp/tic/tic.vcxproj.user index 2eac851..62e3277 100644 --- a/build/uwp/tic/tic.vcxproj.user +++ b/build/uwp/tic/tic.vcxproj.user @@ -11,7 +11,7 @@ XboxOne - UWPRemoteDebugger + WindowsDeviceDebugger XboxOne diff --git a/data/shaders/common.frag b/data/shaders/common.frag deleted file mode 100644 index 289cb44..0000000 --- a/data/shaders/common.frag +++ /dev/null @@ -1,11 +0,0 @@ - -in vec4 color; -in vec2 texCoord; -out vec4 fragColor; - -uniform sampler2D tex; - -void main(void) -{ - fragColor = texture2D(tex, texCoord) * color; -} \ No newline at end of file diff --git a/data/shaders/crt-geom.frag b/data/shaders/crt-geom.frag deleted file mode 100644 index f7d55b8..0000000 --- a/data/shaders/crt-geom.frag +++ /dev/null @@ -1,23 +0,0 @@ -#define distortion 0.08 - -in vec2 texCoord; -out vec4 fragColor; - -uniform sampler2D tex; - -vec2 radialDistortion(vec2 coord) { - vec2 cc = coord - vec2(0.5); - float dist = dot(cc, cc) * distortion; - return coord + cc * (1.0 - dist) * dist; -} - -void main(void) { - vec4 rgba = texture2D(tex, radialDistortion(texCoord)); - - vec4 intensity = fract(gl_FragCoord.y * (0.5 * 4.0 / 3.0)) > 0.5 - ? vec4(0) - : smoothstep(0.2, 0.8, rgba) + normalize(rgba); - - fragColor = intensity * -0.25 + rgba * 1.1; - -} \ No newline at end of file diff --git a/data/shaders/crt-simple.frag b/data/shaders/crt-simple.frag deleted file mode 100644 index 00fd3bc..0000000 --- a/data/shaders/crt-simple.frag +++ /dev/null @@ -1,15 +0,0 @@ -in vec2 texCoord; -out vec4 fragColor; - -uniform sampler2D tex; - -void main(void) -{ - vec4 rgba = texture2D(tex, texCoord); - - vec4 intensity = fract(gl_FragCoord.y * (0.5 * 4.0 / 3.0)) > 0.5 - ? vec4(0) - : smoothstep(0.2, 0.8, rgba) + normalize(rgba); - - fragColor = intensity * -0.25 + rgba * 1.1; -} diff --git a/data/shaders/common.vert b/src/ext/shader/common.vert similarity index 57% rename from data/shaders/common.vert rename to src/ext/shader/common.vert index 8fcb0f0..de915c5 100644 --- a/data/shaders/common.vert +++ b/src/ext/shader/common.vert @@ -1,14 +1,20 @@ -attribute vec3 gpu_Vertex; +CODE( + +#version 100\n +precision highp float; +precision mediump int; + +attribute vec2 gpu_Vertex; attribute vec2 gpu_TexCoord; -attribute vec4 gpu_Color; +attribute mediump vec4 gpu_Color; uniform mat4 gpu_ModelViewProjectionMatrix; -varying vec4 color; +varying mediump vec4 color; varying vec2 texCoord; void main(void) { color = gpu_Color; texCoord = vec2(gpu_TexCoord); - gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 1.0); -} \ No newline at end of file + gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0); +}) \ No newline at end of file diff --git a/data/shaders/crt-lottes.frag b/src/ext/shader/crt-lottes.frag similarity index 94% rename from data/shaders/crt-lottes.frag rename to src/ext/shader/crt-lottes.frag index 570126b..580d2f3 100644 --- a/data/shaders/crt-lottes.frag +++ b/src/ext/shader/crt-lottes.frag @@ -1,5 +1,11 @@ -in vec2 texCoord; -out vec4 fragColor; +CODE( + +#version 100\n +precision highp float; +precision mediump int; + +varying vec2 texCoord; +//vec4 fragColor; uniform sampler2D tex; uniform float trg_w; @@ -120,7 +126,8 @@ void main() { // maskDark=maskLight; vec2 pos=Warp(gl_FragCoord.xy/trg); + vec4 fragColor; fragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy); fragColor.a=1.0; - fragColor = vec4(ToSrgb(fragColor.rgb), fragColor.a); -} + gl_FragColor = vec4(ToSrgb(fragColor.rgb), fragColor.a); +}) \ No newline at end of file diff --git a/src/system.c b/src/system.c index 7fc2e93..bf5cc3e 100644 --- a/src/system.c +++ b/src/system.c @@ -1060,87 +1060,44 @@ static void emstick() #endif -Uint32 load_shader(GPU_ShaderEnum shader_type, const char* filename) -{ - SDL_RWops* rwops; - Uint32 shader; - char* source; - int header_size, file_size; - const char* header = ""; - GPU_Renderer* renderer = GPU_GetCurrentRenderer(); - - // Open file - rwops = SDL_RWFromFile(filename, "rb"); - if(rwops == NULL) - { - GPU_PushErrorCode("load_shader", GPU_ERROR_FILE_NOT_FOUND, "Shader file \"%s\" not found", filename); - return 0; - } - - // Get file size - file_size = SDL_RWseek(rwops, 0, SEEK_END); - SDL_RWseek(rwops, 0, SEEK_SET); - - // Get size from header - if(renderer->shader_language == GPU_LANGUAGE_GLSL) - { - if(renderer->max_shader_version >= 120) - header = "#version 120\n"; - else - header = "#version 110\n"; // Maybe this is good enough? - } - else if(renderer->shader_language == GPU_LANGUAGE_GLSLES) - header = "#version 100\nprecision mediump int;\nprecision mediump float;\n"; - - header_size = strlen(header); - - // Allocate source buffer - source = (char*)malloc(sizeof(char)*(header_size + file_size + 1)); - - // Prepend header - strcpy(source, header); - - // Read in source code - SDL_RWread(rwops, source + strlen(source), 1, file_size); - source[header_size + file_size] = '\0'; - - // Compile the shader - shader = GPU_CompileShader(shader_type, source); - - // Clean up - free(source); - SDL_RWclose(rwops); - - return shader; -} +#define CODE(...) #__VA_ARGS__ -GPU_ShaderBlock load_shader_program(Uint32* p, const char* vertex_shader_file, const char* fragment_shader_file) +u32 load_shader_program() { Uint32 v, f; - v = load_shader(GPU_VERTEX_SHADER, vertex_shader_file); + + static const char* VertexShader = + #include "ext/shader/common.vert" + ; + + v = GPU_CompileShader(GPU_VERTEX_SHADER, VertexShader); if(!v) - GPU_LogError("Failed to load vertex shader (%s): %s\n", vertex_shader_file, GPU_GetShaderMessage()); - - f = load_shader(GPU_PIXEL_SHADER, fragment_shader_file); + GPU_LogError("Failed to load vertex shader: %s\n", GPU_GetShaderMessage()); + + static const char* PixelShader = + #include "ext/shader/crt-lottes.frag" + ; + + f = GPU_CompileShader(GPU_PIXEL_SHADER, PixelShader); if(!f) - GPU_LogError("Failed to load fragment shader (%s): %s\n", fragment_shader_file, GPU_GetShaderMessage()); + GPU_LogError("Failed to load fragment shader: %s\n", GPU_GetShaderMessage()); - *p = GPU_LinkShaders(v, f); + u32 p = GPU_LinkShaders(v, f); - if(!*p) + if(!p) { GPU_ShaderBlock b = {-1, -1, -1, -1}; - GPU_LogError("Failed to link shader program (%s + %s): %s\n", vertex_shader_file, fragment_shader_file, GPU_GetShaderMessage()); - return b; + GPU_LogError("Failed to link shader program: %s\n", GPU_GetShaderMessage()); + return p; } { - GPU_ShaderBlock block = GPU_LoadShaderBlock(*p, "gpu_Vertex", "gpu_TexCoord", "gpu_Color", "gpu_ModelViewProjectionMatrix"); - GPU_ActivateShaderProgram(*p, &block); + GPU_ShaderBlock block = GPU_LoadShaderBlock(p, "gpu_Vertex", "gpu_TexCoord", "gpu_Color", "gpu_ModelViewProjectionMatrix"); + GPU_ActivateShaderProgram(p, &block); - return block; + return p; } } @@ -1176,12 +1133,11 @@ static s32 start(s32 argc, char **argv, const char* folder) GPU_Target* screen = GPU_Init(Width, Height, GPU_INIT_DISABLE_VSYNC); - GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_BGRA); + GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_RGBA);// GPU_FORMAT_BGRA); GPU_SetAnchor(texture, 0, 0); GPU_SetImageFilter(texture, GPU_FILTER_NEAREST); - u32 crt_shader = 0; - load_shader_program(&crt_shader, "data/shaders/common.vert", "data/shaders/crt-lottes.frag"); + u32 crt_shader = load_shader_program(&crt_shader); { u64 nextTick = SDL_GetPerformanceCounter(); From 123ba094c6472f0ecd303a402c49f7d31f5e0033 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Wed, 21 Feb 2018 20:53:49 +0300 Subject: [PATCH 07/11] sdl-gpu as statoc lib for UWP --- .gitignore | 12 ++-- .../sdl-gpu-static.vcxproj} | 63 +++++++------------ .../sdl-gpu-static.vcxproj.filters} | 24 +++---- build/uwp/{sdl-gpu => tic}/packages.config | 0 build/uwp/tic/tic.sln | 26 ++++---- build/uwp/tic/tic.vcxproj | 12 +++- build/uwp/tic/tic.vcxproj.filters | 1 + 7 files changed, 60 insertions(+), 78 deletions(-) rename build/uwp/{sdl-gpu/sdl-gpu.vcxproj => sdl-gpu-static/sdl-gpu-static.vcxproj} (80%) rename build/uwp/{sdl-gpu/sdl-gpu.vcxproj.filters => sdl-gpu-static/sdl-gpu-static.vcxproj.filters} (79%) rename build/uwp/{sdl-gpu => tic}/packages.config (100%) diff --git a/.gitignore b/.gitignore index a8ba750..ad5ae32 100644 --- a/.gitignore +++ b/.gitignore @@ -115,10 +115,10 @@ build/windows/sdl-gpu/Debug/ build/windows/sdl-gpu/Debug Pro/ build/windows/sdl-gpu/Release/ build/windows/sdl-gpu/Release Pro/ -build/uwp/sdl-gpu/Debug/ -build/uwp/sdl-gpu/Debug Pro/ -build/uwp/sdl-gpu/Release/ -build/uwp/sdl-gpu/Release Pro/ -build/uwp/sdl-gpu/ARM/ -build/uwp/sdl-gpu/x64/ +build/uwp/sdl-gpu-static/Debug/ +build/uwp/sdl-gpu-static/Debug Pro/ +build/uwp/sdl-gpu-static/Release/ +build/uwp/sdl-gpu-static/Release Pro/ +build/uwp/sdl-gpu-static/ARM/ +build/uwp/sdl-gpu-static/x64/ build/uwp/tic/packages/ diff --git a/build/uwp/sdl-gpu/sdl-gpu.vcxproj b/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj similarity index 80% rename from build/uwp/sdl-gpu/sdl-gpu.vcxproj rename to build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj index 38ec2cb..a2bf10d 100644 --- a/build/uwp/sdl-gpu/sdl-gpu.vcxproj +++ b/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj @@ -33,20 +33,11 @@ - - - - - - - - {89e9b32e-a86a-47c3-a948-d2b1622925ce} - - {3d303f81-f49f-4d63-be32-370c07e271b7} - DynamicLibrary - sdl_gpu + {361dfddb-f86e-4c2c-abee-03acf4b8ac33} + StaticLibrary + sdl_gpu_static en-US 14.0 true @@ -57,34 +48,34 @@ - DynamicLibrary + StaticLibrary true v140 - DynamicLibrary + StaticLibrary true v140 - DynamicLibrary + StaticLibrary true v140 - DynamicLibrary + StaticLibrary false true v140 - DynamicLibrary + StaticLibrary false true v140 - DynamicLibrary + StaticLibrary false true v140 @@ -116,116 +107,104 @@ false - false false - false false - false false - false false - false false - false NotUsing false - _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) - ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) Console false false - WindowsApp.lib;%(AdditionalDependencies) NotUsing false - _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) - ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) Console false false - WindowsApp.lib;%(AdditionalDependencies) NotUsing false - _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) - ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) Console false false - WindowsApp.lib;%(AdditionalDependencies) NotUsing false - _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) - ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) Console false false - WindowsApp.lib;%(AdditionalDependencies) NotUsing false - _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) - ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) Console false false - WindowsApp.lib;%(AdditionalDependencies) NotUsing false - _WINDOWS;GLEW_STATIC;SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;STBI_FAILURE_USERMSG;SDL_GPU_USE_BUFFER_RESET;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) - ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) false + ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) Console false false - WindowsApp.lib;%(AdditionalDependencies) diff --git a/build/uwp/sdl-gpu/sdl-gpu.vcxproj.filters b/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj.filters similarity index 79% rename from build/uwp/sdl-gpu/sdl-gpu.vcxproj.filters rename to build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj.filters index f52f9f0..8d95540 100644 --- a/build/uwp/sdl-gpu/sdl-gpu.vcxproj.filters +++ b/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj.filters @@ -2,33 +2,27 @@ - {d9d32195-021b-46b4-8ea0-ab03b10402b7} + {c3550c01-2588-4878-8d79-ead29ff8053e} - - src - - - src - - + src src - - src - src - + + src + + + src + + src - - - \ No newline at end of file diff --git a/build/uwp/sdl-gpu/packages.config b/build/uwp/tic/packages.config similarity index 100% rename from build/uwp/sdl-gpu/packages.config rename to build/uwp/tic/packages.config diff --git a/build/uwp/tic/tic.sln b/build/uwp/tic/tic.sln index c70f171..924a807 100644 --- a/build/uwp/tic/tic.sln +++ b/build/uwp/tic/tic.sln @@ -19,7 +19,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren", "..\wren\wren.vcxpro EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "studio", "..\studio\studio.vcxproj", "{6A22403A-6CF5-49F2-A012-EC04C9496306}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl-gpu", "..\sdl-gpu\sdl-gpu.vcxproj", "{3D303F81-F49F-4D63-BE32-370C07E271B7}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl-gpu-static", "..\sdl-gpu-static\sdl-gpu-static.vcxproj", "{361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -133,18 +133,18 @@ Global {6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x64.Build.0 = Release|x64 {6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x86.ActiveCfg = Release|Win32 {6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x86.Build.0 = Release|Win32 - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|ARM.ActiveCfg = Debug|ARM - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|ARM.Build.0 = Debug|ARM - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|x64.ActiveCfg = Debug|x64 - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|x64.Build.0 = Debug|x64 - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|x86.ActiveCfg = Debug|Win32 - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Debug|x86.Build.0 = Debug|Win32 - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|ARM.ActiveCfg = Release|ARM - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|ARM.Build.0 = Release|ARM - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|x64.ActiveCfg = Release|x64 - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|x64.Build.0 = Release|x64 - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|x86.ActiveCfg = Release|Win32 - {3D303F81-F49F-4D63-BE32-370C07E271B7}.Release|x86.Build.0 = Release|Win32 + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|ARM.ActiveCfg = Debug|ARM + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|ARM.Build.0 = Debug|ARM + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|x64.ActiveCfg = Debug|x64 + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|x64.Build.0 = Debug|x64 + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|x86.ActiveCfg = Debug|Win32 + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|x86.Build.0 = Debug|Win32 + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|ARM.ActiveCfg = Release|ARM + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|ARM.Build.0 = Release|ARM + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|x64.ActiveCfg = Release|x64 + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|x64.Build.0 = Release|x64 + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|x86.ActiveCfg = Release|Win32 + {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/uwp/tic/tic.vcxproj b/build/uwp/tic/tic.vcxproj index 8bf38cb..d6b886b 100644 --- a/build/uwp/tic/tic.vcxproj +++ b/build/uwp/tic/tic.vcxproj @@ -203,6 +203,7 @@ Designer + @@ -219,8 +220,8 @@ {89e9b32e-a86a-47c3-a948-d2b1622925ce} - - {3d303f81-f49f-4d63-be32-370c07e271b7} + + {361dfddb-f86e-4c2c-abee-03acf4b8ac33} {6a22403a-6cf5-49f2-a012-ec04c9496306} @@ -258,5 +259,12 @@ + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/build/uwp/tic/tic.vcxproj.filters b/build/uwp/tic/tic.vcxproj.filters index 6d7316c..ed685a2 100644 --- a/build/uwp/tic/tic.vcxproj.filters +++ b/build/uwp/tic/tic.vcxproj.filters @@ -45,6 +45,7 @@ + From ce83d422be79b2bea2870d2b6719955c7162595e Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Wed, 21 Feb 2018 21:02:55 +0300 Subject: [PATCH 08/11] no message --- 3rd-party | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rd-party b/3rd-party index f9e1081..c326432 160000 --- a/3rd-party +++ b/3rd-party @@ -1 +1 @@ -Subproject commit f9e108123796f9bb8bbe6c8b87239bb09fec14d0 +Subproject commit c326432f2ca415f4c63268a8ebff2221e03038e7 From ef41d6ec40d8815d760996aa70e7b28b25b4e6ca Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 22 Feb 2018 10:31:39 +0300 Subject: [PATCH 09/11] no message --- src/ext/shader/common.vert | 1 - src/ext/shader/crt-lottes.frag | 17 +++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ext/shader/common.vert b/src/ext/shader/common.vert index de915c5..f82e14d 100644 --- a/src/ext/shader/common.vert +++ b/src/ext/shader/common.vert @@ -1,6 +1,5 @@ CODE( -#version 100\n precision highp float; precision mediump int; diff --git a/src/ext/shader/crt-lottes.frag b/src/ext/shader/crt-lottes.frag index 580d2f3..1b1ad6b 100644 --- a/src/ext/shader/crt-lottes.frag +++ b/src/ext/shader/crt-lottes.frag @@ -1,16 +1,13 @@ CODE( -#version 100\n precision highp float; precision mediump int; -varying vec2 texCoord; -//vec4 fragColor; - uniform sampler2D tex; uniform float trg_w; uniform float trg_h; + // Emulated input resolution. vec2 res=vec2(256.0,144.0); @@ -51,7 +48,7 @@ vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));} // Also zero's off screen. vec3 Fetch(vec2 pos,vec2 off){ pos=(floor(pos*res+off)+vec2(0.5,0.5))/res; - return ToLinear(1.2 * texture2D(tex,pos.xy,-16.0).rgb);} //vec2??? + return ToLinear(1.2 * texture2D(tex,pos.xy,-16.0).rgb);} // Distance in emulated pixels to nearest texel. vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));} @@ -124,10 +121,10 @@ vec3 Mask(vec2 pos){ void main() { + vec2 pos = gl_FragCoord.xy/trg.xy; + hardScan=-12.0; // maskDark=maskLight; - vec2 pos=Warp(gl_FragCoord.xy/trg); - vec4 fragColor; - fragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy); - fragColor.a=1.0; - gl_FragColor = vec4(ToSrgb(fragColor.rgb), fragColor.a); + pos=Warp(gl_FragCoord.xy/trg.xy); + gl_FragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy); + gl_FragColor = vec4(ToSrgb(gl_FragColor.rgb), 1.0); }) \ No newline at end of file From 840d67f48d4f513e398c652dabcac5d375490938 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 22 Feb 2018 10:58:20 +0300 Subject: [PATCH 10/11] no message --- src/ext/shader/crt-lottes.frag | 117 ++++++++++++++++----------------- 1 file changed, 57 insertions(+), 60 deletions(-) diff --git a/src/ext/shader/crt-lottes.frag b/src/ext/shader/crt-lottes.frag index 1b1ad6b..355f646 100644 --- a/src/ext/shader/crt-lottes.frag +++ b/src/ext/shader/crt-lottes.frag @@ -1,16 +1,14 @@ CODE( precision highp float; -precision mediump int; -uniform sampler2D tex; +varying vec2 texCoord; +uniform sampler2D source; uniform float trg_w; uniform float trg_h; - // Emulated input resolution. vec2 res=vec2(256.0,144.0); - vec2 trg=vec2(trg_w, trg_h); // Hardness of scanline. @@ -47,84 +45,83 @@ vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));} // Nearest emulated sample given floating point position and texel offset. // Also zero's off screen. vec3 Fetch(vec2 pos,vec2 off){ - pos=(floor(pos*res+off)+vec2(0.5,0.5))/res; - return ToLinear(1.2 * texture2D(tex,pos.xy,-16.0).rgb);} + pos=(floor(pos*res+off)+vec2(0.5,0.5))/res; + return ToLinear(1.2 * texture2D(source,pos.xy,-16.0).rgb);} // Distance in emulated pixels to nearest texel. vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));} - + // 1D Gaussian. float Gaus(float pos,float scale){return exp2(scale*pos*pos);} // 3-tap Gaussian filter along horz line. vec3 Horz3(vec2 pos,float off){ - vec3 b=Fetch(pos,vec2(-1.0,off)); - vec3 c=Fetch(pos,vec2( 0.0,off)); - vec3 d=Fetch(pos,vec2( 1.0,off)); - float dst=Dist(pos).x; - // Convert distance to weight. - float scale=hardPix; - float wb=Gaus(dst-1.0,scale); - float wc=Gaus(dst+0.0,scale); - float wd=Gaus(dst+1.0,scale); - // Return filtered sample. - return (b*wb+c*wc+d*wd)/(wb+wc+wd);} + vec3 b=Fetch(pos,vec2(-1.0,off)); + vec3 c=Fetch(pos,vec2( 0.0,off)); + vec3 d=Fetch(pos,vec2( 1.0,off)); + float dst=Dist(pos).x; + // Convert distance to weight. + float scale=hardPix; + float wb=Gaus(dst-1.0,scale); + float wc=Gaus(dst+0.0,scale); + float wd=Gaus(dst+1.0,scale); + // Return filtered sample. + return (b*wb+c*wc+d*wd)/(wb+wc+wd);} // 5-tap Gaussian filter along horz line. vec3 Horz5(vec2 pos,float off){ - vec3 a=Fetch(pos,vec2(-2.0,off)); - vec3 b=Fetch(pos,vec2(-1.0,off)); - vec3 c=Fetch(pos,vec2( 0.0,off)); - vec3 d=Fetch(pos,vec2( 1.0,off)); - vec3 e=Fetch(pos,vec2( 2.0,off)); - float dst=Dist(pos).x; - // Convert distance to weight. - float scale=hardPix; - float wa=Gaus(dst-2.0,scale); - float wb=Gaus(dst-1.0,scale); - float wc=Gaus(dst+0.0,scale); - float wd=Gaus(dst+1.0,scale); - float we=Gaus(dst+2.0,scale); - // Return filtered sample. - return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);} + vec3 a=Fetch(pos,vec2(-2.0,off)); + vec3 b=Fetch(pos,vec2(-1.0,off)); + vec3 c=Fetch(pos,vec2( 0.0,off)); + vec3 d=Fetch(pos,vec2( 1.0,off)); + vec3 e=Fetch(pos,vec2( 2.0,off)); + float dst=Dist(pos).x; + // Convert distance to weight. + float scale=hardPix; + float wa=Gaus(dst-2.0,scale); + float wb=Gaus(dst-1.0,scale); + float wc=Gaus(dst+0.0,scale); + float wd=Gaus(dst+1.0,scale); + float we=Gaus(dst+2.0,scale); + // Return filtered sample. + return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);} // Return scanline weight. float Scan(vec2 pos,float off){ - float dst=Dist(pos).y; - return Gaus(dst+off,hardScan);} + float dst=Dist(pos).y; + return Gaus(dst+off,hardScan);} // Allow nearest three lines to effect pixel. vec3 Tri(vec2 pos){ - vec3 a=Horz3(pos,-1.0); - vec3 b=Horz5(pos, 0.0); - vec3 c=Horz3(pos, 1.0); - float wa=Scan(pos,-1.0); - float wb=Scan(pos, 0.0); - float wc=Scan(pos, 1.0); - return a*wa+b*wb+c*wc;} + vec3 a=Horz3(pos,-1.0); + vec3 b=Horz5(pos, 0.0); + vec3 c=Horz3(pos, 1.0); + float wa=Scan(pos,-1.0); + float wb=Scan(pos, 0.0); + float wc=Scan(pos, 1.0); + return a*wa+b*wb+c*wc;} // Distortion of scanlines, and end of screen alpha. vec2 Warp(vec2 pos){ - pos=pos*2.0-1.0; - pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y); - return pos*0.5+0.5;} + pos=pos*2.0-1.0; + pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y); + return pos*0.5+0.5;} // Shadow mask. vec3 Mask(vec2 pos){ - pos.x+=pos.y*3.0; - vec3 mask=vec3(maskDark,maskDark,maskDark); - pos.x=fract(pos.x/6.0); - if(pos.x<0.333)mask.r=maskLight; - else if(pos.x<0.666)mask.g=maskLight; - else mask.b=maskLight; - return mask;} + pos.x+=pos.y*3.0; + vec3 mask=vec3(maskDark,maskDark,maskDark); + pos.x=fract(pos.x/6.0); + if(pos.x<0.333)mask.r=maskLight; + else if(pos.x<0.666)mask.g=maskLight; + else mask.b=maskLight; + return mask;} -void main() -{ - vec2 pos = gl_FragCoord.xy/trg.xy; - hardScan=-12.0; -// maskDark=maskLight; - pos=Warp(gl_FragCoord.xy/trg.xy); - gl_FragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy); - gl_FragColor = vec4(ToSrgb(gl_FragColor.rgb), 1.0); +void main() { + vec2 pos = gl_FragCoord.xy/trg.xy; + hardScan=-12.0; +// maskDark=maskLight; + pos=Warp(gl_FragCoord.xy/trg.xy); + gl_FragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy); + gl_FragColor = vec4(ToSrgb(gl_FragColor.rgb), 1.0); }) \ No newline at end of file From 11751e75e7a929afe5c7d400cdb1b5a5ed733b00 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 22 Feb 2018 11:38:31 +0300 Subject: [PATCH 11/11] changed pixel format to RGBA --- src/system.c | 13 +++---------- src/tools.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/system.c b/src/system.c index bf5cc3e..5e683e6 100644 --- a/src/system.c +++ b/src/system.c @@ -14,7 +14,7 @@ #endif #define STUDIO_UI_SCALE 4 -#define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888 +#define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ABGR8888 #define TEXTURE_SIZE (TIC80_FULLWIDTH) #define OFFSET_LEFT ((TIC80_FULLWIDTH-TIC80_WIDTH)/2) #define OFFSET_TOP ((TIC80_FULLHEIGHT-TIC80_HEIGHT)/2) @@ -1101,11 +1101,6 @@ u32 load_shader_program() } } -void free_shader(Uint32 p) -{ - GPU_FreeShaderProgram(p); -} - #include static s32 start(s32 argc, char **argv, const char* folder) @@ -1133,7 +1128,7 @@ static s32 start(s32 argc, char **argv, const char* folder) GPU_Target* screen = GPU_Init(Width, Height, GPU_INIT_DISABLE_VSYNC); - GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_RGBA);// GPU_FORMAT_BGRA); + GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_RGBA); GPU_SetAnchor(texture, 0, 0); GPU_SetImageFilter(texture, GPU_FILTER_NEAREST); @@ -1196,10 +1191,8 @@ static s32 start(s32 argc, char **argv, const char* folder) SDL_CloseAudioDevice(platform.audio.device); - free_shader(crt_shader); - + GPU_FreeShaderProgram(crt_shader); GPU_FreeImage(texture); - GPU_Quit(); return 0; diff --git a/src/tools.c b/src/tools.c index 807f530..3b9f397 100644 --- a/src/tools.c +++ b/src/tools.c @@ -88,20 +88,20 @@ u32 tic_tool_find_closest_color(const tic_rgb* palette, const tic_rgb* color) u32* tic_palette_blit(const tic_palette* srcpal) { - static u32 pal[TIC_PALETTE_SIZE] = {0}; - - const u8* src = srcpal->data; - - memset(pal, 0xff, sizeof pal); + static u32 pal[TIC_PALETTE_SIZE]; + const tic_rgb* src = srcpal->colors; + const tic_rgb* end = src + TIC_PALETTE_SIZE; u8* dst = (u8*)pal; - const u8* end = src + sizeof(tic_palette); - enum{RGB = sizeof(tic_rgb)}; - - for(; src != end; dst++, src+=RGB) - for(s32 j = 0; j < RGB; j++) - *dst++ = *(src+(RGB-1)-j); + while(src != end) + { + *dst++ = src->r; + *dst++ = src->g; + *dst++ = src->b; + *dst++ = 0xff; + src++; + } return pal; -} \ No newline at end of file +}