How to Continue

Discussion in 'Mac Programming' started by Fearless Leader, May 28, 2007.

  1. Fearless Leader macrumors 68020

    Mar 21, 2006
    Ok so i have pretty much mastered(? maybe not best word) the syntax, and the basics of c++ programming. I have recently dove into the world of opengl with glut. I can write simple terminal apps (like my rpn calc) or make triangles and squares rotate with fog.

    so onto my convoluted question...

    How do I go from simple little apps in terminal and drawing triangles to a game or a highly functional app.
  2. garethlewis2 macrumors 6502

    Dec 6, 2006
    You have fallen into the most simple of traps.

    You have written in OpenGL, the HelloWorld program, and you now want to create something along the lines of iTunes. Wrong way of doing things.

    For just handling objects so they move around each other correctly and your 'camera' and fly past, upto, and rotate around objects, you will need to create data structures for all objects that have local, world and camera co-ordinates. Luckily for you, OpenGL has alot of builtin routines that will automatically convert between different view spaces for you. After that, you will be able to fly a camera past a static scene, and the camera will fly right through the objects. To make the camera bounce or just stop you will need to add either bounding spheres or bounding boxes to your object models, then every time you move the camera, your code will need to examine every object against, every other object and camera to make sure no collisions occured between spehere-sphere, sphere-box, and box-box. After getting that working, you are going to need to have a physics routine that can use this collision data and the information about how fast the object was moving to simulate how objects will react to in these situations.

    All-in-all, you have a monster amount of work ahead of you. It is why Torque is such an attractive option for developers, along with the Ogre engine. All of the above is already written.

    Say you did, all the above. All you have written, is a very, and I mean this, very basic engine. You don't have any scripting, you don't have an AI, you would still need to write that.

    I am not trying to put you off, plenty of people have done what you are attempting. If you have say 6 months of free-time that you can dedicate to a project, then you will more than likely get very far with this. If you can't guarantee the time required for such an endevour, you might end up feeling very frustrated about the whole process.
  3. Catfish_Man macrumors 68030


    Sep 13, 2001
    Portland, OR
    A somewhat less opengl focused answer: you'll need to pick up an API. On OSX the main ones are Cocoa and Carbon, but there's wxwidgets, Qt, Java, etc... available as well.
  4. Fearless Leader thread starter macrumors 68020

    Mar 21, 2006
    so if i should just use torque or allegro whats the point in learning opengl / directx / other api's?

    I have a lot of free time, I was planning on making a simple 2d engine, and once that was done, move on to a 3d.

    Anybody have some good resources or a have a sugestion for a better learning path.
  5. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK
    There's a lot of tutorials at
    If you can work your way through those then you will be doing well as they cover a lot of ground some of which are quite complex.

    b e n
  6. allegrocm macrumors member

    Mar 13, 2005
    Ames, IA
    OpenGL and GLUT are an awesome combination. Personally I recommend writing little games. For example, make a breakout game, and then add things like items and powerups and points and lives to it! Or try out the opal physics engine layer ( and learn how to do some 3d physics stuff.

  7. garethlewis2 macrumors 6502

    Dec 6, 2006
    To answer your question about why if you learned Torque you should bother with OpenGL, DirectX, etc. You have again fallen into a simple trap. You are making complexity where none exists. Torque can use OpenGL or DirectX. So you don't need to worry about drawing your models, doing the physics, etc. All you need to worry about is the game itself.

    If you end up using Glut and OpenGL, you will still not have any collision detection or physics. You need to build that it.

    If you follow the NeHe tutorials, you will be able to load up at the end DirectX model and shade it. They are useful, but in no way are they what you would call failsafe code, and they definately are not structured in a modular way.

    I wouldn't bother with 2D if your ultimate end is to make a 3D game/engine. The math for distances, cross-product, dot-product and matrices are very similar, but everything else, is completely different. For instance, in most 2D shooters there will be a turrent enemy scrolling by in the foreground or background layer. All the code needs to do is simply work out the angle between the player sprite and the enemy and draw the turrent at the corresponding angle. In 3D, you still need to work the angle using the cross product, but then you have the problem of drawing the turret rotating. In 2D, this is a simple cos or sin call. In 3D you will need depending on the turrent design to rotate the turrent about all 3 Axis. It isn't difficult, if it was nobody would do it. But designers spend a lot of time tinkering with the code that does this part, and it usually scripted so at higher difficulty levels the script code uses smaller delta value to move with so the turret can rotate faster.

    Enjoy making the game, it is a fun task.

Share This Page