• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Sundeepkahlon

XNA Quadrender question

4 posts in this topic

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:

[CODE]
internal sealed class QuadRender
{
private VertexPositionTexture[] verts;
private GraphicsDevice myDevice;
private short[] ib = null;
///
/// Loads the quad.
///
///
The engine.
public QuadRender(GraphicsDevice device)
{
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 };
}
///
/// Draws the fullscreen quad.
///
///
The effect.
public void RenderFullScreenQuad(Effect effect)
{
effect.CurrentTechnique.Passes[0].Apply();
RenderQuad(Vector2.One * -1, Vector2.One);
}
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);
}
}
[/CODE]

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?
0

Share this post


Link to post
Share on other sites
what your are displaying with the quad is a texture that comes from a texture2d variable. Normally as a render target or such.

What you are giving are the texture coordinates that go from 0,0 to 1,1. It will match the texture image to a quad that fits all screen.
0

Share this post


Link to post
Share on other sites
[quote name='winsrp' timestamp='1345581412' post='4971970']
what your are displaying with the quad is a texture that comes from a texture2d variable. Normally as a render target or such.

What you are giving are the texture coordinates that go from 0,0 to 1,1. It will match the texture image to a quad that fits all screen.
[/quote]

I'm more or less asking for an explanation for the class, I haven't used it yet. Edited by Sunkah
0

Share this post


Link to post
Share on other sites
[quote name='Sunkah' timestamp='1345573887' post='4971919']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?
[/quote]

The Vector2 structures of (0,0) and (1,1) actually refer to the texture coordinates, and the Vector3 structures refer the coordinate positions. The VertexPositionTexture structure consists of Vector3 for the position and a Vector2 for the texture, in addition to a VertexDeclaration class that defines the vertex info.

The constructor for this QuadRender class sets all the vertices at the origin as a default, so if it were not for the parameters passed in Draw() to reposition the vertices, it would be as if there was no quad visible at all.
0

Share this post


Link to post
Share on other sites
What you failed to mention is where this came from: [url="http://code.google.com/p/port-ploobsengine/"]PloobsEngine[/url]. (For reference if anyone else wants to help further)
Do note as well that they have a link to their own tutorials on the front page of that project, if you need extra resources.

[quote name='Sunkah' timestamp='1345991690' post='4973477']
I'm more or less asking for an explanation for the class, I haven't used it yet.
[/quote]
Since it's already been coded for you, all you [i]really[/i] need to know about it is how it's used: drawing a quad to the screen (useful for deferred rendering techniques, as well as sprite/font drawing, though since XNA already has classes for that I'll assume its intent is the former). If you're trying to learn from the codebase, here's some more info:

The ib array is an index array (ib probably referring to "index buffer"). That's a necessary piece of information for the DrawIndexedPrimitive and DrawUserIndexedPrimitive calls, as it tells the DirectX pipeline which vertices in the vertex buffer correspond to which triangles, and lets you re-use vertices (as otherwise this draw call would need 6 verts to comprise the 2 triangles). The ib array itself { 0, 1, 2, 2, 3, 0 } says the first tri will use verts from the vertex array at indices 0, 1, and 2; and the second will use verts at indices 2, 3, and 0.

(0,0) to (1,1) is uv coordinate space (for texture coordinates) which is always normalized across any-sized texture, so (.5, .5) would always refer to the point right at the middle of the image you're sampling.

RenderFullScreenQuad calls the more arbitrary RenderQuad with specific vector values that make it span the full viewport space (which has normalized coordinates from (-1, -1) to (1,1) being the top left and bottom right corners respectively).
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0