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

 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


Ads

Texture filtering

Last chapter we’ve drawn the skybox. You’ll notice immediately the blocked nature of our skybox. This is because DirectX has to stretch the small image, loaded from screen, to fill our whole screen, so the pixels of the image become real blocks. You could already have observed this effect when flying close to a tower building, where the pixels are stretched vertically. Luckily, DirectX has several built-in function that smooth out these effects.

There’s yet another problem, when you look at the image of the final chapter: you can easily see the texture images are pasted on a cube. You can simply see the corners! That’s of course not allowable. This chapter we’ll solve this problem as well.

To solve the blocking artifacts, you can simply put these lines under your device creating:
 device.SamplerState[0].MinFilter = TextureFilter.Anisotropic;
 device.SamplerState[0].MagFilter = TextureFilter.Anisotropic

Setting the minification and mignification filters to anything but None will interpolate the pixel colors. To better understand the interpolation process, have a look at the picture below, where I have illustrated linear interpolation:



The left part illustrates 2 pixels from a small texture image. Suppose this texture would have to be pasted on a huge triangle. This would mean every pixel would have to be enlarged. Simply enlarging the pixels would give a result illustrated by the left part of the image above. You can clearly see the separation between both pixels, and as such the pixels are displayed as blocks.

When you use the Linear texture filter, DirectX will enlarge the image texture, and smooth the transition between both images. This way most of the blocking effect will have disappeared.

The Anisotropic filter also corrects an additional viewing abberation, while the GaussianQuad filter is a natural averaging filter, which causes a natural blurr. Usually, the Anisotropic filter is used, if your graphics card supports it. If this is not the case, DirectX default to the Linear texture filter.

Try running the code and see the improvements!

Another problem are the edges of our skybox. A first major reason that can cause edges between neighbouring textures become visible, is the size of your texture. The vertical and horizontal sizes of your texture image always have to be a power of 2. Always. If not, the edges will become visible. The size of the city texture is not a power of 2, which causes the edges to be slightly visible. You can try improving this by scaling the image to a power of 2.

The sizes of the skybox images are a power of 2, which brings us to the second possible cause, which will especially be noticeable with a linear texture filter turned on, as in our case. What happens? Imagine a pixel in the outer right column of a skybox image. For example, take the right pixel of the image above. The pixel will be hugely enlarged, and because of linear filtering, the left part of the pixel will be faded to the color of the left pixel. Because there is no pixel to the right of our pixel, the right side of our pixel will keep the original color! This is what creates the rim we see in the corners of our skybox.

Luckily, DirectX has another solution for this. We can make set the TextureAdress to Mirror, which means the the outer left pixel will be taken as a right pixel for our pixel of interest. This way there doesn’t remain a rim of a constant color. So put these lines under your device creation:

 device.SamplerState[0].AddressU = TextureAddress.Mirror;
 device.SamplerState[0].AddressV = TextureAddress.Mirror;

Remember the U,V coordinates are simply the 2D coordinates of the image space, meaning this mode will be set for both horizontal as vertical edges.

Compare the image of last chapter to this image:




DirectX Tutorial 11 - Texture filtering

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



Click here to go to the forum on this chapter!

Or click on one of the topics on this chapter to go there:
  • Level of detail
          Hi Riemer, How do you maintain the same level o...
  • spreading textures
          Hi Riemer, How do I spread a texture bitmap ove...
  • Something worry with resource?
           if ((materialarray[i].TextureFilename != ...



    A lot of text for four simple lines.. Well I guess you know the meaning behind them now :) Next chapter we’ll be adding the targets.

     using System;
     using System.Drawing;
     using System.Collections;
     using System.ComponentModel;
     using System.Windows.Forms;
     using System.Data;
     using Microsoft.DirectX;
     using Microsoft.DirectX.Direct3D;
     using D3D = Microsoft.DirectX.Direct3D;
     using Microsoft.DirectX.DirectInput;
     using DI = Microsoft.DirectX.DirectInput;
     
     namespace DirectX_Tutorial
     {
         public class WinForm : System.Windows.Forms.Form
         {
             private int[,] int_Floorplan;
             private int WIDTH;
             private int HEIGHT;
             private int differentbuildings = 5;
             private float gamespeed = 0.02f;
             private int[] buildingheights = new int[] { 0, 10, 1, 3, 2, 5 };
     
             private System.ComponentModel.Container components = null;
             private D3D.Device device;
             private Texture scenerytexture;
             private Material material;
             private CustomVertex.PositionNormalTextured[] verticesarray;
             ArrayList verticeslist = new ArrayList();
             private Mesh spacemesh;
             private Material[] spacemeshmaterials;
             private Texture[] spacemeshtextures;
             private float spacemeshradius;
             private float scaling = 0.0005f;
             private Vector3 spacemeshposition = new Vector3(5, 5, 1);
             private Vector3 spacemeshangles = new Vector3(0, -0.5f, (float)Math.PI/4);
             private DI.Device keyb;
             private double score = 0;
             private Mesh skyboxmesh;
             private Material[] skyboxmaterials;
             private Texture[] skyboxtextures;
     
             public WinForm()
             {
                 InitializeComponent();
                 this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
             }
     
             public void InitializeDevice()
             {
                 PresentParameters presentParams = new PresentParameters();
                 presentParams.Windowed = true;
                 presentParams.SwapEffect = SwapEffect.Discard;
                 presentParams.AutoDepthStencilFormat = DepthFormat.D16;
                 presentParams.EnableAutoDepthStencil = true;
                 device = new D3D.Device(0, D3D.DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
     
                 device.RenderState.Lighting = true;
     
                 device.Lights[0].Type = LightType.Directional;
                 device.Lights[0].Diffuse = Color.White;
                 device.Lights[0].Direction = new Vector3(1, 1, -1);
                 device.Lights[0].Update();
                 device.Lights[0].Enabled = true;
     
                 device.Lights[1].Type = LightType.Directional;
                 device.Lights[1].Diffuse = Color.White;
                 device.Lights[1].Direction = new Vector3(-1, -1, -1);
                 device.Lights[1].Update();
                 device.Lights[1].Enabled = true;
     
                 device.SamplerState[0].MinFilter = TextureFilter.Anisotropic;
                 device.SamplerState[0].MagFilter = TextureFilter.Anisotropic;
     
                 device.SamplerState[0].AddressU = TextureAddress.Mirror;
                 device.SamplerState[0].AddressV = TextureAddress.Mirror;
             }
     
             protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
             {
                 ReadUserInput(gamespeed);
                 UpdatePosition(ref spacemeshposition, spacemeshangles, gamespeed);
                 if (CheckCollision(spacemeshposition, spacemeshradius) > 0)
                 {                
                     spacemeshposition = new Vector3(8, 2, 1);
                     spacemeshangles = new Vector3(0, 0, 0);
                     gamespeed /= 1.1f;
                     score /= 2;                
                 }
     
                 device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkSlateBlue, 1.0f, 0);
                 device.BeginScene();
     
                 device.RenderState.Ambient = Color.DarkGray;
                 device.Transform.World = Matrix.Translation(-(float)spacemeshposition.X, -(float)spacemeshposition.Y, -(float)spacemeshposition.Z) * Matrix.RotationYawPitchRoll((float)spacemeshangles.X, (float)spacemeshangles.Y, (float)spacemeshangles.Z);            
                 device.VertexFormat = CustomVertex.PositionNormalTextured.Format;
     
                 device.SetTexture(0, scenerytexture);
                 device.DrawUserPrimitives(PrimitiveType.TriangleList, verticeslist.Count / 3, verticesarray);
     
                 device.Transform.World = Matrix.Scaling(scaling, scaling, scaling) * Matrix.RotationX((float)Math.PI / 2);
                 DrawMesh(spacemesh, spacemeshmaterials, spacemeshtextures);
     
                 device.RenderState.Ambient = Color.White;
                 device.Transform.World = Matrix.RotationX((float)Math.PI/2) *Matrix.RotationYawPitchRoll((float)spacemeshangles.X, (float)spacemeshangles.Y, (float)spacemeshangles.Z);
                 DrawMesh(skyboxmesh, skyboxmaterials, skyboxtextures);
     
                 device.EndScene();
                 device.Present();
                 this.Invalidate();            
             }
     
             private void SetUpCamera()
             {
                 device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, (float)this.Width / (float)this.Height, 0.3f, 500f);
                 device.Transform.View = Matrix.LookAtLH(new Vector3(0, -1f, 0.2f), new Vector3(0, 0, 0), new Vector3(0, 0, 1));
             }        
     
             private void LoadTexturesAndMaterials()
             {
                 material = new Material();
     
                 material.Diffuse = Color.White;
                 material.Ambient = Color.White;
     
                 device.Material = material;
     
                 scenerytexture = TextureLoader.FromFile(device, "texturemap.jpg");
             }
     
             private void LoadFloorplan()
             {
                 WIDTH = 20;
                 HEIGHT = 15;
     
                 int_Floorplan = new int[,]
                 {
                     {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                     {1,0,0,1,1,0,0,0,1,1,0,0,1,0,1},
                     {1,0,0,1,1,0,0,0,1,0,0,0,1,0,1},
                     {1,0,0,0,1,1,0,1,1,0,0,0,0,0,1},
                     {1,0,0,0,0,0,0,0,0,0,0,1,0,0,1},
                     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                     {1,0,1,1,0,0,0,1,0,0,0,0,0,0,1},
                     {1,0,1,0,0,0,0,0,0,0,0,0,0,0,1},
                     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                     {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                     {1,0,0,0,0,1,0,0,0,0,0,0,0,0,1},
                     {1,0,0,0,0,1,0,0,0,1,0,0,0,0,1},
                     {1,0,1,0,0,0,0,0,0,1,0,0,0,0,1},
                     {1,0,1,1,0,0,0,0,1,1,0,0,0,1,1},
                     {1,0,0,0,0,0,0,0,1,1,0,0,0,1,1},
                     {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                 };        
     
                 Random random = new Random();
                 for (int x = 0; x < WIDTH; x++)
                 {
                     for (int y = 0; y < HEIGHT; y++)
                     {
                         if (int_Floorplan[x, y] == 1)
                         {
                             int_Floorplan[x, y] = random.Next(differentbuildings) + 1;
                         }
                     }
                 }
             }
     
             private void LoadMesh(string filename, ref Mesh mesh, ref Material[] meshmaterials, ref Texture[] meshtextures, ref float meshradius)
             {
                 ExtendedMaterial[] materialarray;
                 mesh = Mesh.FromFile(filename, MeshFlags.Managed, device, out materialarray);
     
                 if ((materialarray != null) && (materialarray.Length > 0))
                 {
                     meshmaterials = new Material[materialarray.Length];
                     meshtextures = new Texture[materialarray.Length];
     
                     for (int i = 0; i < materialarray.Length; i++)
                     {
                         meshmaterials[i] = materialarray[i].Material3D;
                         meshmaterials[i].Ambient = meshmaterials[i].Diffuse;
     
                         if ((materialarray[i].TextureFilename != null) && (materialarray[i].TextureFilename != string.Empty))
                         {
                             meshtextures[i] = TextureLoader.FromFile(device, materialarray[i].TextureFilename);
                         }
                     }                
                 }
     
                 mesh = mesh.Clone(mesh.Options.Value, CustomVertex.PositionNormalTextured.Format, device);
                 mesh.ComputeNormals();
     
                 VertexBuffer vertices = mesh.VertexBuffer;
                 GraphicsStream stream = vertices.Lock(0, 0, LockFlags.None);
                 Vector3 meshcenter;
                 meshradius = Geometry.ComputeBoundingSphere(stream, mesh.NumberVertices, mesh.VertexFormat, out meshcenter) * scaling;
             }
     
             private void LoadMeshes()
             {
                 float dummy = 0;
                 LoadMesh("xwing.x", ref spacemesh, ref spacemeshmaterials, ref spacemeshtextures, ref spacemeshradius);
                 LoadMesh("skybox2.x", ref skyboxmesh, ref skyboxmaterials, ref skyboxtextures, ref dummy);
             }        
             private void DrawMesh(Mesh mesh, Material[] meshmaterials, Texture[] meshtextures)
             {
                 for (int i = 0; i < meshmaterials.Length; i++)
                 {
                     device.Material = meshmaterials[i];
                     device.SetTexture(0, meshtextures[i]);
                     mesh.DrawSubset(i);
                 }
             }
     
             private void UpdatePosition(ref Vector3 position, Vector3 angles, float speed)
             {
                 Vector3 addvector = new Vector3();
                 addvector.X += (float)(Math.Sin(angles.Z));
                 addvector.Y += (float)(Math.Cos(angles.Z));
                 addvector.Z -= (float)(Math.Tan(angles.Y));
                 addvector.Normalize();
     
                 position += addvector * speed;
             }
     
             private void InitializeInputDevices()
             {
                 keyb = new DI.Device(SystemGuid.Keyboard);
                 keyb.SetCooperativeLevel(this, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
                 keyb.Acquire();
             }
     
             private void ReadUserInput(float speed)
             {
                 KeyboardState keys = keyb.GetCurrentKeyboardState();
     
                 if (keys[Key.Right])
                 {
                     spacemeshangles.X += 2.5f * speed;
                 }
                 if (keys[Key.Left])
                 {
                     spacemeshangles.X -= 2.5f * speed;
                 }
     
                 if (keys[Key.Down])
                 {
                     spacemeshangles.Z -= (float)(speed * Math.Sin(spacemeshangles.X));
                     spacemeshangles.Y -= (float)(speed * Math.Cos(spacemeshangles.X));
                 }
                 if (keys[Key.Up])
                 {
                     spacemeshangles.Z += (float)(speed * Math.Sin(spacemeshangles.X));
                     spacemeshangles.Y += (float)(speed * Math.Cos(spacemeshangles.X));
                 }            
             }
     
             private int CheckCollision(Vector3 position, float radius)
             {            
                 if (position.Z - radius < 0) return 1;
                 if (position.Z + radius > 15) return 2;
     
                 if ((position.X < -10) || (position.X > WIDTH+10)) return 2;
                 if ((position.Y < -10) || (position.Y > HEIGHT+10)) return 2;
                 
                 if ((position.X - radius > 0) && (position.X + radius < WIDTH) && (position.Y - radius> 0) && (position.Y + radius < HEIGHT))
                 {
                     if (position.Z - radius < buildingheights[int_Floorplan[(int)position.X, (int)position.Y]]) return 1;
                 }
                 
                 return 0;
             }
     
             private void VertexDeclaration()
             {
                 float imagesintexture = 1 + differentbuildings * 2;
     
                 for (int x = 0; x < WIDTH; x++)
                 {
                     for (int y = 0; y < HEIGHT; y++)
                     {
                         int currentbuilding = int_Floorplan[x, y];
                         verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, buildingheights[currentbuilding]), new Vector3(0, 0, 1), (currentbuilding * 2 + 1) / imagesintexture, 1));
                         verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y, buildingheights[currentbuilding]), new Vector3(0, 0, 1), currentbuilding * 2 / imagesintexture, 1));
                         verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y + 1, buildingheights[currentbuilding]), new Vector3(0, 0, 1), currentbuilding * 2 / imagesintexture, 0));
     
                         verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y + 1, buildingheights[currentbuilding]), new Vector3(0, 0, 1), currentbuilding * 2 / imagesintexture, 0));
                         verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y + 1, buildingheights[currentbuilding]), new Vector3(0, 0, 1), (currentbuilding * 2 + 1) / imagesintexture, 0));
                         verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, buildingheights[currentbuilding]), new Vector3(0, 0, 1), (currentbuilding * 2 + 1) / imagesintexture, 1));
     
                         if (y > 0)
                         {
                             if (int_Floorplan[x, y - 1] != int_Floorplan[x, y])
                             {
                                 if (int_Floorplan[x, y - 1] > 0)
                                 {
                                     currentbuilding = int_Floorplan[x, y - 1];
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, 0f), new Vector3(0, 1, 0), (currentbuilding * 2 - 1) / imagesintexture, 1));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y, buildingheights[currentbuilding]), new Vector3(0, 1, 0), currentbuilding * 2 / imagesintexture, 0));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y, 0f), new Vector3(0, 1, 0), currentbuilding * 2 / imagesintexture, 1));
     
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y, buildingheights[currentbuilding]), new Vector3(0, 1, 0), currentbuilding * 2 / imagesintexture, 0));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, 0f), new Vector3(0, 1, 0), (currentbuilding * 2 - 1) / imagesintexture, 1));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, buildingheights[currentbuilding]), new Vector3(0, 1, 0), (currentbuilding * 2 - 1) / imagesintexture, 0));
     
                                 }
                                 if (int_Floorplan[x, y] > 0)
                                 {
                                     currentbuilding = int_Floorplan[x, y];
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, 0f), new Vector3(0, -1, 0), currentbuilding * 2 / imagesintexture, 1));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y, 0f), new Vector3(0, -1, 0), (currentbuilding * 2 - 1) / imagesintexture, 1));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y, buildingheights[currentbuilding]), new Vector3(0, -1, 0), (currentbuilding * 2 - 1) / imagesintexture, 0));
     
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, 0f), new Vector3(0, -1, 0), currentbuilding * 2 / imagesintexture, 1));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x + 1, y, buildingheights[currentbuilding]), new Vector3(0, -1, 0), (currentbuilding * 2 - 1) / imagesintexture, 0));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, buildingheights[currentbuilding]), new Vector3(0, -1, 0), currentbuilding * 2 / imagesintexture, 0));
                                 }
     
                             }
                         }
     
                         if (x > 0)
                         {
                             if (int_Floorplan[x - 1, y] != int_Floorplan[x, y])
                             {
                                 if (int_Floorplan[x - 1, y] > 0)
                                 {
                                     currentbuilding = int_Floorplan[x - 1, y];
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, 0f), new Vector3(1, 0, 0), currentbuilding * 2 / imagesintexture, 1));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y + 1, 0f), new Vector3(1, 0, 0), (currentbuilding * 2 - 1) / imagesintexture, 1));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y + 1, buildingheights[currentbuilding]), new Vector3(1, 0, 0), (currentbuilding * 2 - 1) / imagesintexture, 0));
     
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y + 1, buildingheights[currentbuilding]), new Vector3(1, 0, 0), (currentbuilding * 2 - 1) / imagesintexture, 0));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, buildingheights[currentbuilding]), new Vector3(1, 0, 0), currentbuilding * 2 / imagesintexture, 0));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, 0f), new Vector3(1, 0, 0), currentbuilding * 2 / imagesintexture, 1));
                                 }
                                 if (int_Floorplan[x, y] > 0)
                                 {
                                     currentbuilding = int_Floorplan[x, y];
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, 0f), new Vector3(-1, 0, 0), (currentbuilding * 2 - 1) / imagesintexture, 1));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, buildingheights[currentbuilding]), new Vector3(-1, 0, 0), (currentbuilding * 2 - 1) / imagesintexture, 0));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y + 1, 0f), new Vector3(-1, 0, 0), currentbuilding * 2 / imagesintexture, 1));
     
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y, buildingheights[currentbuilding]), new Vector3(-1, 0, 0), (currentbuilding * 2 - 1) / imagesintexture, 0));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y + 1, buildingheights[currentbuilding]), new Vector3(-1, 0, 0), currentbuilding * 2 / imagesintexture, 0));
                                     verticeslist.Add(new CustomVertex.PositionNormalTextured(new Vector3(x, y + 1, 0f), new Vector3(-1, 0, 0), currentbuilding * 2 / imagesintexture, 1));
                                 }
                             }
                         }
                     }
                 }
                 verticesarray = (CustomVertex.PositionNormalTextured[])verticeslist.ToArray(typeof(CustomVertex.PositionNormalTextured));
             }
     
             protected override void Dispose(bool disposing)
             {
                 if (disposing)
                 {
                     if (components != null)
                     {
                         components.Dispose();
                     }
                 }
                 base.Dispose(disposing);
             }
     
             private void InitializeComponent()
             {
                 this.components = new System.ComponentModel.Container();
                 this.Size = new System.Drawing.Size(500, 500);
                 this.Text = "Riemer's DirectX Tutorial using C# -- Season 2";
             }
     
             static void Main()
             {
                 using (WinForm our_directx_form = new WinForm())
                 {
                     our_directx_form.InitializeDevice();
                     our_directx_form.SetUpCamera();
                     our_directx_form.LoadFloorplan();
                     our_directx_form.VertexDeclaration();
                     our_directx_form.LoadTexturesAndMaterials();
                     our_directx_form.LoadMeshes();
                     our_directx_form.InitializeInputDevices();
                     Application.Run(our_directx_form);
                 }
             }
         }
     }


    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)
    XNA 3.0 Recipes Book (8)
    Downloads
    Extra Reading (3)
    Matrices: geometrical
    Matrix Mathematics
    Homogenous matrices
    Community Projects (1)
    Tutorials (160)
    XNA 4.0 using C# (89)
    DirectX using C# (54)
    Series 1:Terrain (14)
    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)
    Short Tuts (2)
    DirectX using C++ (15)
    DirectX using VB (2)
    -- 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!