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

Additional info


Latest Forum posts

 XNA 4.0 conversion
  Posted by: Anonymous
  When: 04/06/2013 at 09:50:05

 XNA Augmented Reality App
  Posted by: Anonymous
  When: 29/05/2013 at 21:20:58

 integer to float conversion
  Posted by: derensendil
  When: 27/05/2013 at 14:56:24

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09


Ads




XNA 3.0 Game Programming Recipes

Riemer Grootjans







Chapter 3: Working with 2D Images/Textures in XNA 3.0 (94 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 3.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.


Google
 
Webwww.riemers.net


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
Translations

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

Microsoft MVP Award



2007 - 2011 MVP Award
DirectX - XNA

Contents

News
Home
Forum
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)
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Team Project (1)
News
Tutorials (160)
XNA 4.0 using C# (89)
2D Series: Shooters (22)
Starting a project
Drawing fullscreen images
Positioning images
SpriteBatch.Draw()
Rotation
Keyboard input
Writing text
Angle to Direction
Direction to Angle
Smoke trail
Manual texture creation
Random terrain
Texture to Colors
Coll Detection Overview
Coll Detection Matrices
Putting CD into practice
Particles
Additive alpha blending
Particle engine
Adding craters
Sound in XNA
Resolution independency
3D Series 1: Terrain (13)
Starting a project
The effect file
The first triangle
World space
Rotation - translation
Indices
Terrain basics
Terrain from file
Keyboard
Adding colors
Lighting basics
Terrain lighting
VertexBuffer & IndexBuffer
3D Series 2: Flightsim (14)
Starting point
Textures
Loading the floorplan
Creating the 3D city
Loading a Model
Ambient and diffuse
Quaternion camera
Flight kinematics
Collision detection
Adding targets
Point sprites
Alpha blending
Skybox
Camera delay
3D Series 3: HLSL (18)
Starting point
HLSL introduction
Vertex format
Vertex shader
Pixel shader
Per-pixel colors
Textured triangle
Triangle strip
World transform
World normals
Per-pixel lighting
Shadow map
Render to texture
Projective texturing
Real shadow
Shaping the light
Preshaders
3D Series 4: Adv. terrain (19)
Starting code
Mouse camera
Textured terrain
Multitexturing
Adding detail
Skydome
The water technique
Refraction map
Reflection map
Perfect mirror
Ripples
The Fresnel term
Moving water
Specular highlights
Billboarding
Region growing
Billboarding renderstates
Perlin noise
Gradient skybox
Short Tuts (3)
Run XNA on older pcs
MessageBox in XNA
Normal generation
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Starting code
Textures
The floorplan
Creating the 3D City
Meshloading from file
Ambient light
Action
Flight kinematics
Collision detection
Skybox
Texture filtering
Adding targets
Point sprites
Alpha blending
DirectSound
Sounds in 3D
Playing MP3 files
Displaying text
Going fullscreen
Series 3: HLSL (19)
Starting point
HLSL Introduction
Vertex Shader
Shaded triangle
Pixel Shader
Textured Triangle
Triangle Strip
World transform
Adding normals
The first light
Shadow mapping
Render To Texture
Projective texturing
The first shadow
Shaping the light
Preshaders
Multiple lights
Adjusting Z values
Finishing touch
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
Series 1: Terrain (15)
Opening a window
Ending the game loop
Linking to the Device
Clearing your window
Drawing a triangle
Culling
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing .bmp files
Adding colors
DirectX Light basics
DirectX using VB (2)
Series 1: Intro (2)
The first triangle
Rotation - translation
-- Tree view --


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!