Working line shader

This commit is contained in:
Paul Chote
2010-11-11 12:11:11 +13:00
parent 888710cbc5
commit 00358e9fe8
3 changed files with 7 additions and 17 deletions

View File

@@ -20,12 +20,8 @@ namespace OpenRA.Renderer.Glsl
public class Shader : IShader public class Shader : IShader
{ {
int program; int program;
string type;
public Shader(GraphicsDevice dev, string type) public Shader(GraphicsDevice dev, string type)
{ {
this.type = type;
Console.WriteLine("Loading shader: {0}",type);
// Vertex shader // Vertex shader
string vertexCode; string vertexCode;
using (var file = new StreamReader(FileSystem.Open("glsl{0}{1}.vert".F(Path.DirectorySeparatorChar, type)))) using (var file = new StreamReader(FileSystem.Open("glsl{0}{1}.vert".F(Path.DirectorySeparatorChar, type))))
@@ -65,6 +61,7 @@ namespace OpenRA.Renderer.Glsl
Gl.glGetProgramInfoLog(program,4024,l,log); Gl.glGetProgramInfoLog(program,4024,l,log);
Console.WriteLine(log.ToString()); Console.WriteLine(log.ToString());
GraphicsDevice.CheckGlError(); GraphicsDevice.CheckGlError();
} }
@@ -84,14 +81,10 @@ namespace OpenRA.Renderer.Glsl
int param = Gl.glGetUniformLocation(program, name); int param = Gl.glGetUniformLocation(program, name);
GraphicsDevice.CheckGlError(); GraphicsDevice.CheckGlError();
if (texture != null && param >= 0) if (texture != null && param >= 0)
{ {
//texture.texture = 0;
Console.WriteLine("setting {0}:{1} to {2}",type,name,texture.texture);
Gl.glUniform1i(param, texture.texture); Gl.glUniform1i(param, texture.texture);
GraphicsDevice.CheckGlError(); GraphicsDevice.CheckGlError();
} }
} }
@@ -99,7 +92,6 @@ namespace OpenRA.Renderer.Glsl
{ {
Gl.glUseProgram(program); Gl.glUseProgram(program);
GraphicsDevice.CheckGlError(); GraphicsDevice.CheckGlError();
//Console.WriteLine("setting {3}:{0} to ({1},{2})",name,x,y,type);
int param = Gl.glGetUniformLocation(program, name); int param = Gl.glGetUniformLocation(program, name);
GraphicsDevice.CheckGlError(); GraphicsDevice.CheckGlError();
Gl.glUniform2f(param,x,y); Gl.glUniform2f(param,x,y);

View File

@@ -1,6 +1,4 @@
uniform sampler2D DiffuseTexture;
void main() void main()
{ {
gl_FragColor = texture2D(DiffuseTexture,gl_TexCoord[0].st); gl_FragColor = gl_Color;
} }

View File

@@ -1,8 +1,8 @@
uniform vec2 Scroll; uniform vec2 Scroll;
uniform vec2 r1; uniform vec2 r1, r2; // matrix elements
uniform vec2 r2; // matrix elements
void main() void main()
{ {
gl_Position = ftransform(); vec2 p = (gl_Vertex.xy - Scroll.xy)*r1 + r2;
gl_Position = vec4(p.x,p.y,0,1);
gl_FrontColor = gl_MultiTexCoord0;
} }