Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

02.06 - Introducing DirectX

  • You cannot reply to this topic
55 replies to this topic

#1 Teej   GDNet+   -  Reputation: 176

Like
Likes
Like

Posted 10 April 2001 - 04:08 PM

The Windows Shortfall If you’ll recall in 02.04 - Game Anatomy 101, I made the distinction between internal and external game elements. In this article, we’re going to take a look at a technology that does it all. You might be wondering, “Aren’t there already ways to read the keyboard, play sounds and draw on the display right in Windows?” Sure there are, but they aren’t up to the task for games. For instance, GDI drawing routines are far too slow for the kind of frame rates we expect – heck, GDI was designed for business presentation graphics! Windows has no native support for all of the fancy things that sound cards are capable of these days, and you’re going to be fumbling to try and keyboard, mouse and joystick input in a proper and orderly fashion. Enter: DirectX Microsoft has long been aware of this, and has responded with a set of software components that interact with the hardware on a lower level, thereby drastically increasing performance. They’re called DirectX components, and address your sound, music, input, output and network needs. Here’s a list of the components (as of version 7.0):
  • DirectDraw
  • DirectInput
  • DirectSound
  • DirectMusic
  • DirectPlay
  • Direct3D
Each of these components are actually COM objects, and are used much like regular C++ objects (if you don't know what COM is, don't worry). Luckily, each is fairly intuitive and straightforward to get working for you. In the sections that follow, I’ll introduce three of these – DirectDraw, DirectSound and DirectInput, and leave the rest for when they’re needed. DirectDraw DirectDraw is our ticket to unleashing the power of hardware acceleration, video memory and all of the various features available in today’s high-performance video hardware. We are able to create memory buffers called DirectDraw surfaces, and these surfaces can make use of video and system memory to hold buffers for the actual display, secondary display buffers, and buffers for our game images. The beauty of DirectX is in its ability to ‘flip’ surfaces directly to the video adapter’s active display, removing the need to copy memory. And since our game images can be held in DirectDraw surface buffers in the video card’s memory, hardware acceleration can be used to move these images directly into display buffers for speedy rendering. DirectInput The asynchronous state of a wide array of input devices can be ascertained through DirectInput objects. It’s direct (read: fast ), it’s well organized and it’s a convenient abstraction for all of the data available to your game. You don’t have to worry about the endless types of joysticks, mice, VR headsets, force-feedback devices or anything else on the market – the data you’re looking for is presented to you in a way you can use without the hassle. DirectSound Sound can be a complicated aspect of writing a game. DirectSound seeks to simplify the output of sound and puts the power of many specialized effects at your disposal, and allows you to use audio resources in any popular format. Similar to DirectDraw’s surfaces, DirectSound utilizes sound buffers for storing, organizing and playing your audio resources in a straightforward and intuitive manner. Other Options Of course, DirectX isn’t the only solution out there for gaming under Windows. Here’s a (very) partial list of some other tools:
  • OpenGL (Open graphics library – very popular as well)
  • GlIDE (3DFX’s native API for Voodoo-based video cards)
  • Allegro (a multi-platform graphics library)
  • SDL (another multi-platform graphics library – thanks to pazu for the heads-up)
  • MIDAS (a third-party sound support API)
I’m sure that you can think of many that I haven’t listed… So why did I choose DirectX? One of the advantages to using DirectX is that the libraries needed on the user’s end are either already in Windows, or simple to update. As you’ve no doubt seen, it’s a very popular choice for most of today’s popular games. A main disadvantage to using (only) DirectX is that it’s not portable to other types of systems. After all, there are people using other environments such as UNIX or the MAC. As a matter of fact, I’m already getting differences of opinion from some forum members on choosing DirectX. Deep down though, you all know I’m right Multi-Platform Parallel Development There’s a willingness by many forum members to have the main material in this forum adopted to other graphics, input and sound tools, and for the most part I’m all for supporting as wide an array of multi-platform APIs as possible. Unfortunately, I doubt I’d have the time to perform the necessary translation myself. As is the case with my choice of language, you’re going to be limited to DirectX in the material I present (for the foreseeable future anyhow), but I am willing to entertain requests from others to take on a role in this tutorial series by representing the interests of other tools. More information on this ongoing issue will follow. Arming Your Machine for DirectX There are two components for DirectX: the user DLLs and the developer’s SDK. Both are available from Microsoft (http://www.microsoft.com/directx), but before you do, we’d better look at the various versions of DirectX that are available (and in use). At the time of this writing, DirectX 7.0(a) and 8.0(a) are the main current versions. This forum uses version 7.0, which means that you need at least this version installed on your machine. Remember that you need both the runtime DLLs (for playing games) and the SDK for writing programs that use DirectX components. If you download and install a version later than 7.0, it includes everything you need. Let me rephrase that clearly: Every version of DirectX is fully compatible with every previous version. If you have DirectX 8.0, you can write games that use version 1, 3, 5, 6 or 7 (there’s no 2 or 4). Think about it – Microsoft couldn’t just scrap older versions or your games would stop working when you updated DirectX on your machine! As I’ve mentioned, there are some DirectX-related files on my webpage, and you can pick and choose what to download instead of grabbing a 150MB file from Microsoft with a lot of useless contents. The one thing that I strongly encourage you to get (even if you have the DirectX 8.0 SDK) is the documentation for DirectX 7.0. Trust me, you’ll need this. The version 8.0 documentation isn’t going to help you. And if you proceed without this documentation at your fingertips, you’re as good as dead . One question remains – if DirectX 8.0 is available right now, why are we using version 7.0 for the tutorials? Well, this is still under debate by many here, but I basically have two reasons:
  1. DirectX 7.0 is still very popular – it’s bound to be the most compatible for writing a game with.
  2. The way things are done in DirectDraw has been massively overhauled in version 8.0 (so much so, DirectDraw doesn’t even exist in 8.0!), and although it’s not the newest anymore, it’s still the most ‘compatible’ when learning to use graphics APIs.
How else can I put it? Version 8.0 is still very new, and 7.0 is well understood by many. It’s in no way out-of-date, and already has more functionality than we even need for a long, long time. The moment I hear a decent argument for abandoning 7.0 in favor of version 8.0, I’ll be the first to concede and update the contents of all material in this forum. What About the Other DirectX Components? DirectMusic deals with playing MIDI music in your game. While I agree that it’s an important part of professional games, it’s not really central to game development. We’ll see where this forum takes us. DirectPlay assists in all of those fun issues involved with network-play. As with DirectMusic, I do not doubt its usefulness – I’m just not concerned with it at the moment. Direct3D: oh boy . I bet that many of you are drooling over this one, aren’t you… Well, here’s my philosophy on 2D and 3D games: if you can’t make Pac-Man eat pellets or a sprite jump onto a ledge, you’re not going to be able to write the next Unreal Tournament. We’re starting our game development journey from the ground-up, and that means at the basics. Too many over-eager enthusiasts jump right into 3D engines and find themselves either pasting code together from other websites, getting hopelessly lost in the mountains of complicated code and math, or finally finishing and having a basic, out-of-date 3D engine ala Quake I/II. The true creativity (in my humble opinion) can be better manifest in 2D games. Ultimately, I’d love to have the forum evolve to such a state where we move into 3D game development… it is, after all, the natural progression… Pre-Flight Checklist Before you move onto the next article, I want you to ensure that you have the following installed and ready:
  • DirectX 7.0 (or higher) runtime DLLs – you can check this by going to your Start Menu/Run… and typing DXDIAG. Somewhere on the first tab of this utility is the current DirectX version number on your machine.
  • DirectX 7.0 SDK (or higher) – you need the C++ libraries at the very least. Also included in the install package is a whack of samples that you may or may not be interested in (but I do highly recommend that you get them – many of the samples are great to learn from)
  • DirectX 7.0 Online Documentation – this comes with the complete DirectX 7.0 SDK, but not with version 8.0. I’ve already told you that this is important, and that it’s available on my webpage.
Here's the link to my webpage: http://teejb.webjump.com If you’re ready, we’re going to move on to actually starting to use this stuff in the next article. Questions? Comments? Please reply to this post. Edited by - teej on April 10, 2001 11:24:37 PM

Sponsor:

#2 Thek   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 April 2001 - 08:20 AM

I don''t know how practical this is, but I''m really interested in DirectPlay, and I''m sure I''m not alone. There seems to be a shortage of good DP Tutorials on the net, and I''ve been looking.
~Thek

"There are three kinds of people in the world: those who can count, and those who can''t."

#3 Higgenkreuz   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 April 2001 - 08:19 AM

Hi everybody,

Does anybody know where I could find version 7.0 of DirectX SDK for Visual C++? I visited the Microsoft download page, but the only thing available there is ver 8.0.

Thanks in advance

#4 Skidoodlidoo   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 April 2001 - 08:30 AM

I do not think you can still get directX 7.0 from Microsoft but directx 8.0 should be just fine.

As Teej said, 8.0 is fully compatible with 7.0. The only thing you need, since we will be doing games with directx 7.0 is the documentation for 7.0 and you can get it from Teej''s page.

Hope it helps

Skidoodlidoo

#5 Piotyr   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 April 2001 - 02:47 PM

Careful, the DX8 user runtime will run DX7 programs, but the DX8 developer SDK won''t be compatible with DX7 code. Mostly the area that is affected is the stuff that is done with DirectDraw (since MS put all 2D functionality in D3D and removed DDraw entirely). Seeing as the first few games (at least) that''ll be done in here are 2D, DirectDraw will be a large part of it. I think you can get the developer stuff for DX7 on Teej''s site.

#6 Blackstream   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 April 2001 - 03:20 PM

I don''t know where you heard that Piotyr, but it is soooo wrong. I installed DirectX 8 on my computer (developer files), and atm, I am making a pong clone using... DirectX 7. There are ambiguities. For example, if you include D3d.h, you will be programming in DirectX 8. That must be what you meant. But wait

#define DIRECTDRAW_VERSION 0x0700

Presto. All your code are belong to us. In directx version 7. Want to go back to the good ole days and execute buffers?

#define DIRECTDRAW_VERSION 0x0300

Tryyyy it. It works. (If you don''t believe me, go into ddraw.h, it comes with your DirectX sdk, at the very beginning.. oh here, I''ll just hand you the snippit of code.

/*==========================================================================;
*
* Copyright © 1994-1997 Microsoft Corporation. All Rights Reserved.
*
* File: ddraw.h
* Content: DirectDraw include file
*
***************************************************************************/

#ifndef __DDRAW_INCLUDED__
#define __DDRAW_INCLUDED__

//Disable the nameless union warning when building internally
#undef ENABLE_NAMELESS_UNION_PRAGMA
#ifdef DIRECTX_REDIST
#define ENABLE_NAMELESS_UNION_PRAGMA
#endif

#ifdef ENABLE_NAMELESS_UNION_PRAGMA
#pragma warning(disable:4201)
#endif

/*
* If you wish an application built against the newest version of DirectDraw
* to run against an older DirectDraw run time then define DIRECTDRAW_VERSION
* to be the earlies version of DirectDraw you wish to run against. For,
* example if you wish an application to run against a DX 3 runtime define
* DIRECTDRAW_VERSION to be 0x0300.
*/
#ifndef DIRECTDRAW_VERSION
#define DIRECTDRAW_VERSION 0x0700
#endif /* DIRECTDRAW_VERSION */


Just letting you know.

-Blackstream

Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage

#7 Piotyr   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 April 2001 - 04:09 PM

Sure that comes with the DX8 SDK? I know I don''t have it with the DX8 SDK, and had to revert to 7 to do DDraw stuff. Maybe they included it in a later version, but when I downloaded it, about 3 days after it came out, there wasn''t any DDraw.h in there. I''ve been wrong before, though, so it wouldn''t surprise me too much. I''ve just used the DX7 SDK for all my 2D needs.

#8 Blackstream   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 April 2001 - 04:22 PM

Hmmm, interesting. I wonder why what you downloaded didn''t have it. You downloaded the whole 130 mb (or so) right? But I do know that what I downloaded had DirectX 8 on it, because this is a new computer that I have, and I didn''t have any sdks installed on my computer. I downloaded DirectX 8, and now I have Ddraw.h. Check you DirectX 8 samples that you got. In the directDraw folder (if you got that, hrmmmm) there is a windowed mode program. They use DirectX 7 and a really nice version of Ddutil.h (it is in class form now). I''d redownload the sdk and have a look at it (if you have time or a dsl). I haven''t looked into direct 3d for DirectX 8, but I here it is much better than 7 (which I touched once). Or do you already have Direct 3d 8? I''m not sure if you had to uninstall 8 in order to use 7 again or not.

-Blackstream

Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage

#9 leggyguy   Members   -  Reputation: 128

Like
Likes
Like

Posted 18 April 2001 - 12:20 AM

Hey Teez, I see we have stopped for a while. Just wondered when we would be moving again



#10 Bifff   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 April 2001 - 01:16 AM

Borland C++ Builder Compiler and DirectX

As I said in an other section, BCC is by far one of the best compiler available and it is free:


BCC 5.5

But when it comes to DirectX, many of you may have to fight hard to link your stuffs. I can prevent this for you: BCC users will have to download specific Borland-compatible libraries . A place to find these is Fötsch''s website:


Borland-compatible DirectX LIB''s

#11 polomint   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 April 2001 - 09:24 AM

OK ! OK !

Does anyone actually know where we can all download the DirectX7 SDK??!?!?!?!

I have DX8SDK, but haven''t got a clue on how to start with DirectDraw. I know it''s now integrated into D3D.

Please, please, someone show us all where to get the DX7SDK!

Thanks

Polomint

#12 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 18 April 2001 - 10:38 AM

You don''t need DX7 SDK, you can still use it DirectDraw with DX8 just like you would with DX7.

#13 Fighterdude   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 April 2001 - 05:06 AM

here are the links to the sdk and the api sdk

http://www.microsoft.com/downloads/release.asp?ReleaseID=12471
http://www.microsoft.com/downloads/release.asp?ReleaseID=12253

i hope they help im not sure witch one your supose to use so could someone please tell me

Fighterdude(A Baldurs Gate Fan)

#14 Halek   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 April 2001 - 07:07 AM

polomint : You can still find the DX7 SDK on the microsoft site. You''l have to make some searches for it but you can eventually find it.

I think i found it by making some searhes on the knowledge base but i''m not too sure which search criterias i used.
I know that if you go to the DX page you only get the latest one (DX 8) and the other resides on some obscure backup location only.

good luck finding it, but i know it''s ther since i downloaded it myself.

On the other hand i can assure you that it''s not a requirement at all for this tutorial series. You can do everything with the DX 8 SDK

Hope this helps

#15 polomint   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 April 2001 - 04:44 AM

Thanks all for your help, I''ll go to ms and see if I can find the DX7SDK.
Thanks again


#16 Teej   GDNet+   -  Reputation: 176

Like
Likes
Like

Posted 23 April 2001 - 05:28 AM

For DirectX downloads, just grab the latest version from Microsoft. Like I''ve said, any newer DirectX version is guaranteed to have 7.0 ''included''. The important thing is to have the documentation, which I provide on my webpage.

leggyguy: As I''ve posted in the News section, I''m experiencing a setback, but I''m working on it!

Teej



#17 Lord Maz   Banned   -  Reputation: 110

Like
Likes
Like

Posted 28 April 2001 - 12:02 PM

Ehm.. This is too confusing for me - could someone tell me just what files I need to download to get this thing running? I got the files from teejs homepage, but there are files missing that i need in that readiness test.. Please don''t tell me I have to download that 140 meg file! at the current rate, it will take 10 hours..

-Lord Maz-

#18 leggyguy   Members   -  Reputation: 128

Like
Likes
Like

Posted 28 April 2001 - 09:42 PM

Lord Maz, I would strongly recomend getting that 140meg download. It is DX8, and everything that we will be doing here will work perfectly on it. Teej is using DX7, but DX8 can run everything built for DX7, and more on top. Eventually, you will want to use the DX8 stuff anyway if you carry on with DX programming.

To download it, simply get Gozilla or Flash Get, and leave it downloading when you go to bed. In the morning it will be pretty much finished. If you have an ISP that cuts off after a few hours, don''t worry, ''cos these download managers can just redial automatically and resume the download.


#19 Lord Maz   Banned   -  Reputation: 110

Like
Likes
Like

Posted 28 April 2001 - 11:38 PM

Oh well.. *click*

10 h, 20 min and 50 seconds.. 49.. 48..
I hope it''s worth it!


-Lord Maz-

#20 RandomGamer   Members   -  Reputation: 122

Like
Likes
Like

Posted 02 May 2001 - 06:44 AM

Bifff: How do I set up/use the Directx that is compatable with BCC? I''m not really sure how to compile a dll file with BCC either. Also, that file was much under an MB, so do I have to download the rest from Microsoft and then replace things?





PARTNERS