What do I need to read to start making a math game

I have the graphics algorithms, etc for a math game, and I simulated a run in Mathematica, so I know all is OK. It involves a few geometrical figures which are transformed by a small number of transformations (xnew,ynew,znew) = function(x,y,z), a bit like a virtual Rubik’s cube for which the cubelets are rotated.

I need to implement these transforms in a selfstanding game and make them respond to some mouse click and drags, rather than preprogrammed as they are in my test run.

Say you wanted to build a virtual Rubik’s cube - what would you use to write it, and what documentation - books , on-line books - should I use? I am a mathematical physicist, and although I wrote cca 250000 lines of working code in Mathematica, much of it graphics, I have almost no experience with interactive environments. I wrote though maybe the most complex interactive mathematical machine in JavaLive by Martin Kraus - he recommended me to go to OpenGL. Besides Mathematica, I worked in Carrara and just got Maya.

People who saw the simulated game were really enthusiastic encouraging me to make it interactive, and I’d love to learn. How do I start?

Many thanks


PS Here is a 4D sculpture I made - virtually first, then from a ton of stainless steel, and a few animations

Can you provide a bit more information?

What language do you want to use? (Java?, C++?)
What sort of hardware and platforms do you want to run on? (Old video cards? Windows/ Linux?)
How many polygons are your intending to display?

Assuming C++,
Most people start out looking at the tutorials at NeHe ( http://nehe.gamedev.net/ )

But for a beginner project I would use a framework like GLUT (been around for ages) or GLFW http://glfw.sourceforge.net/ (newer)

As for books, most people will recommend “The Red Book” called “The OpenGL Programming Guide” http://www.opengl.org/documentation/red_book/

And you can use the Reference pages on this site (Useto be the Blue Book) http://www.opengl.org/sdk/docs/man/

Let me know if you have any trouble setting up as this project has me interested…

If you have little C++ and some Java experience, you will save yourself a lot of headache by programming your OpenGL game in Java. If you program by the specifications, it will run in a Java enabled browser or as a standalone application without problems in Windows, Linux, Mac, etc.

If you want to start from scratch and learn OpenGL details I suggest LWJGL (http://www.lwjgl.org). It basicly just provides the OpenGL API in your Java programs, and you will have to code many of the “trivial” things yourself (the advantage is that you retain full flexibility and learn the OpenGL API in details).

There are a few different options if you want to work in higher level API than standard OpenGL. That can obviously save you a lot of time. I suggest jMonkeyEngine (http://www.jmonkeyengine.com) or JOGL (https://jogl.dev.java.net).

For books I recommend:
OpenGL Superbible 4th OR OpenGL Programming Guide 5th

I have the previous edition of both and found both useful. Superbible has has more explanation but contains less API details. After having covered basic OpenGL, I find myself using OpenGL Programming Guide most of the time, for reference.

It is very possible to get by without a book and learning from examples like NeHe. However, I think you can save yourself some time by getting either of those books. Some of the NeHe tutorials are a bit outdated and doesn’t explain all the why’s and how’s.

kind regards,
Nicolai de Haan Brøgger

Thank you both so much! I’ll give it a try over the winter break.

Mathematica includes much of C among its commands, and very long time ago I was quite good at Pascal. I didn’t use directly Java, but a very talented young fellow from Germany, Martin Kraus, now computer science prof at TU Munchen, wrote a very small compiler which takes a simple kind of instructions in Mathematica, of type x becomes y (no cycles allowed) depending on a few dragged points, and graphics with parameters turned on or off, no lighting or anything fancy, and makes out of this a Java applet. http://www.vis.uni-stuttgart.de/~kraus/LiveGraphics3D/

I made with it a program showing the action of the quaternions as symmetry, interpreting every point 4D regular bodies as special symmetries of 3D regular bodies.

Until a few weeks ago the browsers on Apple computers were giving Java about 256k of RAM, so my Leonardo Machine (as I called it - it used the tetrahedron as drawn by Leonardo) was crashing the browser window every 5 minutes or so. This was apparently remedied in MacOS 10.5 and Java is finally extremely stable and snappy. I can send anyone interested the Leonardo Machine: it works in any browser.

Besides the 4D graphics game I was speaking about (which has modest needs: about 2000 rectangles) I have now finished the design stage of a mechanical device - old fashioned, with 25 spherical cogwheels, The Quaternion Machine in the Quaternion Room. In the 11 x 11 x 11 ft cubical room the visitor moves around the room a point P, which is a quaternion projected into 3D space. In the middle of the room a 5 ft diameter spherical machine turns a 2.5 ft cube, a model of the room, which lies inside the sphere, precisely as rotated by the quaternion in the hand of the viewer - the axis is OP and the angle is 4 arctan |OP|. When your hand with P is at the vertices of a hypercube, the inner cube aligns with the room; when you are on the edges of the hypercube, a diagonal of the inner cube aligns with the room.

Again I have the machine in Mathematica, I just made a short movie of it in motion, and would like to implement it (25 wheels @ 600 rectangles each + extras = 20k rectangles - not too bad.)

I love the fact that quaternions, which fell out fashion in math 100 years ago, are back in a big way in 3D animation and games. The Quaternion Machine would be the first mechanical device which transforms a point - the quaternion - which you move around into the corresponding rotation. What is tricky is that the rotation axis as well as the angle are variable. I am looking now for a donor for the Machine - as people are quite fascinated by 4 dimensions, I hope I’ll have a chance to have it made (non-virtually), just like the sculpture was made.

In more practical terms, I have bought a while ago “Teach yourself Java 2 in 21 days” Is that book OK? Is there anything with exercises online?

Many thanks,


There is now “Teach yourself Java 6 in 21 days”, however from a beginning programmer standpoint, the biggest difference you’d notice is “generics” and “type safe enums”.

Given your experience with Mathematica programming I would guess that the biggest leap to Java would be all of the object oriented programming concepts. Java can be easy to get up and running on many different systems but there are a lot of “gotchas” you have to get used to when moved from C or C++ to a pure OOP language.

That said, the easiest way to learn (my opinion) is to jump right in with a handy reference by your side. If you go the Java route, download JOGL (https://jogl.dev.java.net/) and check out the demos. A good reference would be Java in a Nutshell (http://www.oreilly.com/catalog/javanut5/).

If you want to skip the OOP stuff for now, then do check out GLUT (and those demos). It’s all C or (simple) C++ code. And the NeHe tutorials can also help here.