• Create Account

Sunkah

Member Since 02 Oct 2011
Offline Last Active Sep 24 2012 03:25 PM

Topics I've Started

21 August 2012 - 12:31 PM

Hi, I have some basic questions about quadrender and how things are drawn on the screen, go easy on me, I'm new to XNA . Have a look at the below class:

```internal sealed class QuadRender
{
private VertexPositionTexture[] verts;
private GraphicsDevice myDevice;
private short[] ib = null;
///
///
///
The engine.
{
myDevice = device;
verts = new VertexPositionTexture[]
{
new VertexPositionTexture(
new Vector3(0,0,0),
new Vector2(1,1)),
new VertexPositionTexture(
new Vector3(0,0,0),
new Vector2(0,1)),
new VertexPositionTexture(
new Vector3(0,0,0),
new Vector2(0,0)),
new VertexPositionTexture(
new Vector3(0,0,0),
new Vector2(1,0))
};
ib = new short[] { 0, 1, 2, 2, 3, 0 };
}
///
///
///
The effect.
{
effect.CurrentTechnique.Passes[0].Apply();
}
public void RenderQuad(Vector2 v1, Vector2 v2)
{
verts[0].Position.X = v2.X;
verts[0].Position.Y = v1.Y;
verts[1].Position.X = v1.X;
verts[1].Position.Y = v1.Y;
verts[2].Position.X = v1.X;
verts[2].Position.Y = v2.Y;
verts[3].Position.X = v2.X;
verts[3].Position.Y = v2.Y;
myDevice.DrawUserIndexedPrimitives
(PrimitiveType.TriangleList, verts, 0, 4, ib, 0, 2);
}
}
```

What I'm confused about is the co-ordinate system, what I mean is why does (0,0) represent top left and (1,1) represent bottom right? For example if I have a 800x600 screen, bottom right would be (800, 600), so why is (1,1) used instead. Also why are all the vertices initialized with a Vector3(0,0,0). Whilst I'm here, whats the significance of the other methods present in the class and the ib array?

PARTNERS