·天新网首页·加入收藏·设为首页·网站导航
数码笔记本手机摄像机相机MP3MP4GPS
硬件台式机网络服务器主板CPU硬盘显卡
办公投影打印传真
家电电视影院空调
游戏网游单机动漫
汽车新车购车试驾
下载驱动源码
学院开发设计
考试公务员高考考研
业界互联网通信探索
您现在的位置:天新网 > 软件开发 > 游戏开发
Direct3D vs. OpenGL: A Comparison
http://www.21tx.com 2002年06月28日 Blog joykidd

Direct3D vs. OpenGL: A Comparison

Summary

This page is an informal attempt to summarize the main differences between SGI's OpenGL and Microsoft's Direct3D. First, each API is summarized in an attempt to bring a balanced presentation of the two APIs. Then a feature comparison is made between the capabilities of OpenGL and Direct3D.

Unless otherwise noted, "OpenGL" refers to the OpenGL 1.2 core with no extensions and "Direct3D" refers to Direct3D8, the Direct3D interface in DirectX 8. When a difference between Direct3D7 and Direct3D8 is noteworthy, version numbers are given.

Intended Audience

This document assumes that the reader is familiar with the architecture of a traditional 3D graphics pipeline as commonly used with scanline rendering techniques. For more information on such architectures, the reader is encouraged to consult a 3D graphics text such as "3D Computer Graphics" by Alan Watt and Mark Watt. This is only one book of many 3D graphics books, the interested reader is encouraged to browse a good technical bookstore and find one that speaks to them most effectively.

SGI's OpenGL

SGI's OpenGL is a procedural 3D graphics API, the successor to Iris GL which originated in the Unix workstation market. Iris GL is the graphics API used on a succession of 3D graphics workstations designed and built by Silicon Graphics, Inc.

"OpenGL" is a trademark of the OpenGL Architectural Review Board (ARB). The ARB controls the definition of OpenGL through control of the specification by which an implementation may call itself "OpenGL". The specification is an English prose document with associated mathematics that define the semantics of the API. The ARB also governs a suite of conformance tests that serve as a validation suite for an implementation.

The ARB was formed in 1992 and functions under a set of bylaws to revise and oversee the specification of the API.

OpenGL defines a state machine that controls the rendering pipeline. State machine attributes are modified through procedure calls and vertices defining graphic primitives are specified to the pipeline through procedure calls.

Only the OpenGL 1.2 core is considered in this document, not extensions.

Microsoft's Direct3D

Microsoft's Direct3D is a COM based 3D graphics API originating in a third-party 3D graphics API for x86 architectures. Microsoft acquired the technology in 1996 and has been offering the API as a component of its DirectX technology. Direct3D contains an immediate-mode interface and a strctured hierarchical scene graph interface called retained mode. Only the immediate-mode interface is considered in this document.

Microsoft defines the Direct3D API through its COM interfaces, and the semantics are defined by the the help files and sample code accompanying the software development kit provided by Microsoft.

Direct3D first appeared in DirectX 3 with execute buffers as its display paradigm. All subsequent releases, beginning with DirectX 5 (there was no DirectX 4), replaced execute buffers with a more traditional graphics primitive display paradigm.

Feature Comparison

OpenGL and Direct3D both expose a traditional graphics rendering pipeline. This basic pipeline design has been present since the earliest days of computer graphics and has been enhanced and extended over the years as hardware has become more capable, but the fundamental paradigm has not changed.

Vertices are described to the pipeline as a bundle of data consisting of coordinates in space defining the vertex's location and associated per-vertex data. A graphics primitive is described to the pipeline as an ordered set of vertices. How vertices are combined into various primitives -- generally points, lines and triangles -- is defined by the particular API.

Rather than provide an exhaustive list of features where both OpenGL and Direct3D provide the same feature, I will list the differences.

Feature OpenGL 1.2 Core Direct3D 7 Direct3D 8
System Mechanics
Operating System Support Windows (9x, NT, 2000), MacOS, BeOS, *nix, others Windows (9x, 2000, CE) [12] Windows (9x, 2000) [12]
API Definition Control OpenGL ARB Microsoft Microsoft
API Specification OpenGL Specification [10] SDK/DDK Documentation and DDK Reference SDK Documentation
API Mechanism includes and libraries COM COM
Software Emulation of Unaccelerated Features [4] Yes No No [11]
Extension Mechanism [5] Yes No Yes
Source Implementation Available [6] Yes Yes No
Modeling
Fixed-Function Vertex Blending No Yes Yes
Programmable Vertex Blending No No Yes
Parametric Curve Primitives Yes No Yes
Parametric Surface Primitives Yes No Yes
Hierarchical Display Lists Yes No [8] No [8]
Rendering
Two-sided Lighting Yes No [1] No [1]
Point Size Rendering Attributes [9] Yes No Yes
Line Width Rendering Attributes [9] Yes No No
Programmable Pixel Shading No [14] No Yes
Triadic Texture Blending Operations No No Yes
Cube Environment Mapping No Yes Yes
Volume Textures Yes No Yes
Multitexture Cascade No [13] Yes Yes
Texture Temporary Result ReGISter No No Yes
Mirror Texture Addressing No Yes Yes
Texture "Wrapping" No Yes Yes
Range-Based Fog No Yes Yes
Bump Mapping No Yes Yes
Modulate 2X Texture Blend No Yes Yes
Modulate 4X Texture Blend No Yes Yes
Add Signed Texture Blend No Yes Yes
Frame Buffer
Hardware Independent Z Buffer Access Yes No [2] No [2]
Full-Screen Antialiasing Yes Yes Yes
Motion Blur Yes No Yes
Depth of Field Yes No Yes
Accumulation Buffers Yes No No [7]
Miscellaneous
Picking Support Yes No [3] No [3]
Multiple Monitor Support No Yes Yes
Stereo Rendering Yes Yes No

Notes:

  1. Two-sided lighting can be emulated by an application that desires two-sided polygon surfaces. First, the application sets the pipeline to cull back facing polygons and draws the front side of all two-sided polygons. Next, the pipeline is set to cull front facing polygons and the application draws the back side of all two-sided polygons.
  2. Access to the Z buffer is provided, but the values stored in the Z buffer are hardware dependent.
  3. Picking can be done entirely in the application by traversing its own data structures.
  4. OpenGL provides software emulation when hardware cannot accomodate the requested feature to guarantee that a rendering feature will exist. Direct3D exposes extensive information about hardware capabilities and lets the application determine how to obtain the requested feature.
  5. OpenGL provides an extension mechanism for an implementation to expose additional features not yet adopted by the ARB. Direct3D7 has one implementation with no extension mechanism. Direct3D8 has one implementation and provides support for pluggable software devices.
  6. An open source sample implementation of OpenGL is available. Microsoft's Windows 2000 DDK (driver development kit) contains the reference rasterizer for Direct3D 7.
  7. Multisampling is provided Direct3D8, but not as an accumulation buffer. This allows Direct3D8 to perform full-screen antialiasing, depth of field and motion blur effects without providing an accumulation buffer.
  8. Hierarchical display lists are not provided by Direct3D, but Direct3D does provide storage for polygon vertices and vertex indices to avoid data copying. These are flat array-like storages consisting only of geometry data and no state changes. State changes may be aggregated into state blocks for efficient transmission to the device. Neither state blocks, nor index buffers nor vertex buffers are hierarchical.
  9. Point and line width attributes can be emulated by drawing textured triangles (for points) or quadrilaterals (for lines) when the size of the point or line is significant. This also provides the application with more control over the exact rendering of these large points and thick lines. This additional control over rendering may be important for OpenGL applications even though OpenGL provides point and line rendering attributes.
  10. OpenGL's specification, while still being an English prose specification, is more rigorously defined than Direct3D.
  11. Direct3D8 provides software emulation for vertex processing (blending, vertex shaders, fixed-function vertex processing, etc.), but not for pixel processing (pixel shaders, multitexturing, etc.).
  12. Windows NT 4 only supports DirectX 3.
  13. Multitexture cascade is provided in OpenGL 1.2 through an ARB extension. While still an extension and not part of the official 1.2 core, it is expected to be widely implemented as it is a "standard" extension and not a vendor extension.
  14. Programmable pixel shading is provided by some vendors in OGL through the register combiner vendor extension.

In several ASPects, a comparison between OpenGL and Direct3D is similar to a comparison between OpenGL and PEX. Many of the same differences exist for Direct3D.


Last modified: May 2001

上一篇: 捡金豆游戏源代码
下一篇: 汉诺塔的源程序

关于我们 | 联系我们 | 加入我们 | 广告服务 | 投诉意见 | 网站导航
Copyright © 2000-2011 21tx.com, All Rights Reserved.
晨新科技 版权所有 Created by TXSite.net