Game Programming


Game programming means graphics and sound programming. As mentioned in chapter 1, thisbook uses the Screaming Llama LlamaWorks2D game engine and the OpenGL graphics library. For sound, it uses OpenAL. OpenGL and OpenAL are industry standard tools that are well documented and widely available.

What is OpenGL?

The Open Graphics Library (OpenGL) was first invented at Silicon Graphics, Inc. many years ago. OpenGL is an open standard. That means it's a standard library worked out by an industry group. Everyone who creates a version of OpenGL conforms to the standard, so all versions of OpenGL on all types of computers work essentially the same way. The standard allows some differences, but you don't have to worry about them if you don't want to use the features they define.

OpenGL provides you and me with code to do the most important graphics tasks. For example, it enables our programs to easily draw bitmaps and geometric shapes (circles, rectangles, and so forth) into a game's back buffer. When the final frame is ready, our programs can easily switch the front and back buffers to display the frame on the screen.

Programming with OpenGL is not difficult. After a bit of introduction, you'll be using it like a pro. Unfortunately, one of the hardest tasks to accomplish when you're using OpenGL is to get it up and running under Windows. However, the LlamaWords2D game engine does that for you. All you have to do is pass the engine some startup information that I'll explain in chapter 3. The engine takes it from there.

Where Can I Get More Information on OpenGL and OpenAL?

Information on both OpenGL and OpenAL is available from many sources on the Web. Probably your best starting point for OpenGL information is www.opengl.org. This is the home page for the organization that maintains OpenGL. Here you'll find documentation, articles, and discussion forums where you can ask industry experts your OpenGL questions.

If you want documentation on how to use OpenGL with Windows, you can get it at www.msdn.microsoft.com/library/en-us/dnanchor/html/opengl.asp?frame=true.if that address is too long for you to type (it is for me too), you can find this documentation set by going to www.msdn.microsoft.com/library/default.asp and typing OpenGL in the Search box.

For information on OpenAL, I suggest you start with www.openal.org. This site contains documentation, example programs, and links to articles and other Web pages about OpenAL.


What is OpenAL?

Like OpenGL, the Open Audio Library (OpenAL) is an open standard. OpenAL enables our games to play and mix sounds. Mixing sounds is important for proper special effects. If you have two characters firing guns, you want to hear both bangs. To make that happen, your game has to mix the two sounds together in a memory buffer and then play the contents of the buffer.

With OpenAL, you can play music and special effects at the same time. When you get proficient with it, you can use OpenAL to do 3D sounds. For instance, if there's an explosion off to the player's left, you can get OpenAL to make the sound come from the left speaker. You can also do effects such as diminishing sounds over distance, echoing, and so on.

OpenGL, OpenAL, and DirectX

As mentioned in chapter 1, Microsoft provides a library that does graphics, sound, and other game-related tasks. It's called DirectX. The DirectX graphics library is called DirectX Graphics or Direct3D (Direct3D is by far the more common name). Its sound libraries are called DirectSound and DirectMusic.

Programmers new to game programming often ask, "Which is better, OpenGL and OpenAL or DirectX?"

If you're a beginner, "better" probably means "easier." In that case, OpenGL and OpenAL are by far the better choice. That's why we're using them in this book. DirectX is complex. There's nothing easy about it.

If you're a proficient C++ programmer with a background in graphics, DirectX is the better choice. It gives you cutting-edge graphics and sound. OpenGL and OpenAL are professional tools used in real games. However, they do not give the screaming performance and bleeding-edge graphics and sound that DirectX provides.

Many great games do not need cutting-edge graphics and sound. Professional games such as Blizzard Entertainment's WarCraft have long used 2D graphics. WarCraft, and games like it, do not depend on blindingly fast graphics and split-second player response times. You can write games just like it with OpenGL and OpenAL.

The long and short of all this is that OpenGL and OpenAL are a better place to start. If you then want to move to top-level graphics and sound, you'll have to learn DirectX. To be a professional game programmer generally requires a strong knowledge of both OpenGL/OpenAL and DirectX.



Creating Games in C++(c) A Step-by-Step Guide
Creating Games in C++: A Step-by-Step Guide
ISBN: 0735714347
EAN: 2147483647
Year: N/A
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net