1. Trang chủ
  2. » Công Nghệ Thông Tin

Beginning Direct 3D Game Programming P2

20 350 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 20
Dung lượng 0,93 MB

Nội dung

After you have configured Visual C/C++ 6, make sure it is configured correctly by compiling one of the examples in the C:\DXSDK\Samples\C++\Direct3D directory. You might see something like the following message if you haven’t configured the include path properly: d:\book\source\part 1\chapter6\animated objects\objects.cpp(68) : error C2146: syntax error : missing ‘;’ before ‘g_Keyboard_pDI’ Even if you provided the correct path to the header and library files, you might have to feed the names of these files to the linker of your development environment. The proper path to these object/library modules should be listed in your Link dialog box. To reach this dialog box, select Project, Settings and then choose the Link tab. In the General category, there is an entry field called Object/Library Modules. It holds all of the library files, which should be linked to the application you’re currently developing. It should look like Figure I.15. In this entry field, you will need to name at least the following: • d3dx9.lib • 3dxof.lib • d3d9.lib • winmm.lib • dxguid.lib If you missed a file, an error message that might look like this will appear: d3dapp.obj : error LNK2001: unresolved external symbol _Direct3DCreate9@4 Debug/SkinnedMesh.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. xxxi Introduction Figure I.15 Configuring the Linker Path Here, d3d9.lib is missing. The unresolved external symbols are part of the COM (Component Object Model ) interfaces of Direct3D. (I will explain COM in detail later in the book.) You should also check another include path, the one that holds the path to the directories of the common include files for the C/C++ compiler. If you change your machine or you are working on another machine with a different DirectX directory, normally you have to add the common files using Project, Add Files to Project, Files. Now let’s compile our first project. 1. Fire up your Visual C++ configured development environment. 2. Click on Open Workspace. 3. Choose basics.dsp. 4. Check whether you’ve configured the paths to the directories as described previously. 5. Choose the Build/basics.exe build. 6. When everything works correctly, choose run basics.exe. That’s it. If something went wrong, reread the sections on installing the DirectX SDK and Visual C++, and consult the provided documentation. Setting Up Visual C++ .NET Similar to Visual C/C++ 6, the DirectX 9 SDK will set all paths for you if you install it after you install Visual C++ .NET. Nevertheless, in case anything went wrong, this section tells you what you have to do if you need to configure DirectX 9 in the Visual C++ .NET IDE manually. You start by clicking on Tools, Options in the Visual C++ .NET IDE, as shown in Figure I.16. There is a project section that holds all the paths to the relevant directories, as shown in Figure I.17. If you have seen the dialog box that is used by Visual C/C++ 6 Studio, you should feel com- fortable because this dialog box uses the same logic. You can see that at the top-right of the dialog box, the Show Directories For drop-down menu offers the different kinds of files that you can reference (see Figure I.18). xxxii Introduction xxxiii Introduction Figure I.16 Choose the Options menu item Figure I.17 Choose the Project, VC++ Directories section After you choose a type of file, the referenced directories will appear in the large area in the middle of the dialog box. The include file directories are C:\dxsdk\include and C:\DXSDK9\Samples\C++\Common\ Include. You should point your Visual C++ .NET IDE to these directories by clicking on the New button and then on the ellipsis button. A default dialog box will open, allowing you to choose a directory (see Figure I.19). xxxiv Introduction Figure I.18 Choose the type of file to reference Figure I.19 Choose a directory Now put this directory at the top of the list by using the arrow buttons. After you have referenced the directories to the include files, choose the path to C:\dxsdk\lib to reference the library files correctly. Don’t forget to bring them to the top of the list using the arrow buttons. The proper path to the additional dependencies files should be listed in the Additional Dependencies field at Project, Properties, Linker, Input. In this entry field, you will need to name at least the following (see Figure I.20): • d3dx9.lib • d3dxof.lib • d3d9.lib • winmm.lib • dxguid.lib If any problem occurs, check out the end of the “Setting Up Visual C++ 6.0” section for solutions to common problems. The solutions are the same for Visual C++ .NET. Now let’s compile our first project. 1. Fire up your Visual C++ .NET configured development environment. 2. Click on Open Solution. 3. Choose basics.sln. 4. Check whether you’ve configured the paths to the directories as described previously. 5. Choose Debug, Start Without Debugging. 6. When everything works correctly, basics.exe will start. xxxv Introduction Figure I.20 Choose additional dependencies That’s it. If something went wrong, reread the sections on installing the DirectX SDK and Visual C++ .NET, and study the provided documentation. DirectX Shader Debugger To debug vertex and pixel shaders, you need to install the DirectX shader debugger. This debugger is only provided for Visual C++ .NET. You can find it in the dialog box of the DirectX installation routine, as shown in Figure I.21. By default, the shader debugger is not selected, so you have to choose it explicitly. If the computer only hosts a Visual C/C++ 6 installation, you don’t get this choice at all. The dialog box will look like Figure I.22. Please note that only Visual C++ .NET users can use the shader debugger. xxxvi Introduction Figure I.21 Choose the shader debugger by clicking on DirectX Extensions for Visual Studio 7 Figure I.22 Installable DirectX utilities under Visual C/C++ 6 Other Tools Two plug-and-play compilers (provided by Intel and Codeplay) can be switched into the Visual C/C++ 6 or Visual C++ .NET IDE. They offer higher performance for game programmers than the compilers provided with these IDEs. However, I don’t recommend that beginners use these compilers because they overcomplicate some things. You can find more information at http://www.intel.com/software/products/compilers and at http://www.codeplay.com. While on Intel’s Web site, don’t forget to check out VTune, a profiler that helps you to optimize your game. These and the Visual C++ compilers from Microsoft are the fundamental development tools that the majority of PC game program- mers use nowadays. Additional Resources The CD-ROM provided with this book includes a directory called Movies. These movies inter- actively show you how to configure the default paths of Visual C/C++ 6 and Visual C++ .NET. You should visit the Microsoft MSDN site for DirectX (http://msdn.microsoft.com/directx) at regular intervals, and also the mailing list at http://discuss.microsoft.com/SCRIPTS/ WA-MSD.EXE?S1=DIRECTXDEV. You can find daily news about the game developer com- munity at http://www.gamedev.net or http://www.flipcode.com. I’ll also provide additional information on http://www.direct3d.info. xxxvii Introduction PA RT ONE DirectX Graphics: Don’t Hurt Me 1 The History of Direct3D/DirectX Graphics 2Overview of HAL and COM 3 Programming Conventions 4 3D Fundamentals, Gouraud Shading, and Texture-Mapping Basics 5 The Basics 6 First Steps to Animation CHAPTER 1 The History of Direct3D/ DirectX Graphics 01 direct3d chap01 6/19/03 5:18 PM Page 3 [...]... release of DirectX 6.0 The major changes between Direct3 D Immediate Mode versions 6.0 and 7.0 affected the support of hardware-accelerated transformation and lighting and the reorganization of the lights, materials, and viewport objects, which now are set directly by calling the methods of IDirect3DDevice7 Direct3 D 7 dropped the special interface used in Direct3 D 6 to access textures The IDirect3DDrawSurface7... textures DirectX 8 The advent of the DirectX 8.0 SDK brought the biggest improvements in the history of Direct3 D Direct3 D got a fundamentally new architecture with version 8.0 The initialization, allocation, and management of data were simplified by the integration of DirectDraw and Direct3 D into one interface, called DirectX Graphics, which led to a smaller memory footprint and a simpler programming. .. shaders in DirectX 8 • The basics of 3D textures DirectX 2.0 With the advent of DirectX in 1995, Microsoft provided within Windows the performance previously available only through DOS, without the complexity of supporting each vendor’s particular hardware Now every hardware vendor delivers its product with Windows drivers Direct3 D, part of DirectX, appeared in 1996 in DirectX 2.0 Direct3 D is designed...1 4 The History of Direct3 D/DirectX Graphics T his chapter covers the history of Direct3 D and its functional development over time It starts with DOS and PC history, and it discusses how three British students changed the world of 3D programming Before Windows, DOS was the most popular operating system for the PC Games were programmed exclusively in DOS for many years Game developers resisted... has been used in versions since DirectX 6 and is used in all examples in this book Starting with DirectX 8.0, this framework is called common files You will find these files in the C:\DXSDK9\Samples\C++\Common directory 7 8 1 The History of Direct3 D/DirectX Graphics The common files give you the direct access you need and encapsulate the details of setting up Direct3 D, which is great for your learning... to program the graphics processor directly) 5 1 6 The History of Direct3 D/DirectX Graphics Point Sprites A new feature of DirectX 8 was the ability to use hardware sprites for a particle system to generate sparks, explosions, rain, snow, and so on So-called point sprites are supported by their own programming interface to help you accomplish this 3D Textures With 3D volumetric textures, you can accomplish... programmers • All games developed in early versions of DirectX must be guaranteed to run in future versions of DirectX Hardware Abstraction Layer Along with the graphics card driver provided by the hardware vendor, Direct3 D provides a very thin software layer around your graphics card HAL makes up one part of this thin layer If you’ve ever played a game driven by DirectX, you’ve seen HAL Every game includes... to play the game Nowadays, the software /game manufacturer must develop the hardware emulation device, whereas in former incarnations of the DirectX run-time environment, Microsoft provided it as the RGB device Software devices are loaded by the application and registered with the Direct3 D object The function to register a pluggable software device is IDirect3D9::RegisterSoftwareDevice The DirectX 9 DDK... DirectX 7.0 games you can choose a HAL, TnLHAL (Transformation and Lighting HAL), RGB, or a reference rasterizer driver from this dialog box In DirectX 8.0/8.1/9.0 games, you might choose between a HAL, a pluggable software device, or a reference rasterizer; or the application might select one automatically You will find this device selection box, called the Direct3 D Settings dialog box, in every Direct3 D... 1995 DirectX 8 After the acquisition of RenderMorphics, Microsoft integrated Reality Lab into its DirectX family of APIs (Application Programming Interfaces) The Immediate Mode component of Reality Lab absorbed the standard 3D Windows API of the time, 3-D-DDI, which was created by Michael Abrash, who later helped create the Quake 1 engine at id Software DirectX 6/7 Until the advent of DirectX 8.0, Direct3 D . set directly by calling the methods of IDirect3DDevice7 . Direct3 D 7 dropped the special interface used in Direct3 D 6 to access tex- tures. The IDirect3DDrawSurface7. drivers. Direct3 D, part of DirectX, appeared in 1996 in DirectX 2.0. Direct3 D is designed to give access to the advanced graphics capabilities of 3D hardware

Ngày đăng: 06/11/2013, 11:15

TỪ KHÓA LIÊN QUAN