42 lines
4.8 KiB
HTML
42 lines
4.8 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<title>Writing 3D Applications</title>
|
|
</head>
|
|
|
|
<body bgcolor=#000000 text=#FFFFFF link=#FF0000 vlink=#FFFF00>
|
|
<basefont face="Times New Roman" size=3>
|
|
|
|
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
|
|
|
|
|
|
<BLOCKQUOTE>
|
|
<FONT FACE="arial" SIZE="2">
|
|
<!--DocHeaderEnd-->
|
|
<!-- This is a PANDA Generated HTML file. The source is a WinWord Document. -->
|
|
<h2>Writing Direct3D Apps for Hardware Accelerators: The BeginScene()/EndScene() API Calls</h2>
|
|
<P>The DirectX Team
|
|
<P>August 2, 1996
|
|
<P><h4>Introduction</H4>
|
|
<P>Proper use of Direct3D's <b>BeginScene()</b> and <b>EndScene()</b> is essential to making your application work properly with hardware 3-D accelerators. This article describes the operation of <b>BeginScene()</b> and <b>EndScene()</b> and gives guidelines for their use. Failure to follow these guidelines may cause your application to render incorrectly on a broad class of forthcoming 3-D hardware.
|
|
<P><h4>Definition</H4>
|
|
<P>A <i>scene</i> in the Direct3D immediate mode is a collection of all the vertices and drawing primitives (triangles, lines, and points) used to draw a single frame. <b>BeginScene()</b> marks the beginning of a scene (and hence the start of a frame) and <b>EndScene()</b> marks the end of a scene (and hence the end of the frame).
|
|
<P>In keeping with this definition, it is essential that all the execute buffer executions used to draw a single frame be bracketed by a single <b>BeginScene()</b>/<b>EndScene()</b> pair.
|
|
<P><h4>Justification</H4>
|
|
<P>Correct use of <b>BeginScene()</b> and <b>EndScene()</b> is important to support a class of emerging 3-D hardware accelerators which do not use a conventional z-buffer to perform hidden surface removal. Such accelerators may implement a number of mechanisms for performing hidden surface removal (such as internal tiling and polygon sorting). However, to perform hidden surface removal, they all must process a copy of the entire geometric database for a single frame.
|
|
<P>To accomplish this task, such accelerators must perform <i>Scene Capture</i>. In other words, they must store, for later processing, the geometric information passed to them via execute buffers.To ensure the hidden surface processing is correct, a single <b>BeginScene()</b> and <b>EndScene()</b> must bracket <b>all</b> the drawing instructions comprising a single frame. If multiple <b>BeginScene()</b> and <b>EndScene()</b> calls are made while composing a single frame, the accelerator will be unable to correctly resolve hidden surface interactions between triangles executed in different scene contexts.
|
|
<P>Furthermore, an application should not assume that multiple <b>BeginScene()</b>/<b>EndScene()</b> calls per frame are permissible simply because it knows there are no hidden surface interactions between the triangles in different scene contexts. Certain accelerators use scene capture to perform high-quality rendering effects in addition to hidden surface removal. For example, a scene-capturing accelerator may be able to render shadows and semitransparent objects. These effects rely on the entire geometric database for a frame being available to the accelerator for processing. Multiple <b>BeginScene()</b> and <b>EndScene()</b> contexts will break such effects.
|
|
<P><h4>2-D and 3-D Interaction</H4>
|
|
<P>Accelerators that perform scene capture probably will be unable to interleave 2-D drawing operations such as blits and direct writes with 3-D drawing operations in a scene context. Accelerators that have this restriction export the DirectDraw capability bit DDCAPS2_NO2DDURING3DSCENE. Therefore, an application should check this capability bit and, if it is present, not perform <b>DirectDraw Blt()</b>, <b>GetDC()</b>, or <b>Lock()</b> calls on the rendering surface between calls to <b>BeginScene()</b> and <b>EndScene()</b>.
|
|
<P><h4>What to Do</H4>
|
|
<P>To make sure that your application correctly renders on all 3-D accelerators (including those that perform scene capture), do the following:
|
|
<P>1. Ensure that all the execution of execute buffers that hold triangles (and other rendering primitives instructions) for a single frame are preceded by a single call to <b>BeginScene()</b> and followed by a single call to <b>EndScene()</b>.
|
|
<P>2. Check the DirectDraw caps bit DDCAPS2_NO2DDURING3DSCENE. If it is set, do not call DirectDraw's <b>Blt()</b>, <b>GetDC()</b> or <b>Lock()</b> functions on the rendering surface between a call to <b>BeginScene()</b> and <b>EndScene()</b>. Such 2-D operations can be performed after <b>EndScene()</b> has been invoked.
|
|
<P>3. Ensure that your application does not assume that any rendering primitives included in an execute buffer have been rendered to the target surface when <b>Execute()</b> returns. Scene capture cards will postpone rendering until the scene is complete (<b>EndScene()</b> has been called).
|
|
<P>
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|