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

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

📁 csdn10年中间经典帖子
💻 HTM
📖 第 1 页 / 共 4 页
字号:
              and provide a mechanism for recording a series of state changes 
              (including lighting, material and matrix changes) into a macro, 
              which can then be replayed by a single call. This has two 
              advantages: 
              <OL>
                <LI>You reduce the call overhead by making one call instead of 
                many.<BR><BR>
                <LI>An aware driver can pre-parse and pre-compile the state 
                changes, making it much faster to submit to the graphics 
                hardware. </LI></OL>
              <P class=tl>State changes can still be expensive, but using state 
              macros can help reduce at least some of the cost.</P>
              <LI><B>Use only a single Direct3D device</B>. If you need to 
              render to multiple targets, use <B>SetRenderTarget</B>. If you are 
              creating a windowed application with multiple 3D windows, use the 
              <B>CreateAdditionalSwapChain</B> API. The runtime is optimized for 
              a single device and there is a considerable speed penalty for 
              using multiple devices. </LI></UL>
            <H4>Which primitive types (strips, fans, lists, and so on) should I 
            use?</H4>
            <P>Many meshes encountered in real data feature vertices that are 
            shared by multiple polygons. To maximize performance it is desirable 
            to reduce the duplication in vertices transformed and sent across 
            the bus to the rendering device. It is clear that using simple 
            triangle lists achieves no vertex sharing, making it the least 
            optimal method. The choice is then between using strips and fans, 
            which imply a specific connectivity relationship between polygons, 
            and using indexed lists. Where the data naturally falls into strips 
            and fans, these are the most appropriate choice, since they minimize 
            the data sent to the driver. However, decomposing meshes into strips 
            and fans often results in a large number of separate pieces, 
            implying a large number of DrawPrimitive calls. For this reason, the 
            most efficient method is usually to use a single 
            DrawIndexedPrimitive call with a triangle list. An additional 
            advantage of using an indexed list is that a benefit can be gained 
            even when consecutive triangles only share a single vertex. In 
            summary, if your data naturally falls into large strips or fans, use 
            strips or fans; otherwise use indexed lists.</P>
            <H4>What's a good usage pattern for vertex buffers if I'm generating 
            dynamic data?</H4>
            <OL>
              <LI>Create a vertex buffer using the D3DUSAGE_DYNAMIC and 
              D3DUSAGE_WRITEONLY usage flags, and the D3DPOOL_DEFAULT pool flag. 
              (Also specify D3DUSAGE_SOFTWAREPROCESSING if you are using 
              software vertex processing.)<BR><BR>
              <LI>I = 0.<BR><BR>
              <LI>Set state (textures, renderstates, and so on).<BR><BR>
              <LI>Check if there is space in the buffer, that is, i.e. I + M 
              &lt;= N? (Where M is the number of new vertices).<BR><BR>
              <LI>If yes, then Lock the VB with D3DLOCK_NOOVERWRITE. This tells 
              Direct3D and the driver that you will be adding vertices and won't 
              be modifying the ones that you previously batched. Therefore, if a 
              DMA operation was in progress, it isn't interrupted. If no, goto 
              11.<BR><BR>
              <LI>Fill in the M vertices at I.<BR><BR>
              <LI>Unlock.<BR><BR>
              <LI>Call Draw[Indexed]Primitive. For non-indexed primitives use I 
              as the <B>StartVertex</B> parameter. For indexed primitives, 
              ensure the indices point to the correct portion of the vertex 
              buffer (it may be easiest to use the <B>BaseVertexIndex</B> 
              parameter of the SetIndices call to achieve this).<BR><BR>
              <LI>I += M.<BR><BR>
              <LI>Goto 3.<BR><BR>
              <LI>Ok, so we are out of space, so let us start with a new VB. We 
              don't want to use the same one because there might be a DMA 
              operation in progress. We communicate to this to Direct3D and the 
              driver by locking the <I>same</I> VB with the D3DLOCK_DISCARD 
              flag. What this means is "you can give me a new pointer because I 
              am done with the old one and don't really care about the old 
              contents any more."<BR><BR>
              <LI>I = 0.<BR><BR>
              <LI>Goto 4 (or 6). </LI></OL>
            <H3><A name=directx8faq_topic6></A>Direct3DX Utility Library</H3>
            <H4>What file formats are supported by the D3DX image file loader 
            functions?</H4>
            <P>The D3DX image file loader functions support BMP, TGA, PNG, JPG, 
            DIB, PPM, and DDS files.</P>
            <H4>The text rendering functions in D3DX don't seem to work, what am 
            I doing wrong?</H4>
            <P>A common mistake when using the <B>ID3DXFont::DrawText</B> 
            functions is to specify a zero alpha component for the color 
            parameter; resulting in completely transparent (that is, invisible) 
            text. For fully opaque text, ensure that the alpha component of the 
            color parameter is fully saturated (255).</P>
            <H4>Should I use ID3DXFont or the SDK framework CD3DFont class for 
            font rendering?</H4>
            <P>The <B>ID3DXFont</B> class is capable of handling kerning and 
            complex international fonts because it uses GDI to draw the string. 
            It can therefore be a little slow since it needs to invoke GDI each 
            time.</P>
            <P><B>CD3DFont</B> is designed for speed and uses textured 
            primitives to draw the characters. It can only handle simple fonts 
            and does not support the full array of formatting options available 
            to <B>ID3DXFont</B>, but is useful for simple fast displays such as 
            framerate counters and so forth.</P>
            <P>For production code, you may well want to implement your own font 
            rendering using textured primitives and/or a GDI based scheme with 
            caching to avoid re-drawing.</P>
            <H2><A name=directx8faq_topic7></A>DirectSound</H2>
            <H4>Why do I get a burst of static when my application starts up? I 
            notice this problem with other applications too.</H4>
            <P>You probably installed the debug DirectX runtime. The debug 
            version of the runtime fills buffers with static in order to help 
            developers catch bugs with uninitialized buffers. You cannot 
            guarantee the contents of a DirectSound buffer after creation; in 
            particular, you cannot assume that a buffer with be zeroed out.</P>
            <H2><A name=directx8faq_topic8></A>DirectPlay</H2>
            <H4>How do I ensure my game will work properly with Network Address 
            Translators (NATs) and Internet Connection Sharing (ICS) 
setups?</H4>
            <P>NATs and ICS are complex topics that are covered in greater 
            detail in a <A 
            href="http://msdn.microsoft.com/library/techart/Nats2-msdn.htm">separate 
            article</A> on MSDN. However, the following tips are good general 
            guidelines: 
            <UL type=disc>
              <LI>Use a client-server, not peer-to-peer network topology, using 
              the <B>IDirectPlay8Client</B> and <B>IDirectPlay8Server</B> 
              interfaces.<BR><BR>
              <LI>Host servers on the clear Internet, not behind a NAT.<BR><BR>
              <LI>Enumerate the game port directly, without using 
DPNSVR.<BR><BR>
              <LI>Do not embed IP addresses or port numbers in your messages. 
              </LI></UL>
            <P>For issues regarding peer-to-peer games, hosting servers behind 
            NATs, and specific advice for ICS on various different Windows 
            operating systems, refer to the more detailed documentation.</P>
            <H4>What is DPNSVR for?</H4>
            <P>DPNSVR is a forwarding service for enumeration requests that 
            eliminates problems caused by conflicts between port usages for 
            multiple DirectPlay applications. Using DPNSVR allows DirectPlay to 
            select the port to use automatically, while allowing clients to 
            enumerate your game. By default, DirectPlay will use DPNSVR as this 
            generally provides the most flexibility for applications; however, 
            you can disable it by specifying the DPNSESSION_NODPNSVR flag when 
            you create your session. The use of DPNSVR can cause some issues 
            with NATs on the client-side, specifically, if the client enumerates 
            the host using the DPNSVR port, and the host responds using its own 
            port the NAT may deny forwarding the packet to the client because it 
            didn't come from the same port the request was send to.</P>
            <H4>Why does IDirectPlay8LobbyClient::Initialize return 
            DPNERR_NOTALLOWED?</H4>
            <P>DirectPlay does not allow more than one lobby client or 
            application per process and attempting to create multiple clients 
            will cause this error to be returned.</P><!--FOOTER_START-->
            <P>&nbsp;</P><FONT size=1>
            <P>&nbsp;</P></FONT><!--FOOTER_END--><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center bgColor=#006699 border=0 cellPadding=0 cellSpacing=0 
width=770>
  <TBODY>
  <TR bgColor=#006699>
    <TD align=middle bgColor=#006699 id=white><FONT 
    color=#ffffff>对该文的评论</FONT></TD>
    <TD align=middle>
      <SCRIPT src="CSDN_文档中心_DirectX 8 开发者常见问题集.files/readnum.htm"></SCRIPT>
    </TD></TR></TBODY></TABLE><BR>
<DIV align=center>
<TABLE align=center bgColor=#cccccc border=0 cellPadding=2 cellSpacing=1 
width=770>
  <TBODY>
  <TR>
    <TH bgColor=#006699 id=white><FONT 
color=#ffffff>我要评论</FONT></TH></TR></TBODY></TABLE></DIV>
<DIV align=center>
<TABLE border=0 width=770>
  <TBODY>
  <TR>
    <TD>你没有登陆,无法发表评论。 请先<A 
      href="http://www.csdn.net/member/login.asp?from=/Develop/read_article.asp?id=3954">登陆</A> 
      <A 
href="http://www.csdn.net/expert/zc.asp">我要注册</A><BR></TD></TR></TBODY></TABLE></DIV><BR>
<HR noShade SIZE=1 width=770>

<TABLE border=0 cellPadding=0 cellSpacing=0 width=500>
  <TBODY>
  <TR align=middle>
    <TD height=10 vAlign=bottom><A 
      href="http://www.csdn.net/intro/intro.asp?id=2">网站简介</A> - <A 
      href="http://www.csdn.net/intro/intro.asp?id=5">广告服务</A> - <A 
      href="http://www.csdn.net/map/map.shtm">网站地图</A> - <A 
      href="http://www.csdn.net/help/help.asp">帮助信息</A> - <A 
      href="http://www.csdn.net/intro/intro.asp?id=2">联系方式</A> - <A 
      href="http://www.csdn.net/english">English</A> </TD>
    <TD align=middle rowSpan=3><A 
      href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010"><IMG 
      border=0 height=48 src="CSDN_文档中心_DirectX 8 开发者常见问题集.files/biaoshi.gif" 
      width=40></A></TD></TR>
  <TR align=middle>
    <TD vAlign=top>百联美达美公司 版权所有 京ICP证020026号</TD></TR>
  <TR align=middle>
    <TD vAlign=top><FONT face=Verdana>Copyright &copy; CSDN.net, Inc. All rights 
      reserved</FONT></TD></TR>
  <TR>
    <TD height=15></TD>
    <TD></TD></TR></TBODY></TABLE></DIV>
<DIV></DIV><!--内容结束//--><!--结束//--></BODY></HTML>

⌨️ 快捷键说明

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