Programming Languages for 3d simulation and games

What language and programming environment should we use for 3d programming?

If you are a beginner to programming, see here.

What are the options? If we just want to display a 2d representation of the points it would be relatively easy to program in any reasonably efficient language such as either C++ or Java. If we want to display 3D graphics in real-time, for instance in a game or 3D simulation, then we need a language and environment that runs fast and we also need efficient 3D libraries.

Options:

  1. Use C++. There is quite a steep learning curve, because, not only do we have to learn C++ (the easy part!) we also have to understand the OpenGL library (GLUT) or Direct3d and any other libraries you may need.
  2. Use Java and Java3D - Much easier to learn, this is what I use, JBuilder6 is for Java, however the downside of this is that Java can run slower and it is more difficult to distribute Java applications to other people. There is a standard extension to Java which supports 3D display, this is Java3D.
  3. .Net languages such as C# or Visual Basic which (2003 versions/ net1.1) now support directX 9.
  4. Write the program as a script to drive VRML or the 3D program that you are using.

Graphics standards and class library's

For more information about this please see this open forum discussion


Commercial graphics and/or physics engines

Another option to consider, if if you have plenty of money to spend on the project is buying in a commercial graphics and/or physics engines, there would be royalties to pay.
To build a commercial game from scratch. This would allow you to put more of your time into the creative side, also these engines would come with interfaces for the different games platforms.

One possibility is the use of Quake III Arena (TM), which is a game engine for shoot-em type games, which uses OpenGL.

cover The 3D gamemaker - Allows simple 'shoot-em-up' type games to be built without any programming from the elements provided. You can use your own characters in the game, provided you can find a way to build them in Microsoft .X file format.


Java

Java is supported on many platforms such as Windows, UNIX, Linux, etc. The source code is compiled onto code which runs on a Java virtual machine (JVM). Sun provides virtual machines for the platforms supported.

The syntax of the language is derived from C.

This is much the most productive programming environment that I have used. The language and the class libraries are all integrated together, so everything feels integrated and works well together. Also features such as garbage collection and lack of pointers means that memory leaks and null pointer type problem are less likely.

There are some very good free development tools for Java, such as Eclipse and JBuilder7. I have put information about setting up Eclipse here.

At the moment Java does not have any built in support for displaying 3D. In order to use a 3D library such as OpenGL we need a java 'wrapper' which has some native code to call OpenGL. There are a number of possibilities:

At the moment there are some downsides to the use of Java for 3D.

Therefore Java is relatively easy for the developer, but not very practical for the end user.

books about Java3D

external links: http://www.javagaming.org/

cover JBuilder - There is also a free version of Jbuilder at borland website . However its licence conditions are quite restrictive so you may prefer another java IDE.


.NET

This is a Microsoft specific framework. Like Java it compiles to intermediate code. The advantage of .NET is that it allows you choose between C++, C#, Visual Basic and other languages, and even to mix these languages. There are some Linux versions such as mono, I don't know how complete or reliable they are or if they will catch on, however the choice of platforms is less than Java.

Programs written for this framework will be distributed as intermediate code (CLI = Common Language Infrastructure). This is interpreted (or more accuately just-in-time compiled) when run.

The original 2002 versions of these programs do not have a library which supports activeX or OpenGL, so the only way to use these versions is to use anOpenGL .NET wrapper which can be included in your .NET program as an axHost component.

The 2003 versions of these programs (.net version 1.1) now support directX 9 without the need for any 3rd party plugins.

The 2005 versions of these programs now use .net version 2.0. This means that the code built using the 2005 versions will only run on PCs with .net 2.0 installed.

C#

cover Visual C# .NET for Microsoft Platforms only.

This is a Microsoft language that uses the ideas from Java. For instance it uses a virtual machine and a garbage collector. The main difference is that the intermediate code (CLI = Common Language Infrastructure) is not so closely tied to C#, so the virtual machine can be used by other languages.

There are different ways to write code using C# such as:

.Net Game Programming with C#

cover Introduction to 3D Game Engine Design Using DirectX 9 and C# (Net Developer)

Tutorial - Using C# to write a 2D game


C++

cover Visual C++ .NET for Microsoft Platforms only.

C++ tends to be the language of choice for games programmers.

C++ and C tends to be complied directly to the machine language of the platform being used. Also C and C++ allows you to write in a way that is quite close to most machine code (incrementing pointers, etc.). Because of these things the code produced can be very efficient and run very fast. However is is very easy to create bugs, such as not releasing resources leading to memory leaks, or not setting pointers properly, etc.

There is a very steep learning curve for the programmer, who has to learn the language itself, the libraries, whatever 3D library is used, also any libraries for interface components. These libraries don't always 'join up' and so it takes a long time to learn where everything is, and in some cases the libraries may not do what you want and you may have to resort to understanding the APIs used and calling them directly. However there is not much you cant do in C++ if you can master the complexity.

So there are a lot of choices to be made about what platform and what class framework to use. These choices include:

Because most PCs already have have the code for the 3D libraries installed, programs compiled from C++ to the native platform can be much easier for the user to install than Java programs. The user only has to download the code itself from the web in the form of an .EXE file and and run it. Provided they trust the site where the code came from!


Machine Code

If you want really fast and efficient code then, you might be able to code it yourself using an assembler to produce faster code than a compiler would produce.

It would only be worth doing this for time critical parts of the program that are run frequently.

One example, where writing machine code by hand might help is to make use of the machine code extensions intended for 3D. These are SIMD Single Instruction Multiple Data instructions such as MMX and 3Dnow, which can do multiple integer or floating point operations at a time.


Visual Basic

cover Visual Basic .NET for Microsoft Platforms only.
cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

 

Visual Basic is easier to learn than some other languages but it may not be as well structured, and may not scale up so well as the program gets bigger. It may be either interpreted or compiled, but it will not produce such efficient code as C++. 3D libraries such as Direct3D can be called by the use of ActiveX components.

Microsoft Express 2005 edition, is free for a year (at the time of writing). However it is a very large download and reqires .net 2.0 on any machines which run the code.


metadata block
see also:
Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Introduction to 3D Game Engine Design Using DirectX 9 and C# (Net Developer)

cover This explains how to program using the managed extensions to C++.

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover Visual C++ .NET for Microsoft Platforms only.

cover The 3D gamemaker - Allows simple 'shoot-em-up' type games to be built without any programming from the elements provided. You can use your own characters in the game, provided you can find a way to build them in Microsoft .X file format.

Other commercial game generation software for home use

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2014 Martin John Baker - All rights reserved - privacy policy.