XNA for C#
DirectX 9 for C#
DirectX 9 for C++
DirectX 9 for VB
My XNA Book
       Go to section on this site

Additional info

Latest Forum posts

 Account settings
  Posted by: Anonymous
  When: 07/05/2014 at 09:48:39

 forced subtitle
  Posted by: Applefly
  When: 07/05/2014 at 06:00:48

 convert DVD into PMS
  Posted by: Applefly
  When: 07/05/2014 at 05:55:25

 DVD to Digital Copy easily
  Posted by: VIKIVannessa
  When: 05/05/2014 at 06:52:29

 DVD on Xbox 360/Xbox One Console
  Posted by: VIKIVannessa
  When: 05/05/2014 at 06:51:47

 Extract .Srt Subtitles
  Posted by: Applefly
  When: 04/05/2014 at 03:54:38

 Encode Movie collection
  Posted by: Applefly
  When: 04/05/2014 at 03:52:41

 Convert DVD to WMV
  Posted by: Applefly
  When: 29/04/2014 at 05:53:50

 rip DVDs into digital files
  Posted by: Applefly
  When: 29/04/2014 at 05:51:20

 iTunes movies/music to Kindle Fire
  Posted by: ciciyu80
  When: 29/04/2014 at 05:10:20


XNA 2.0 Game Programming Recipes

Riemer Grootjans

Chapter 3: Working with 2D Images/Textures in XNA 2.0 (102 pages)

Whether your game will be 2D or 3D, it will definitely use a vast amount of images. Where 2D games need a whole set of canvas and character images, 3D games use images to cover the triangles that make up their 3D objects.

There are many other cases where you’ll need images while creating a game. Presenting the user with a nice-looking menu interface and saving a screenshot to disk are just some examples. Special 2D images can be required as input to very advanced effects.

This chapter covers how to load, create, show, and manipulate images in XNA. The first recipes are aimed at 2D games because they mainly focus on rendering 2D images to the screen. You’ll also find two recipes that introduce you to the content pipeline, a major component of the XNA Framework. The more advanced recipes show some uses of 2D images in a 3D
game world, supported by HLSL code fragments.

3-1. Display 2D Images: Load and Render Images Using the SpriteBatch Class
This beginner recipe shows how you can easily use XNA’s SpriteBatch to render 2D images to the screen using hardware acceleration.

3-1. Rotate, Scale, and Mirror an Image
Exploring some of the more complex overloads of the SpriteBatch.Draw method, this recipe shows how you can rotate, scale and/or mirror an image before rendering it to the screen.

3-3. Render Transparent Images Using Layers
XNA’s SpriteBatch class supports rendering 2D images to multiple layers, a requirement for creating rich 2D games. This recipe shows you how you can maintain full control when blending multiple 2D images over each other.

3-4. Consider Performance When Using the SpriteBatch Class
This recipe discusses some performance rules you have to keep in mind when creating large 2D applications in XNA.

3-5. Display Text
As simple as it sounds, XNA’s SpriteBatch can also be used to render text to the screen using SpriteFont objects.

3-6. Create a 2D Menu Interface
This recipe discusses from start to finish the steps involved in creating a complete 2D Menu for your game. This includes smooth transitioning from one menu to another, as well as post-processing effects.

3-7. Create a Texture, Define the Color of Each Pixel,
Save a Texture to a File
XNA has made it very easy to define and save an image by means of the Texture2D class.

3-8. Render the Scene into a Texture
This recipe discusses two ways to hijack the content of the video output and save it into a Texture2D object. Pitfalls such as different aspect ratios between the multiple render targets are explained in detail.

3-9. Extend the Image Content Processor
This recipe introduces you to XNA’s Content Pipeline. In this easy recipe, you’ll learn how to manipulate the color content of an image during compile time.

3-10. Extend the Image Content Processor: Grayscale Conversion and Processor Parameters
Extending on the previous recipe, this recipe shows how you can make your Content Processors more flexibly using a feature introduced in XNA 2.0.

3-11. Make Your Scene More Impressive with Billboarding: Render 2D Images in a 3D World So They Always Face the Camera
Billboarding is one of the most powerful and most used techniques used in 3D games. Therefore, it is discussed in a lot of detail and in all possible flavours, shown both for CPU and GPU. Billboarding renders 2D images in a 3D world, so they are always facing the camera. On larger distances, this e.g. allows you to create a convincing forest in your 3D world using only 2D images.

3-12. Create a 3D Explosion Effect/Simple Particle System
Using the billboarding technique created in the previous recipe, this recipe introduces you to HLSL particle systems. As an example, you learn how to invoke a full-blown 3D explosion at a 3D location of your choice.

3-13. Create a Mirror: Projective Texturing
Creating a mirror requires some mathematical steps, but the results can be convincing. This recipes helps you through the difficult parts.

Recipe 3-12: HLSL Particle effect making extensive use of Billboarding to create a 3D explosion.


If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !

- Website design & XNA + DirectX code : Riemer Grootjans -
©2003 - 2011 Riemer Grootjans

This site in English
This site in Korean
This site in Czech

Microsoft MVP Award

2007 - 2011 MVP Award
DirectX - XNA


XNA 2.0 Recipes Book (8)
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
XNA 3.0 Recipes Book (8)
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
-- Expand all --

Thank you!

Support this site --
any amount is welcome !

Stay up-to-date

I don't have the time to keep a News section, so stay informed about the updates by clicking on this RSS file!