⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csdn_文档中心_directx 8 开发者常见问题集.htm

📁 csdn10年中间经典帖子
💻 HTM
📖 第 1 页 / 共 4 页
字号:
          <TD align=middle height=10></TD>
          <TD height=10></TD></TR></TBODY></TABLE><!--文章说明信息结束//-->
      <TABLE border=0 width=600>
        <TBODY>
        <TR>
          <TD align=left><BR>&nbsp;<!--SYNC_END--> 
            <H1><A name=directx8faq></A>Microsoft DirectX 8 Developer FAQ</H1>
            <P>Microsoft Corporation</P>
            <P>February 2001</P>
            <P><B>Summary:</B> This article provides in-depth answers to 
            frequently asked development questions regarding Microsoft DirectX, 
            version 8.0, including sections on Direct3D, DirectSound, and 
            DirectPlay. (10 printed pages)</P>
            <P><B>Contents</B></P>
            <P><A 
            href="http://msdn.microsoft.com/library/techart/DirectX8faq.htm#directx8faq_topic1">General 
            DirectX Development Issues</A><BR><A 
            href="http://msdn.microsoft.com/library/techart/DirectX8faq.htm#directx8faq_topic2">Direct3D</A><BR>&nbsp;&nbsp;&nbsp;<A 
            href="http://msdn.microsoft.com/library/techart/DirectX8faq.htm#directx8faq_topic3">General 
            Questions</A><BR>&nbsp;&nbsp;&nbsp;<A 
            href="http://msdn.microsoft.com/library/techart/DirectX8faq.htm#directx8faq_topic4">Geometry 
            (Vertex) Processing</A><BR>&nbsp;&nbsp;&nbsp;<A 
            href="http://msdn.microsoft.com/library/techart/DirectX8faq.htm#directx8faq_topic5">Performance 
            Tuning</A><BR>&nbsp;&nbsp;&nbsp;<A 
            href="http://msdn.microsoft.com/library/techart/DirectX8faq.htm#directx8faq_topic6">Direct3DX 
            Utility Library</A><BR><A 
            href="http://msdn.microsoft.com/library/techart/DirectX8faq.htm#directx8faq_topic7">DirectSound</A><BR><A 
            href="http://msdn.microsoft.com/library/techart/DirectX8faq.htm#directx8faq_topic8">DirectPlay</A></P>
            <H2><A name=directx8faq_topic1></A>General DirectX Development 
            Issues</H2>
            <H4>Why do I get so many error messages when I try to compile the 
            samples?</H4>
            <P>You probably don't have your include path set correctly. Many 
            compilers, including Microsoft? Visual C++?, include an earlier 
            version of the SDK, so if your include path searches the standard 
            compiler include directories first, you'll get incorrect versions of 
            the header files. To remedy this issue, make sure the include path 
            and library paths are set to search the DirectX include and library 
            paths first. See also the dxreadme.txt file in the SDK. If you 
            install the DirectX SDK and you are using Visual C++, the installer 
            can optionally set up the include paths for you.</P>
            <H4>I get linker errors about multiple or missing symbols for 
            globally unique identifiers (GUIDs), what do I do?</H4>
            <P>The various GUIDs you use should be defined once and only once. 
            The definition for the GUID will be inserted if you #define the 
            INITGUID symbol before including the DirectX header files. 
            Therefore, you should make sure that this only occurs for one 
            compilation unit. An alternative to this method is to link with the 
            dxguid.lib library, which contains definitions for all of the 
            DirectX GUIDs. If you use this method (which is recommended), then 
            you should never #define the INITGUID symbol.</P>
            <H4>Can I cast a pointer to a DirectX interface to a lower version 
            number?</H4>
            <P>No. DirectX interfaces are COM interfaces. This means that there 
            is no requirement for higher numbered interfaces to be derived from 
            corresponding lower numbered ones. Therefore, the only safe way to 
            obtain a different interface to a DirectX object is to use the 
            <B>QueryInterface</B> method of the interface. This method is part 
            of the standard <B>IUnknown</B> interface, from which all COM 
            interfaces must derive.</P>
            <H4>Can I mix the use of DirectX 8 components and DirectX 7 or 
            earlier components within the same application?</H4>
            <P>You can freely mix <I>different components</I> of differing 
            version; for example, you could use DirectPlay 8 with DirectDraw 7 
            in the same application. However, you generally cannot mix different 
            versions of the <I>same component</I> within the same application; 
            for example, you cannot mix DirectDraw 7 with Direct3D 8 (since 
            these are effectively the same component as DirectDraw has been 
            subsumed into Direct3D in DirectX 8).</P>
            <H4>What do the return values from the Release or AddRef methods 
            mean?</H4>
            <P>The return value will be the current reference count of the 
            object. However, the COM specification states that you should not 
            rely on this and the value is generally only available for debugging 
            purposes. The values you observe may be unexpected since various 
            other system objects may be holding references to the DirectX 
            objects you create. For this reason, you should not write code that 
            repeatedly calls Release until the reference count is zero, as the 
            object may then be freed even though another component may still be 
            referencing it.</P>
            <H4>Does it matter in which order I release DirectX interfaces?</H4>
            <P>It shouldn't matter because COM interfaces are reference counted. 
            However, there are some known bugs with the release order of 
            interfaces in some versions of DirectX. For safety, you are advised 
            to release interfaces in reverse creation order when possible.</P>
            <H4>What is a smart pointer, and should I use them?</H4>
            <P>A smart pointer is a C++ template class designed to encapsulate 
            pointer functionality. In particular, there are standard smart 
            pointer classes designed to encapsulate COM interface pointers. 
            These pointers automatically perform <B>QueryInterface</B> instead 
            of a cast, and handle <B>AddRef</B> and <B>Release</B> for you. 
            Whether you should use them is largely a matter of taste. If your 
            code contains lots of copying of interface pointers, with multiple 
            <B>AddRefs</B> and <B>Releases</B>, then smart pointers can probably 
            make your code neater and less error prone. Otherwise, you can do 
            without them. Visual C++ includes a standard Microsoft COM smart 
            pointer, defined in the "comdef.h" header file (look up com_ptr_t in 
            the help).</P>
            <H4>I have trouble debugging my DirectX application, any tips?</H4>
            <P>The most common problem with debugging DirectX applications is 
            attempting to debug while a DirectDraw surface is locked. This 
            situation can cause a "Win16 Lock" on Microsoft Windows? 9<I>x</I> 
            systems, which prevents the debugger window from painting. 
            Specifying the D3DLOCK_NOSYSLOCK flag when locking the surface can 
            usually eliminate this. Windows 2000 does not suffer from this 
            problem. When developing an application, it is useful to be running 
            with the debugging version of the DirectX runtime (selected when you 
            install the SDK), which performs some parameter validation and 
            outputs useful messages to the debugger output.</P>
            <H4>What's the correct way to check return codes?</H4>
            <P>Use the SUCCEEDED and FAILED macros. DirectX methods can return 
            multiple success and failure codes, so a simple "==D3D_OK" or 
            similar test will not always suffice.</P>
            <H4>What happened to DirectDraw?</H4>
            <P>Much of the functionality of DirectDraw has now been subsumed 
            into the new Direct3D8 interfaces. Developers working on purely 2D 
            applications may wish to continue using the old DirectX 7 
            interfaces. Developers working on 3D applications with some 2D 
            elements are encouraged to use Direct3D alternatives (point sprites 
            and billboard textures, for example) as this will result in improved 
            performance and flexibility.</P>
            <H4>How do I disable ALT+TAB and other task switching?</H4>
            <P>You don't. Really.</P>
            <H4>Is there a recommended book explaining COM?</H4>
            <P><A href="http://mspress.microsoft.com/books/19.htm">Inside 
            COM</A> by Dale Rogerson, published by Microsoft Press, is an 
            excellent introduction to COM. For a more detailed look at COM, the 
            book <I>Essential COM</I> by Don Box, published by Longman, is also 
            highly recommended.</P>
            <H4>What books are there about general Windows programming?</H4>
            <P>Lots. However, the ones that are highly recommended are: 
            <UL type=disc>
              <LI><A 
              href="http://mspress.microsoft.com/books/2344.htm">Programming 
              Windows</A> by Charles Petzold (Microsoft Press)<BR><BR>
              <LI><A href="http://mspress.microsoft.com/books/1292.htm">Advanced 
              Windows</A> by Jeffrey Richter (Microsoft Press) </LI></UL>
            <H2><A name=directx8faq_topic2></A>Direct3D</H2>
            <H3><A name=directx8faq_topic3></A>General Questions</H3>
            <H4>Where can I find information about 3D graphics techniques?</H4>
            <P>The standard book on the subject is <I>Computer Graphics: 
            Principles and Practice</I> by Foley, Van Dam et al., and is a 
            valuable resource for anyone wanting to understand the mathematical 
            foundations of geometry, rasterization, and lighting techniques. The 
            FAQ for the comp.graphics.algorithms Usenet group also contains 
            useful material.</P>
            <H4>Does Direct3D emulate functionality not provided by 
            hardware?</H4>
            <P>It depends. Direct3D has a fully featured software vertex 
            processing pipeline (including support for custom vertex shaders). 
            However, no emulation is provided for pixel level operations; 
            applications must check the appropriate caps bits and use the 
            ValidateDevice API to determine support.</P>
            <H4>Is there a software rasterizer included with Direct3D?</H4>
            <P>No. Direct3D now supports plug-in software rasterizers. However, 
            there is currently no software rasterizer supplied by default.</P>
            <H4>Does the Direct3D geometry code utilize 3DNow! and/or Pentium 
            III SIMD instructions?</H4>
            <P>Yes. The Direct3D geometry pipeline has several different code 
            paths, depending on the processor type, and will utilize the special 
            floating-point operations provided by the 3DNow! or Pentium III SIMD 
            instructions where these are available. This includes processing of 
            custom vertex shaders.</P>
            <H4>How do I prevent transparent pixels being written to the 
            z-buffer?</H4>
            <P>You can filter out pixels with an alpha value above or below a 
            given threshold. You control this behavior by using the renderstates 
            ALPHATESTENABLE, ALPHAREF, and ALPHAFUNC.</P>
            <H4>What is a stencil buffer?</H4>
            <P>A stencil buffer is an additional buffer of per-pixel 
            information, much like a z-buffer. In fact, it resides in some of 
            the bits of a z-buffer. Common stencil/z-buffer formats are 15-bit z 
            and 1-bit stencil, or 24-bit z and 8-bit stencil. It is possible to 
            perform simple arithmetic operations on the contents of the stencil 
            buffer on a per-pixel basis as polygons are rendered. For example, 
            the stencil buffer can be incremented or decremented, or the pixel 
            can be rejected if the stencil value fails a simple comparison test. 
            This is useful for effects that involve marking out a region of the 
            frame buffer, and then performing rendering only the marked (or 
            unmarked) region. Good examples are volumetric effects like shadow 
            volumes.</P>
            <H4>How do I use a stencil buffer to render shadow volumes?</H4>
            <P>The key to this, and other volumetric stencil buffer effects, is 
            the interaction between the stencil buffer and the z-buffer. A scene 
            with a shadow volume is rendered in three stages. First, the scene 
            without the shadow is rendered as usual, using the z-buffer. Next, 
            the shadow is marked out in the stencil buffer as follows. The front 
            faces of the shadow volume are drawn using invisible polygons, with 
            z-testing enabled but z-writes disabled, and the stencil buffer 
            incremented at every pixel passing the z-test. The back faces of the 
            shadow volume are rendered similarly, but decrementing the stencil 
            value instead. </P>
            <P>Now, consider a single pixel. Assuming the camera is not in the 
            shadow volume there are four possibilities for the corresponding 
            point in the scene. If the ray from the camera to the point does not 
            intersect the shadow volume, then no shadow polygons will have been 
            drawn there and the stencil buffer is still zero. Otherwise, if the 
            point lies in front of the shadow volume the shadow polygons will be 
            z-buffered out and the stencil again remains unchanged. If the 
            points lies behind the shadow volume then the same number of front 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -