diff --git a/cnc-ddraw.vcxproj b/cnc-ddraw.vcxproj index 580c416..670fb03 100644 --- a/cnc-ddraw.vcxproj +++ b/cnc-ddraw.vcxproj @@ -32,7 +32,8 @@ - + + diff --git a/cnc-ddraw.vcxproj.filters b/cnc-ddraw.vcxproj.filters index 0fda0cd..93af5df 100644 --- a/cnc-ddraw.vcxproj.filters +++ b/cnc-ddraw.vcxproj.filters @@ -89,7 +89,10 @@ Header Files - + + Header Files + + Header Files diff --git a/inc/d3d9shader.h b/inc/d3d9shader.h new file mode 100644 index 0000000..f2bad6b --- /dev/null +++ b/inc/d3d9shader.h @@ -0,0 +1,101 @@ +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 10.1 +// +// Parameters: +// +// sampler2D PaletteTex; +// sampler2D SurfaceTex; +// +// +// Registers: +// +// Name Reg Size +// ------------ ----- ---- +// SurfaceTex s0 1 +// PaletteTex s1 1 +// + + ps_2_0 + def c0, 0.99609375, 0.001953125, 0, 0 + dcl t0.xy + dcl_2d s0 + dcl_2d s1 + texld r0, t0, s0 + mad r0.x, r0.x, c0.x, c0.y + mov r0.y, c0.z + texld r0, r0, s1 + mov oC0, r0 + +// approximately 5 instruction slots used (2 texture, 3 arithmetic) + +// fxc.exe /Tps_2_0 shader.hlsl /Fhshader.h +/* +uniform sampler2D SurfaceTex; +uniform sampler2D PaletteTex; + +float4 main(float2 texCoords : TEXCOORD) : COLOR +{ + float pIndex = tex2D(SurfaceTex, texCoords).r; + return tex2D(PaletteTex, float2(pIndex * (255./256) + (0.5/256), 0)); +} +*/ +#endif + +const BYTE PalettePixelShaderSrc[] = +{ + 0, 2, 255, 255, 254, 255, + 44, 0, 67, 84, 65, 66, + 28, 0, 0, 0, 131, 0, + 0, 0, 0, 2, 255, 255, + 2, 0, 0, 0, 28, 0, + 0, 0, 0, 1, 0, 0, + 124, 0, 0, 0, 68, 0, + 0, 0, 3, 0, 1, 0, + 1, 0, 0, 0, 80, 0, + 0, 0, 0, 0, 0, 0, + 96, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 108, 0, 0, 0, 0, 0, + 0, 0, 80, 97, 108, 101, + 116, 116, 101, 84, 101, 120, + 0, 171, 4, 0, 12, 0, + 1, 0, 1, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 83, 117, 114, 102, 97, 99, + 101, 84, 101, 120, 0, 171, + 4, 0, 12, 0, 1, 0, + 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 112, 115, + 95, 50, 95, 48, 0, 77, + 105, 99, 114, 111, 115, 111, + 102, 116, 32, 40, 82, 41, + 32, 72, 76, 83, 76, 32, + 83, 104, 97, 100, 101, 114, + 32, 67, 111, 109, 112, 105, + 108, 101, 114, 32, 49, 48, + 46, 49, 0, 171, 81, 0, + 0, 5, 0, 0, 15, 160, + 0, 0, 127, 63, 0, 0, + 0, 59, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 0, + 0, 2, 0, 0, 0, 128, + 0, 0, 3, 176, 31, 0, + 0, 2, 0, 0, 0, 144, + 0, 8, 15, 160, 31, 0, + 0, 2, 0, 0, 0, 144, + 1, 8, 15, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 176, 0, 8, + 228, 160, 4, 0, 0, 4, + 0, 0, 1, 128, 0, 0, + 0, 128, 0, 0, 0, 160, + 0, 0, 85, 160, 1, 0, + 0, 2, 0, 0, 2, 128, + 0, 0, 170, 160, 66, 0, + 0, 3, 0, 0, 15, 128, + 0, 0, 228, 128, 1, 8, + 228, 160, 1, 0, 0, 2, + 0, 8, 15, 128, 0, 0, + 228, 128, 255, 255, 0, 0 +}; diff --git a/inc/paletteshader.h b/inc/openglshader.h similarity index 52% rename from inc/paletteshader.h rename to inc/openglshader.h index 52dcf80..dad8f24 100644 --- a/inc/paletteshader.h +++ b/inc/openglshader.h @@ -1,6 +1,6 @@ // old -static const char PassthroughVertShader110Src[] = +const char PassthroughVertShader110Src[] = "#version 110\n" "varying vec2 TEX0; \n" "\n" @@ -10,7 +10,7 @@ static const char PassthroughVertShader110Src[] = " TEX0 = gl_MultiTexCoord0.xy; \n" "}\n"; -static const char PaletteFragShader110Src[] = +const char PaletteFragShader110Src[] = "#version 110\n" "uniform sampler2D SurfaceTex; \n" "uniform sampler2D PaletteTex; \n" @@ -25,7 +25,7 @@ static const char PaletteFragShader110Src[] = // new -static const char PassthroughVertShaderSrc[] = +const char PassthroughVertShaderSrc[] = "#version 130\n" "in vec4 VertexCoord;\n" "in vec4 COLOR;\n" @@ -42,7 +42,7 @@ static const char PassthroughVertShaderSrc[] = "}\n"; -static const char PaletteFragShaderSrc[] = +const char PaletteFragShaderSrc[] = "#version 130\n" "out vec4 FragColor;\n" "uniform sampler2D SurfaceTex;\n" @@ -55,20 +55,3 @@ static const char PaletteFragShaderSrc[] = " FragColor = texture(PaletteTex, vec2(pIndex.r * (255.0/256.0) + (0.5/256.0), 0));\n" "}\n"; - -static const BYTE PalettePixelShaderSrc[] = -{ - 0,2,255,255,254,255,42,0,67,84,65,66,28,0,0,0,115,0,0,0,0,2,255,255, - 2,0,0,0,28,0,0,0,0,1,0,0,108,0,0,0,68,0,0,0,3,0,0,0, - 1,0,2,0,72,0,0,0,0,0,0,0,88,0,0,0,3,0,1,0,1,0,6,0, - 92,0,0,0,0,0,0,0,115,48,0,171,4,0,12,0,1,0,1,0,1,0,0,0, - 0,0,0,0,115,49,0,171,4,0,12,0,1,0,1,0,1,0,0,0,0,0,0,0, - 112,115,95,50,95,48,0,77,105,99,114,111,115,111,102,116,32,40,82,41,32,72,76,83, - 76,32,83,104,97,100,101,114,32,67,111,109,112,105,108,101,114,32,57,46,50,57,46,57, - 53,50,46,51,49,49,49,0,81,0,0,5,0,0,15,160,0,0,127,63,0,0,0,59, - 0,0,0,0,0,0,0,0,31,0,0,2,0,0,0,128,0,0,3,176,31,0,0,2, - 0,0,0,144,0,8,15,160,31,0,0,2,0,0,0,144,1,8,15,160,66,0,0,3, - 0,0,15,128,0,0,228,176,0,8,228,160,4,0,0,4,0,0,1,128,0,0,0,128, - 0,0,0,160,0,0,85,160,1,0,0,2,0,0,2,128,0,0,170,160,66,0,0,3, - 0,0,15,128,0,0,228,128,1,8,228,160,1,0,0,2,0,8,15,128,0,0,228,128,255,255,0,0 -}; diff --git a/src/render.c b/src/render.c index 3274e65..3a167a6 100644 --- a/src/render.c +++ b/src/render.c @@ -20,7 +20,7 @@ #include "opengl.h" #include "main.h" #include "surface.h" -#include "paletteshader.h" +#include "openglshader.h" #define TEXTURE_COUNT 4 diff --git a/src/render_d3d9.c b/src/render_d3d9.c index 13eea81..7684d3a 100644 --- a/src/render_d3d9.c +++ b/src/render_d3d9.c @@ -3,7 +3,7 @@ #include #include "main.h" #include "surface.h" -#include "paletteshader.h" +#include "d3d9shader.h" typedef struct CUSTOMVERTEX { float x, y, z, rhw, u, v; } CUSTOMVERTEX;