当前位置:服务支持 >  软件文章 >  Direct3D (DirectX 9.0) 代码示例大全与实战应用

Direct3D (DirectX 9.0) 代码示例大全与实战应用

阅读数 3
点赞 0
article_banner













Direct3D (DirectX 9.0) Code Samples 的图1 Direct3D (DirectX 9.0) Code Samples 的图2 Direct3D (DirectX 9.0) Code Samples 的图3
Direct3D (DirectX 9.0) Code Samples 的图4





High Dynamic Range Texture Loader

This sample demonstrates how to load a .hdr or "light probe" image file (High Dynamic Range) as a Direct3D texture.


The sample also demonstrates how to use a vertex and pixel shader to perform tone-mapping on the fragment colors generated by the HDR texture, so they can they can be rendered on low-dynamic display devices like CRTs and LCD panels.


Relevant Keywords: D3DXCreateEffectFromFile, SetTechnique, SetTexture, SetFloat, Begin, End, BeginPass, EndPass, RGBE_ReadHeader, RGBE_ReadPixels_RLE, rgbe_header_info, D3DXCreateTexture, LockRect, UnlockRect, float4x4, texture, sampler_state, technique, pass, compile, ps_2_0, tex2D, LPD3DXEFFECT, D3DLOCKED_RECT, LPD3DXBUFFER, and D3DFMT_A16B16G16R16F.


Direct3D (DirectX 9.0) Code Samples 的图5


Direct3D (DirectX 9.0) Code Samples 的图9
Direct3D (DirectX 9.0) Code Samples 的图10 Direct3D (DirectX 9.0) Code Samples 的图11 Direct3D (DirectX 9.0) Code Samples 的图12
















Direct3D (DirectX 9.0) Code Samples 的图13 Direct3D (DirectX 9.0) Code Samples 的图14 Direct3D (DirectX 9.0) Code Samples 的图15
Direct3D (DirectX 9.0) Code Samples 的图16





Solid Node BSP Tree Compiler

One method of speeding up a game engine is to use a BSP-Tree (Binary-Space Partitioning Tree) to subdivide and sort your game's world geometry.


This is done by dividing up, sorting, and storing polys in a BSP Tree in a such as way as to denote their relationship to one another (i.e. being in front of or in back of another poly). Once the BSP tree is compiled or built, the engine can quickly decide whether or not it should render certain polys based on the view’s current location within the world.


For example, the BSP compiler in this sample demonstrates how early game programmers, who didn't have hardware accelerated z-buffers, used a simple solid-node style BSP tree to sort their scene polys into a back-to-front order for proper rendering. The sample also demonstrates how a BSP Tree can be used for collision detection by identifying whether or not a unobstructed line-of sight can be established between two 3D points.


Unfortunately, the code doesn't go into a lot of BSP Tree theory or teach the basics, so if you're new to the concept of a BSP Tree, check out this cool little Java Applet for a real-time demonstration of how they work.


This sample is based on one of the BSP demos that came with the "Advanced 3D BSP, PVS and CSG Techniques" course offered at GameInstitute.com. If you're truly interested in learning about BSP trees and how they're used in games, this course is the best by far and I highly recommend it.


Check out the OpenGL source code page for the OpenGL equivalent of this sample.


Relevant Keywords: CreateDevice, SetSamplerState, SetDataFormat, GUID_SysMouse, SetCooperativeLevel, Acquire, Unacquire, GetDeviceState, DrawIndexedPrimitiveUP, D3DXVec3Dot, DISCL_NONEXCLUSIVE, DISCL_FOREGROUND, LPDIRECTINPUT8, LPDIRECTINPUTDEVICE8, D3DXVECTOR3, DIERR_INPUTLOST, DIMOUSESTATE2, D3DSAMP_MIPMAPLODBIAS, D3DSAMP_MAGFILTER, D3DSAMP_MINFILTER, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR, D3DFMT_INDEX16 and DIRECTINPUT_VERSION.


Direct3D (DirectX 9.0) Code Samples 的图17


Direct3D (DirectX 9.0) Code Samples 的图20
Direct3D (DirectX 9.0) Code Samples 的图21 Direct3D (DirectX 9.0) Code Samples 的图22 Direct3D (DirectX 9.0) Code Samples 的图23
















Direct3D (DirectX 9.0) Code Samples 的图24 Direct3D (DirectX 9.0) Code Samples 的图25 Direct3D (DirectX 9.0) Code Samples 的图26
Direct3D (DirectX 9.0) Code Samples 的图27





2D Demo Game of a Side-Scrolling Shooter

Re-live such classic side-scrolling shooters as Gradius and R-Type by writing your own. Of course, this sample is a far cry from a fully featured side-scroller, but it will definitely put you on the right track. Check out the DirectX 8.1 source code page for the DirectX 8.1 code equivalent of this sample.


Direct3D (DirectX 9.0) Code Samples 的图28


Direct3D (DirectX 9.0) Code Samples 的图30
Direct3D (DirectX 9.0) Code Samples 的图31 Direct3D (DirectX 9.0) Code Samples 的图32 Direct3D (DirectX 9.0) Code Samples 的图33
















Direct3D (DirectX 9.0) Code Samples 的图34 Direct3D (DirectX 9.0) Code Samples 的图35 Direct3D (DirectX 9.0) Code Samples 的图36
Direct3D (DirectX 9.0) Code Samples 的图37





Simple Introduction to the NovodeX Physics SDK

This sample demonstrates how to use the NovodeX Physics SDK by simply creating and dropping boxes on to a plane that represents the ground. Check out the OpenGL source code page for the OpenGL equivalent of this sample.


Relevant Keywords: NxPhysicsSDK, NxScene, NxVec3, ErrorStream, NxCreatePhysicsSDK, setMaterialAtIndex, createScene, shapes.pushBack, createActor, NX_BROADPHASE_COHERENT, release, releaseScene, NxBodyDesc, NxBoxShapeDesc, NxActorDesc, createActor, userData, getNbActors, getActors, getGlobalPose, getColumnMajor44, flushStream, and fetchResults.


Direct3D (DirectX 9.0) Code Samples 的图38


Direct3D (DirectX 9.0) Code Samples 的图40
Direct3D (DirectX 9.0) Code Samples 的图41 Direct3D (DirectX 9.0) Code Samples 的图42 Direct3D (DirectX 9.0) Code Samples 的图43
















Direct3D (DirectX 9.0) Code Samples 的图44 Direct3D (DirectX 9.0) Code Samples 的图45 Direct3D (DirectX 9.0) Code Samples 的图46
Direct3D (DirectX 9.0) Code Samples 的图47





How to use the Tokamak SDK to Create a Rope or Chain using Ball-Joints

This sample demonstrates how to use the Tokamak Physics SDK to create a chain or rope like object by using small collision cubes joined by ball-joints. For demonstration purposes, the chain is dropped onto a platform, which doesn’t quite catch all of it. This allows the chain to hang off and swing about. For fun, you can use the F1 key to lift up on the chain's last segment by applying some velocity to it. Check out the OpenGL source code page for the OpenGL equivalent of this sample.


Relevant Keywords: neSimulator, neRigidBody, neAnimatedBody, neSimulatorSizeInfo, neBoxInertiaTensor, neJoint, neGeometry, CreateSimulator, CreateRigidBody, AddGeometry, SetBoxSize, CollideConnected, UpdateBoundingInfo, SetInertiaTensor, SetMass, SetJointFrameWorld, SetType, SetEpsilon, SetIteration, Enable, and GetTransform.


Direct3D (DirectX 9.0) Code Samples 的图48


Direct3D (DirectX 9.0) Code Samples 的图50
Direct3D (DirectX 9.0) Code Samples 的图51 Direct3D (DirectX 9.0) Code Samples 的图52 Direct3D (DirectX 9.0) Code Samples 的图53

免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删
相关文章
QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空