ASP.NET
  Home arrow ASP.NET arrow Page 2 - Managed DirectX First Steps: Direct 3D Bas...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Managed DirectX First Steps: Direct 3D Basics and DirectX vs. GDI+
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 65
    2005-01-26

    Table of Contents:
  • Managed DirectX First Steps: Direct 3D Basics and DirectX vs. GDI+
  • DirectX Overview
  • Referencing DirectX Libraries
  • Put That in Your Pipeline and Shade It
  • 3-D Coordinate Systems and Projections
  • Drawing Primitives and Texture
  • The Application Proposal
  • The Coding Phase
  • Second Step: Coding Your First Windowed Test
  • Code the Render Procedure
  • Fourth Step: Using Transparent Textures
  • Fifth Step: Changing Diffuse Colors
  • Sixth Step: Testing Matrix Transformations
  • Adding the Final Touches

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Managed DirectX First Steps: Direct 3D Basics and DirectX vs. GDI+ - DirectX Overview


    (Page 2 of 14 )

    In this section, we’ll discuss some common terms used in the DirectX world and see how they fit together to provide you a framework for building great games.

    Using hardware acceleration is a wonderful thing, because you can go from dozens of frames a second, such as in the previous two sample applications, to hundreds of frames drawn per second. In the tests in this chapter, the basic samples easily reach 300 frames per second, and can go to almost a thousand depending on the hardware capabilities!

    Of course, there’s a price to pay. Even the simplest games must go through some complex routines, and you’ll have to learn some new concepts, even if you don’t want to take full advantage of the hardware acceleration features.

    When you manage to understand these initialization routines and the basic concepts, you can use the Direct3D interface to create your 2-D games without even worrying about more advanced concepts like depth buffers or vertex blending.

    Let’s start with an overview of the main concepts used by DirectX and how they’re related.

    Presenting the DirectX Top-Level Objects

    A good library for writing games doesn’t just deal with computer graphics; it also deals with handling input, generating sounds and music, and handling communication between clients and servers in a multiplayer gaming context.

    Here is a quick overview of the libraries available with Managed DirectX:

    •  Microsoft.DirectX is the top-level namespace, but also contains common mathematical constructs such as vectors and matrices.
                                                                                  
    • Microsoft.DirectX.Direct3D is the most commonly used library and contains classes and structures designed to help you create and render 3-D images.

    • Microsoft.DirectX.Direct3DX is a set of “helper libraries” that have many common functions used when creating Direct3D applications.

    • Microsoft.DirectX.DirectDraw exists mostly for backward-compatibility with older versions of DirectX. All the functionality of DirectDraw was subsumed into the Direct3D namespace. In the past, DirectDraw was the primary API used to create 2-D games.

    • Microsoft.DirectX.DirectInput is the namespace where all input devices are controlled and managed. It even has support for force-feedback joysticks.

    • Microsoft.DirectX.DirectPlay allows you to write multiplayer games using efficient network communication packets.

    • Microsoft.DirectX.DirectPlay.Lobby extends DirectPlay to support a client/ server style of multiplayer gameplay.

    • Microsoft.DirectX.DirectPlay.Voice adds voice communication features to DirectPlay. It is highly flexible and allows you to add your own sound decoders (codecs) if you’re brave enough.

    • Microsoft.DirectX.DirectSound gives sound capabilities to your application, including the ability to simulate 3-D sounds and effects. It also has all the other cool “knobs and whistles” you would want in a sound library, including the ability to add echo, reverb, and other effects.

    • Microsoft.DirectX.AudioVideoPlayback gives you the ability to do simple control of audio and video playback within your application.

    • Microsoft.DirectX.Diagnostics is used to let you programmatically investigate the features of your environment.

    • Microsoft.DirectX.Security gives you secure control over all input and output components of DirectX.

    • Microsoft.DirectX.Security.Permissions is a component of the Security namespace that lets you establish security actions and policies.

    • Direct3D allows access to the 3-D acceleration layer.

    In this chapter, we’ll concentrate on the Direct3D namespace, and you’ll learn some helper functions from Direct3DX. In upcoming chapters, we’ll also examine DirectSound, DirectInput, and DirectPlay.

    Understanding Adapters

    As you’ve probably guessed, DirectX has a lot of new terminology that you’ll see mentioned over and over again. One of those terms is adapter. A graphics card generally has one adapter in it, from the DirectX perspective (although many graphics cards support multiple adapters now). It’s not unusual to have a single computer driving multiple monitors anymore, and this is usually done with multiple adapters attached to the computer. Conveniently, DirectX provides some functions that allow you to list all display adapters attached to a system and gather some information about them.

    You don’t do any direct operations over an adapter; the functions are here just for informational purposes, or to allow you to choose between adapters when you have more than one.

    Usually you’ll have only one adapter (the default), but with machines with secondary adapters you can use the adapter identifier (a sequential number) to switch from one adapter to another.

    To gather the adapter information, you can use the following code sample:

    public void ListAdapters() {
      AdapterDetails adapterInfo;
      // Add each adapter to the LstAdapters list box.
      foreach(AdapterInformation info in Manager.Adapters) {
        LstAdapters.Items.Add(info.Information.Description);
      }
    }

    Note that these code samples will require you to reference the Managed DirectX assemblies; see the sidebar “Referencing DirectX Libraries” for more details. In Managed DirectX, many of the methods are reengineered to provide a more intuitive interface than their unmanaged counterparts. For example, many Get methods have been replaced by properties such as the Adapters.Count property in the preceding code, which replaces the previous GetAdapterCount method. Additionally, some functions that returned values as parameters have been rewritten to return values as the result of the function. There’s also a new object, the Manager, presented in the previous code sample, that handles basic interactions with Direct3D. These kinds of modifications make the code cleaner for the managed version of DirectX.

    The code listing uses the Adapters.Count property to run across the adapters and gather the description of each one. Although Description can vary for the same device and driver when dealing with different vendors, it and the DriverName property of the AdapterDetail structure are the only human-readable information available. The other members of this structure are numeric values that identify the driver version, revision, and other internal control numbers, and won’t be of interest to you (refer to DirectX SDK help for further information).


     

    This chapter is from Beginning .NET Game Programming in C# by David Weller et. al.(Apress, 2004, ISBN: 1590593197). Check it out at your favorite bookstore today. Buy this book now.

    More ASP.NET Articles
    More By Apress Publishing


     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek