- Working on the SpriteBatch_GLSL.fx
- Working on the Parameters property which now collects the names and ids
This commit is contained in:
parent
c3007a980e
commit
9fcf9ec91f
@ -58,6 +58,8 @@ namespace ANX.Framework.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native OpenGL Effect implementation.
|
||||
///
|
||||
/// http://wiki.delphigl.com/index.php/Tutorial_glsl
|
||||
/// </summary>
|
||||
public class EffectGL3 : INativeEffect
|
||||
{
|
||||
@ -81,7 +83,10 @@ namespace ANX.Framework.Windows.GL3
|
||||
List<EffectTechnique> techniques = new List<EffectTechnique>();
|
||||
|
||||
// TODO: dummy, fill with actual data.
|
||||
techniques.Add(new EffectTechnique());
|
||||
techniques.Add(new EffectTechnique()
|
||||
{
|
||||
NativeTechnique = new EffectTechniqueGL3(),
|
||||
});
|
||||
|
||||
return techniques;
|
||||
}
|
||||
@ -95,17 +100,25 @@ namespace ANX.Framework.Windows.GL3
|
||||
{
|
||||
List<EffectParameter> parameters = new List<EffectParameter>();
|
||||
|
||||
int uniformCount;
|
||||
GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms, out uniformCount);
|
||||
int uniformCount;
|
||||
GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms,
|
||||
out uniformCount);
|
||||
|
||||
string[] uniformNames = new string[uniformCount];
|
||||
int[] uniformIndices = new int[uniformCount];
|
||||
List<string> names = new List<string>();
|
||||
for (int index = 0; index < uniformCount; index++)
|
||||
{
|
||||
string name = GL.GetActiveUniformName(programHandle, 0);
|
||||
|
||||
//TODO: this command doesn't work ?!?! -> GL.GetUniformIndices(programHandle, uniformCount, uniformNames, uniformIndices);
|
||||
|
||||
|
||||
// TODO: dummy, fill with actual data.
|
||||
parameters.Add(new EffectParameter());
|
||||
if (names.Contains(name) == false)
|
||||
{
|
||||
names.Add(name);
|
||||
int uniformIndex = GL.GetUniformLocation(programHandle, name);
|
||||
parameters.Add(new EffectParameter()
|
||||
{
|
||||
NativeParameter = new EffectParameterGL3(name, uniformIndex),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
@ -291,7 +304,7 @@ namespace ANX.Framework.Windows.GL3
|
||||
#region Apply (TODO)
|
||||
public void Apply(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
GL.UseProgram(programHandle);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -65,14 +65,25 @@ namespace ANX.Framework.Windows.GL3
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The index of the uniform.
|
||||
/// </summary>
|
||||
public int UniformIndex
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a ne effect parameter object.
|
||||
/// </summary>
|
||||
internal EffectParameterGL3()
|
||||
internal EffectParameterGL3(string setName, int setUniformIndex)
|
||||
{
|
||||
Name = setName;
|
||||
UniformIndex = setUniformIndex;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -54,60 +54,25 @@ namespace ANX.Framework.Windows.GL3
|
||||
#region SpriteBatchShader
|
||||
internal static byte[] SpriteBatchByteCode = new byte[]
|
||||
{
|
||||
224,
|
||||
007, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
|
||||
153,
|
||||
002, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116, 114, 105, 120,
|
||||
084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110,
|
||||
040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061,
|
||||
103, 108, 095, 077, 111, 100, 101, 108, 086, 105, 101, 119, 080, 114, 111, 106, 101, 099, 116, 105,
|
||||
111, 110, 077, 097, 116, 114, 105, 120, 042, 103, 108, 095, 086, 101, 114, 116, 101, 120, 059, 125,
|
||||
010, 035, 035, 033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 118, 111, 105, 100,
|
||||
032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108, 095, 070, 114, 097, 103,
|
||||
067, 111, 108, 111, 114, 061, 118, 101, 099, 052, 040, 049, 046, 048, 044, 049, 046, 048, 044, 049,
|
||||
046, 048, 044, 049, 046, 048, 041, 059, 125, 010, 047, 042, 010, 084, 101, 120, 116, 117, 114, 101,
|
||||
050, 068, 060, 102, 108, 111, 097, 116, 052, 062, 032, 084, 101, 120, 116, 117, 114, 101, 032, 058,
|
||||
032, 114, 101, 103, 105, 115, 116, 101, 114, 040, 116, 048, 041, 059, 010, 115, 097, 109, 112, 108,
|
||||
101, 114, 032, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, 114, 032, 058, 032,
|
||||
114, 101, 103, 105, 115, 116, 101, 114, 040, 115, 048, 041, 059, 010, 115, 116, 114, 117, 099, 116,
|
||||
032, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 123, 010,
|
||||
102, 108, 111, 097, 116, 052, 032, 112, 111, 115, 032, 058, 032, 080, 079, 083, 073, 084, 073, 079,
|
||||
078, 059, 010, 102, 108, 111, 097, 116, 052, 032, 099, 111, 108, 032, 058, 032, 067, 079, 076, 079,
|
||||
082, 059, 010, 102, 108, 111, 097, 116, 050, 032, 116, 101, 120, 032, 058, 032, 084, 069, 088, 067,
|
||||
079, 079, 082, 068, 048, 059, 010, 125, 059, 010, 115, 116, 114, 117, 099, 116, 032, 080, 105, 120,
|
||||
101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 123, 010, 102, 108, 111, 097, 116,
|
||||
052, 032, 112, 111, 115, 032, 058, 032, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 059,
|
||||
010, 102, 108, 111, 097, 116, 052, 032, 099, 111, 108, 032, 058, 032, 067, 079, 076, 079, 082, 059,
|
||||
010, 102, 108, 111, 097, 116, 050, 032, 116, 101, 120, 032, 058, 032, 084, 069, 088, 067, 079, 079,
|
||||
082, 068, 048, 059, 010, 125, 059, 010, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 073,
|
||||
110, 112, 117, 116, 032, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097,
|
||||
100, 101, 114, 040, 032, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 073, 110, 112,
|
||||
117, 116, 032, 105, 110, 112, 117, 116, 032, 041, 123, 010, 080, 105, 120, 101, 108, 083, 104, 097,
|
||||
100, 101, 114, 073, 110, 112, 117, 116, 032, 111, 117, 116, 112, 117, 116, 061, 040, 080, 105, 120,
|
||||
101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 041, 048, 059, 010, 111, 117, 116,
|
||||
112, 117, 116, 046, 112, 111, 115, 061, 109, 117, 108, 040, 105, 110, 112, 117, 116, 046, 112, 111,
|
||||
115, 044, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 041, 059, 010,
|
||||
111, 117, 116, 112, 117, 116, 046, 099, 111, 108, 061, 105, 110, 112, 117, 116, 046, 099, 111, 108,
|
||||
059, 010, 111, 117, 116, 112, 117, 116, 046, 116, 101, 120, 061, 105, 110, 112, 117, 116, 046, 116,
|
||||
101, 120, 059, 010, 114, 101, 116, 117, 114, 110, 032, 111, 117, 116, 112, 117, 116, 059, 125, 010,
|
||||
102, 108, 111, 097, 116, 052, 032, 083, 112, 114, 105, 116, 101, 080, 105, 120, 101, 108, 083, 104,
|
||||
097, 100, 101, 114, 040, 032, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112,
|
||||
117, 116, 032, 105, 110, 112, 117, 116, 032, 041, 032, 058, 032, 083, 086, 095, 084, 097, 114, 103,
|
||||
101, 116, 123, 010, 114, 101, 116, 117, 114, 110, 032, 084, 101, 120, 116, 117, 114, 101, 046, 083,
|
||||
097, 109, 112, 108, 101, 040, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, 114,
|
||||
044, 105, 110, 112, 117, 116, 046, 116, 101, 120, 041, 042, 105, 110, 112, 117, 116, 046, 099, 111,
|
||||
108, 059, 125, 010, 116, 101, 099, 104, 110, 105, 113, 117, 101, 049, 048, 032, 083, 112, 114, 105,
|
||||
116, 101, 084, 101, 099, 104, 110, 105, 113, 117, 101, 123, 010, 112, 097, 115, 115, 032, 083, 112,
|
||||
114, 105, 116, 101, 067, 111, 108, 111, 114, 080, 097, 115, 115, 123, 010, 083, 101, 116, 071, 101,
|
||||
111, 109, 101, 116, 114, 121, 083, 104, 097, 100, 101, 114, 040, 032, 048, 032, 041, 059, 010, 083,
|
||||
101, 116, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 040, 032, 067, 111, 109, 112,
|
||||
105, 108, 101, 083, 104, 097, 100, 101, 114, 040, 032, 118, 115, 095, 052, 095, 048, 044, 083, 112,
|
||||
114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 040, 041, 032, 041,
|
||||
032, 041, 059, 010, 083, 101, 116, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 040, 032,
|
||||
067, 111, 109, 112, 105, 108, 101, 083, 104, 097, 100, 101, 114, 040, 032, 112, 115, 095, 052, 095,
|
||||
048, 044, 083, 112, 114, 105, 116, 101, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 040,
|
||||
041, 032, 041, 032, 041, 059, 125, 010, 125, 010, 042, 047, 010, 117, 140, 064, 187, 232, 054, 126,
|
||||
209, 103, 145, 103, 013, 029, 122, 079, 091, 098, 241, 220, 158, 076, 040, 008, 035, 172, 166, 125,
|
||||
213, 214, 199, 171, 220, 149, 178, 155, 164, 238, 077, 175, 178, 130, 078, 077, 229, 197, 006, 010,
|
||||
071, 037, 113, 028, 110, 096, 111, 079, 211, 240, 031, 083, 045, 193, 025, 040, 058
|
||||
111, 110, 077, 097, 116, 114, 105, 120, 042, 103, 108, 095, 086, 101, 114, 116, 101, 120, 059, 010,
|
||||
103, 108, 095, 084, 101, 120, 067, 111, 111, 114, 100, 091, 048, 093, 061, 103, 108, 095, 077, 117,
|
||||
108, 116, 105, 084, 101, 120, 067, 111, 111, 114, 100, 048, 059, 010, 103, 108, 095, 070, 114, 111,
|
||||
110, 116, 067, 111, 108, 111, 114, 061, 103, 108, 095, 067, 111, 108, 111, 114, 059, 125, 010, 035,
|
||||
035, 033, 102, 114, 097, 103, 109, 101, 110, 116, 033, 035, 035, 010, 117, 110, 105, 102, 111, 114,
|
||||
109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059,
|
||||
010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 123, 010, 103, 108,
|
||||
095, 070, 114, 097, 103, 067, 111, 108, 111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068,
|
||||
040, 084, 101, 120, 116, 117, 114, 101, 044, 118, 101, 099, 050, 040, 103, 108, 095, 084, 101, 120,
|
||||
067, 111, 111, 114, 100, 091, 048, 093, 041, 041, 042, 103, 108, 095, 067, 111, 108, 111, 114, 059,
|
||||
125, 010, 158, 137, 116, 152, 114, 087, 034, 194, 190, 191, 004, 241, 045, 226, 015, 222, 146, 050,
|
||||
005, 201, 127, 023, 220, 186, 170, 186, 147, 127, 228, 201, 229, 208, 024, 188, 126, 121, 005, 218,
|
||||
091, 005, 195, 101, 015, 122, 021, 003, 169, 237, 192, 224, 104, 229, 065, 240, 081, 150, 216, 205,
|
||||
237, 050, 203, 242, 163, 253
|
||||
};
|
||||
#endregion //SpriteBatchShader
|
||||
|
||||
|
@ -41,15 +41,16 @@
|
||||
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
|
||||
// particular purpose and non-infringement.
|
||||
|
||||
uniform mat4 MatrixTransform;
|
||||
|
||||
//
|
||||
// Vertex Shader
|
||||
//
|
||||
|
||||
uniform mat4 MatrixTransform;
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
||||
|
||||
##!fragment!##
|
||||
@ -58,52 +59,8 @@ void main(void)
|
||||
// Fragment Shader
|
||||
//
|
||||
|
||||
uniform sampler2D Texture;
|
||||
void main(void)
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
/*
|
||||
Texture2D<float4> Texture : register(t0);
|
||||
sampler TextureSampler : register(s0);
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float4 col : COLOR;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PixelShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 col : COLOR;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
PixelShaderInput SpriteVertexShader( VertexShaderInput input )
|
||||
{
|
||||
PixelShaderInput output = (PixelShaderInput)0;
|
||||
|
||||
output.pos = mul(input.pos, MatrixTransform);
|
||||
output.col = input.col;
|
||||
output.tex = input.tex;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 SpritePixelShader( PixelShaderInput input ) : SV_Target
|
||||
{
|
||||
return Texture.Sample(TextureSampler, input.tex) * input.col;
|
||||
}
|
||||
|
||||
technique10 SpriteTechnique
|
||||
{
|
||||
pass SpriteColorPass
|
||||
{
|
||||
SetGeometryShader( 0 );
|
||||
SetVertexShader( CompileShader( vs_4_0, SpriteVertexShader() ) );
|
||||
SetPixelShader( CompileShader( ps_4_0, SpritePixelShader() ) );
|
||||
}
|
||||
}
|
||||
*/
|
||||
gl_FragColor = texture2D(Texture, vec2(gl_TexCoord[0])) * gl_Color;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user