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();