namespace TestA{
public struct Vertex{
public float m_x { get; set; }
public float m_y { get; set; }
public float m_z { get; set; }
public float m_u { get; set; }
public float m_v { get; set; }
public void SetPosition(float x, float y, float z){
m_x=x;
m_y=y;
m_z=z;
return;
}
public void SetTexCoord(float u, float v){
m_u=u;
m_v=v;
return;
}
public void Set(float x, float y, float z, float u, float v){
m_x = x; m_y = y; m_z = z; m_u = u; m_v = v;
return;
}
}
public class AppMain{
public static void Main (string[] args){
GraphicsContext Graphics = new GraphicsContext();
Graphics.SetClearColor(1.0f,0.0f,0.0f,0);
ShaderProgram SP = new ShaderProgram("/Application/shaders/Texture.cgx");
Font fnt = new Font(FontAlias.System, 12, FontStyle.Regular);
FontMap FMap = new FontMap(fnt);
GamePadData Pad;
float Width=Tex.Width;
float Height=Tex.Height;
Vertex[] v = new Vertex[6];
v[0].Set(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
v[1].Set(Tex.Width, 0.0f, 0.0f, 1.0f, 0.0f);
v[2].Set(0.0f, Tex.Height, 0.0f, 0.0f, 1.0f);
v[3].Set(Tex.Width, 0.0f, 0.0f, 1.0f, 0.0f);
v[4].Set(Tex.Width, Tex.Height, 0.0f, 1.0f, 1.0f);
v[5].Set(0.0f, Tex.Height, 0.0f, 0.0f, 1.0f);
VertexBuffer vb = new VertexBuffer(6, VertexFormat.Float3, VertexFormat.Float2);
vb.SetVertices(0, v, 0, 20); //sizeof in c# was giving me errors
vb.SetVertices(1, v,12, 20); //sizeof in c# was giving me errors
Matrix4 Proj = Matrix4.Ortho(0.0f, Graphics.Screen.Width, Graphics.Screen.Height, 0.0f, 0.0f, 1.0f);
Matrix4 View = Matrix4.Translation(20.0f, 20.0f, 0.0f);
Graphics.SetVertexBuffer(0, vb);
Graphics.SetShaderProgram(SP);
Graphics.SetTexture(0, Tex);
SP.SetUniformValue(SP.FindUniform("ProjMat"), ref Proj);
float xS=0.0f;
float yS=0.0f;
while (true) {
SystemEvents.CheckEvents ();
Pad = GamePad.GetData(0);
xS=0.0f;
yS=0.0f;
if((Pad.Buttons&GamePadButtons.Square)!=0) xS=-1.0f;
else if((Pad.Buttons&GamePadButtons.Circle)!=0) xS=1.0f;
if((Pad.Buttons&GamePadButtons.Cross)!=0) yS=1.0f;
else if((Pad.Buttons&GamePadButtons.Triangle)!=0) yS=-1.0f;
View*=Matrix4.Translation(xS, yS, 0.0f);
SP.SetUniformValue(SP.FindUniform("ViewMat"), ref View);
Graphics.Clear();
Graphics.DrawArrays(DrawMode.Triangles, 0, 6);
Graphics.SwapBuffers();
if((Pad.Buttons&GamePadButtons.Start)!=0) break;
}
vb.Dispose();
SP.Dispose();
Graphics.Dispose();
}
}
}