Search Tips Advanced Search |
| Delphi Graphics and Game Programming Exposed with DirectX 7.0 by John Ayres Wordware Publishing, Inc. ISBN: 1556226373 Pub Date: 12/01/99
Search this book:
Previous | Table of Contents | Next
2. It must offer true pointer access to memory. As with C/C++, it’s quite easy in Delphi to create a pointer, point it to some location in memory, and commence reading or writing as necessary. Like C/C++, Delphi also allows you to perform pointer arithmetic, moving the location to which the pointer points. This is a very powerful technique which, when used incorrectly, can cause spectacular system-wide crashes. C/C++ does not have any advantages over Delphi when it comes to using pointers. 3. It must offer the ability to manage memory allocation. This goes hand in hand with the ability to use pointers. Game applications typically push the limit on the hardware, and some must specifically manage the memory used by the application in order to realize maximum performance. Like C/C++, Delphi offers many ways to allocate memory, from the automatic memory management offered by the VCL, all the way to Pascal commands for memory management and Windows API functions for allocating and deallocating memory. 4. It must offer full access to operating system resources. Again, just like C/C++, Delphi has full, open access to the entire Windows API. Indeed, Delphi can use any DLL or type library to which it has an import unit. This is one area where C/C++ does have an advantage over Delphi. Since Windows is written in C/C++, DLLs and other resources created by Microsoft and other third-party developers typically have header units for C/C++ access before someone translates it into a Delphi unit. However, thanks to the efforts of the JEDI Project and other individuals, Delphi import units for hundreds of APIs are becoming available to the general public. Typically, Delphi will probably always be one step behind on access to the latest technologies. However, it’s not too difficult a task to convert C/C++headers into Delphi units, and you can usually find the converted unit on the Web or buy one from a Delphi vendor. Most people will argue that there are several more attributes by which a development language must be judged before determining if it is a viable games development platform. As we’ve discussed, Delphi meets or exceeds all expectations for the above requirements, and could probably do the same for any other requirement that one could think of. Pascal is an old language; it’s been around for quite a while, and is mature, stable, and proven. It’s unfortunate that many people still think of Pascal as a beginner’s language, fit for little more than hobby applications. This is probably due to the irrational Western mentality that if something looks complex, or if it is hard to understand, it must be powerful. Bear in mind that a high-level language like C/C++ or Pascal is just an interface to assembly language that is easier for humans to understand. Each language has a few small advantages over the other, but ultimately an application written in either language is transformed into a final assembly language form. The only differences lay in how this transformation is accomplished by the compiler, and Delphi’s compiler can create assembly language that competes with the best of them. #### Delphi as a Games Development Platform So, Delphi is indeed a viable game development platform. What, then, can we expect to encounter when developing a game using Delphi? Delphi’s incredible debugging features will be almost unusable if you are creating a DirectX game, primarily because of how DirectX monkeys with the display hardware. However, certain aspects of how the VCL encapsulates the Windows API will take a lot of the drudgery out of DirectX programming, and will indeed make some tasks extremely easy. Most notably, the TBitmap object will be very useful for loading graphics into DirectX memory blocks, and the TCanvas object can be quite handy when performing standard GDI functions, such as outputting text to the screen. Of course, if you will be using Delphi to create non-DirectX games, the full power of the debugging features as well as the GDI encapsulation will make the task of programming a game just as easy as that of developing a database application. In this book, we will focus on creating DirectX games, and we will examine how the VCL can make some aspects of DirectX programming almost trivial. As a whole, Delphi offers many advantages over other game development platforms. Every language has advantages and disadvantages over every other, which is why there are so many languages to choose from. While the following discussion is by no means an exhaustive look at Delphi versus C/C++, Delphi does have some specific advantages and disadvantages when compared to C/C++ that merit further investigation. Advantages This is a truly opinionated and arguable statement, but Delphi’s Object Pascal is a much better language than C/C++ for two reasons: It is not as arcane, and it is much stronger typed. While it is possible to write easily understandable code in C/C++, it is just as easy to write code that is completely unintelligible and unmanageable. C/C++ has a precompiler that allows one to redefine function names (among other things). While this can be quite useful in some instances, if used indiscriminately it can lead to a major headache when trying to decipher what a piece of code accomplishes. C/C++ has many other language constructs that allow one to write very archaic instructions decipherable only by its author or a C/C++ guru. The primary reason this is important is because, in today’s development shops, a section of code may be written by one programmer but modified or updated by several others. It is an incredible waste of time and energy if a programmer tasked with the responsibility of updating a section of code has to spend several hours just determining what it does. The archaic quality of C/C++ code, which can be worsened by arrogant or apathetic programmers, tends to make the arduous task of modifying existing code very difficult, if not impossible. Alternatively, Pascal syntax is closer to regular English, and although it is possible to write some very arcane Pascal code, it is typically much easier to understand from a glance than C/C++. Some will argue that C/C++ was written by programmers for programmers, resulting in the greatly abbreviated lexical tokens perpetuating the language. While it is true that this may save a few keystrokes, in the opinion of this writer, Pascal syntax is much easier to understand from a brief glance and its format and construction make it much easier to decipher an algorithm from its implementation.
Previous | Table of Contents | Next

Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.