News   Articles   Sources   Code libraries    RSS

Language:

English   Russia  

Current filter:

All   C#   C++   C  



Log in:

Name
Pass

Register

.NET File Explorer Control

Introduction to DirectX


Language:C++
Category:Multimedia
Date: 2008-09-11
Author:.NET File Explorer Control

Since the times when Microsoft was not yet a full-fledged operation system but just a shell to MS-DOS, the GDI had been the programming basis for graphics operations. It was initially a successful technology that made it possible to work with any type of video card. The PC platform employed a variety of video chips, each with different capabilities, and GDI offered a universal way to access their video functions. Even though the technology greatly improved, is still used in Windows.

While universality was definitely a plus, the video performance left a lot to be desired. When I played the Doom game for the first time, I wondered how the game could create such complex scenes on an x396 computer when Windows could not. Of course, the resolution used in the game was lower, but the scenes of the 3D world were more complex. This difference in performance occurs because with the GDI, applications cannot directly access the video card or the video buffer. Allowing them to do this would make it difficult to implement a multi-window system. And while the GDI’s universality is an advantage, it is also a shortcoming, because it does not allow the capabilities of a good video chip to be used to their full extent.

Thus, the slow graphics system made the Windows perform unusable for direct developing games. Even though there were developments directed at speeding up the graphics processing, the effect was much like flogging a dead horse.

To solve this problem, a fundamentally graphics-orientated applications programming interface (API) was needed that address the following main problem areas:

  • The graphics applications had to have direct access to the video memory to force execution;
  • The video card capabilities had to be used to their full capacity, especially since the introduction of video accelerators was just around the corner. The letter became a standard feature, and modern computer video cards are also equipped with eccelerator functions;
  • The graphics applications had have maximum access to processor resources. Windows is a multithread and multi-window OS, which is unacceptable for games. Running the application in the full-screen mode makes the processor service this application only.

All of these issues were addressed quite efficiently by the DirectX graphics API. This interface is allocated the maximum amount of computer resources and is given direct access to the video buffer if the application runs in the full-screen mode. In my opinion, this is the easiest setup. If a process takes the entire screen, it can be given more resources then if it runs in a window. In the latter case, the OS has to draw everything in background, and graphics is the program’s week spot.

The most difficult task is fully using the video chip’s capabilities. Today PCs are equipped with video cards based on NVIDIA GeForce, ATI Redeon, Matrox, and other video chips, which are not compatible. One video card may support one set of features, and another may support an entirely different set. Moreover, video chips with minimal graphical capabilities exist (e.g., Intel video chips). So how can universally be implemented in this situation? One approach could be to implement in DirectX only those capabilities supported be all video ships; however, something similar was attempted with the GDI, resulting in inferior performance. Another approach would be to implement only those functions considered necessary. However, such a program will not work on all computers, and problems with video cards will arise.

There are only two practical solutions to achieving universality:

  • Provide interface to all necessary features. If a capability is implemented in the video chip hardware, use it to get maximum productivity; otherwise; emulate it programmatically;
  • Implement only certain capabilities and force developers to adhere to the specification to achieve capabilities.

Initially, Microsoft chose the first approach, because video accelerators were expensive and far from all computers was equipped with them. The DirectX engine can work in the following modes:

  • Hardware abstraction layer (HAL) mode. The mode is used when the necessary capabilities are implemented in the chip’s hardware;
  • Hardware emulation layer (HEL) mode. This mode is used when the necessary function is not implemented in the chip’s hardware.

It is better to avoid the HEL mode in production application and use it only during the application development stage. Most modern video chips have hardware implementation for almost all DirectX functions, and there is no need to emulate them programmatically. Emulating complex effects places an overly heavy workload on the central processor, and it may not be able to handle the necessary calculations, resulting in slow graphics output.

In my opinion, DirectX is one of the best technologies for game developing.


Comments:

: Nice but small

Nice but too small. I think it might be more detailed.


Send your comment

Your name:
Vote:
Title:
Comment:
Protection code:





Submit an article   Submit a file

Copyright © HackishCode.com 2008. All rights reserved
WEB Design and WEB Development by WEB consulting company ProfWebDev.com
www.hackishcode.com