Welcome to Project Vanquish!


Welcome to Project Vanquish. The purpose behind this blog is to create a Deferred Rendering engine using XNA with input from you, the reader.  I want the project to be community based so that beginners and experts can put their 2 cents in and help build a stable engine for all to use.

I have done a lot of searching in the past regarding XNA and Deferred Rendering.  I did find another tutorial over on The Cansin’s website, but this already had a few features implemented which I feel would be nice to implement ourselves so we can all learn something new.  The example that crops up the most is Catalin Zima’s tutorial, but this was for an earlier version of the XNA Game Studio.  However, Roy Triesschejin converted this version to XNA 4 and I believe this is a great starting point for this project.  Download the source code and open it up to get an idea of how the project is structured.  This demo doesn’t really have any scene management or model management, but this is where you come in.

Having Roy’s source code open, I fired up a new instance of Visual Studio and created a new “Windows Game (4.0)” project called “ProjectVanquishTest”.

Project Vanquish Test

Once the project was created, I then added a new Project to the solution.  This time I chose the project type, “Windows Game Library (4.0)” and named it “ProjectVanquish”.  This is the project that we are going to build upon.  Once this project is created, add a “Content Reference” to the “ProjectVanquishTestContent”.  You’re solution should look something like this (keeping in mind that you can rename the projects to whatever you fancy):

New Project Vanquish solution

The next thing to do is to remove the “Class1.cs” file from the “ProjectVanquish” project.  Now we need to add a Reference to the new class library in the “ProjectVanquishTest” directory.  So, right mouse click “ProjectVanquishTest” project and click “Add Reference”.  The following window should open up, with the appropriate project highlighted:

Click OK and let’s save the solution before we continue to create a solution outline.

Create the following 3 folders:

And then add a new class, called “DeferredRenderer”, to the “Renderers” folder and make it public. 

public class DeferredRenderer
{
}

We need to add 2 new namespaces to the class in order to be able to use the XNA libraries.  Add the following to your using directives at the top of the class:

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

Let’s add a constructor to the class:

public DeferredRenderer(GraphicsDevice device, ContentManager content)
{
}

So, our constructor has been defined and it accepts two arguments, GraphicsDevice and ContentManager.  We shall continue creating a skeleton class so that we can implement the class in the Game1 class of the “ProjectVanquishTest” project.

Create the following methods:

public void Draw(GameTime gameTime)
{
}

public void Update(GameTime gameTime)
{
}

Build the solution.  You shouldn’t have any errors at this point.  Now, open up the “Game1.cs” file in the “ProjectVanquishTest” project.  Firstly, we will add the namespace to the using directives at the top of the file.

using ProjectVanquish.Renderers;

Now that we have this, we can start to use the “DeferredRenderer” class.  Add a new variable:

DeferredRenderer renderer;

Now,we need to instantiate this object.  To do this, in the “Initialize” method, add the following under the TODO comment:

renderer = new DeferredRenderer(GraphicsDevice, Content);

Let’s build the solution.  We should have no errors.  If you run the application you’ll see a Cornflower Blue window.  This is because we’ve not yet implemented our Update and Draw methods, so let’s do that.  Add the following code to the Draw and Update methods, under the TODO comments again:

renderer.Draw(gameTime);

renderer.Update(gameTime);

Build the solution again, and you shouldn’t get any errors.  Again, running the application we will still have the Cornflower Blue window, but this time we are calling our new Draw and Update methods so this will change in the next part.

In the next part, we’ll start to look at Roy’s code and migrate the useful parts into our new project.

Advertisements

2 comments on “Welcome to Project Vanquish!

  1. Pingback: The next steps… | Project Vanquish

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s