• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Teej

02.06 - Introducing DirectX

55 posts in this topic

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
0

Share this post


Link to post
Share on other sites
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."
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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 (C) 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
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
Hey Teez, I see we have stopped for a while. Just wondered when we would be moving again

0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
You don''t need DX7 SDK, you can still use it DirectDraw with DX8 just like you would with DX7.
0

Share this post


Link to post
Share on other sites
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)
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
Thanks all for your help, I''ll go to ms and see if I can find the DX7SDK.
Thanks again
0

Share this post


Link to post
Share on other sites
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

0

Share this post


Link to post
Share on other sites
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-
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
Oh well.. *click*

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


-Lord Maz-
0

Share this post


Link to post
Share on other sites
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?
0

Share this post


Link to post
Share on other sites
RandomGamer: Sorry that I can''t help you with BCC...there must be some people out there that have it working...anyone?

Lord Maz: Well, it''s been over a week. Is the download finished yet?

Teej

0

Share this post


Link to post
Share on other sites
Is it possible to get the DirectX SDK on CD-ROM? Such as PC magazine CDs etc?
0

Share this post


Link to post
Share on other sites
Hi, I''m having quite a bit of difficulty downloading the DirectX 7.0 Online Documentation from your website, Teej. Would it be possible for you to email it to me, or do you know an alternate place that I could get it (and preferably the Word format)? Thanks!
0

Share this post


Link to post
Share on other sites
As far as i know ( i haven''t checked in a while) the SDK can be ordered on CD format. You just have to pay the shipping cost (under $10)
0

Share this post


Link to post
Share on other sites
Here''s a link to the DirectX 7.0a SDK if anyone is interested...

http://msdn.microsoft.com/isapi/gomscom.asp?TARGET=/downloads/release.asp?ReleaseID=16927

0

Share this post


Link to post
Share on other sites