I want to make a simple 3D game using openGL, where to start?

I find that I will best learn by example. Is there a good website or codebase that shows how event processing, conflict detection, modeling, and basic 3D drawing work?

The game I'm trying to start with is a simple racing game in which the user controls a small spaceship and moves through channels, fields of asteroids, space colonists and other other obstacles (I know, this is the original). The movement is in 3 dimensions. The game should know when the shuttle got into an obstacle. Tracks are defined, as in most racing games (schemes and linear paths).

Pressing the arrow keys should cause the direction vector to rotate accordingly. In addition, the ship should use something like afterburner when the user presses the space bar, for example. Movement up and down is also an option.

+4
source share
11 answers

Not knowing my entry level skill, I suggest you take a look at Ogre3D . This is a complete 3D rendering engine that has a really clean interface for operation, ease of expansion and, most importantly, it is multi-platform, running on Windows, Linux and Mac OS X. The above examples and training materials are pretty self-evident.

If you want to completely write your own OpenGL engine from scratch, Ogre3D may not be the next way ...

+4
source

If you want to learn about OpenGL, I recommend starting with the OpenGL Red Book and then looking at NeHe samples . The Red Book is free, at least in the online HTML format, there are also downloadable PDF files.

However, Red Book and NeHe will teach you mainly to use OpenGL; writing games is an art, and there are too many to explain, too much to learn, and too much to read about it. Here is just a tip.

This is the basic structure of most games. Hope this helps with the basics. Of course, this is not a full-fledged game, it will not work, and largely depends on how you do it, but it should give you a basic idea.

void update(float k) { // k == time in seconds since last update; eg 0.02 ship.y += ship.speed_y*k; } int main() { while(1) { if(hasEvents()) { event_t evt; getEvent(&evt); if (evt.type == keypress && evt.key==down) { ship.speed_y=1; } } paint(); new_ticks = get_ticks(); update((new_ticks - old_ticks)/1000.); old_ticks = new_ticks; } } 
+4
source

A few notes, some of which have already been outlined:

  • OpenGL Redbook . Great place to start. There were several changes in the book, so the free online version is a bit outdated by comparison.
  • GameDev.net . They are an excellent resource for developers of all experience, and there are a lot of talented people on the forums. They answered the question: "I want to make a game, where to start?" many, many times.
  • I do not recommend NeHe. I find that the textbooks there most often confuse the neophyte. The textbooks show the “how,” but very little explain why this is important.

Game development is a huge multifaceted discipline. This is difficult even if you have very good math and programming skills.

Two tips:

  • Start small. Start small. Start small. You might think that your goal is rather modest, but it will involve much more than you imagine.
  • Avoid the temptation to cut and paste sample code. You will fool yourself out of decisive understanding.
+3
source

Nehe

This site has helped more than ever when I studied opengl.

+2
source

I don’t know how much programming experience you have in the game, but I would start with something more limited.

Start with a game based on 2d tiles (Sokoban, etc.) - they are relatively easy to write - something where objects are always on the tile, which makes things pretty trivial.

Once you have the principles of this, the game loop, synchronization, user input processing, data model, rendering, etc., then you can do something more active.

Then you can try something like “Asteroids” that will need some 2d vector maths, intertia modeling (i.e. integration), maybe a little trigger. and a collision system based on non-gravity.

After you lick, you can try something 3d, which makes things more complicated again, mathematically.

+1
source

I would look at www.gamedev.net , it contains some excellent tutorials for beginners and on forums that you will find a lot of information about any subject related to game programming.

+1
source

First, you should consider the structure of your code. Each game has several options for the following:

 int main() { Screen::Init(); Game::Init(); while (Game::isrunning) { Game::Update(); Screen::Render(); } Game::Shutdown(); return 0; } 

The rest just becomes an implementation detail. Try looking at the SDL, it handles a lot of the unpleasant things of Windows programming (window initialization, loading OpenGL, etc.), so you can focus on writing your game.

+1
source

I have to give a warning for using nehe because many people have recommended it (don't have an account to comment, sorry)

Mostly because it only shows how to do things with a fixed pipeline, not shaders. The first pair of tutorials might be fine if you get a kickstart on how to get something on the screen. But don’t waste your time, for example, learning how to activate alpha blending and lighting settings for a fixed pipeline, because if you want to do something that doesn’t look like a game from 1999, you will have to relearn how to do it all this again, but with shaders. Better to learn a new path from the very beginning imo.

+1
source

Firstly, I do not recommend using OpenGL for your first game, especially if you have never programmed before. You should seriously consider new and simpler methods such as XNA with C #.

Secondly, like OpenGL, XNA also has a large number of tutorials on the Internet, which I think you will find very useful.

If you have never programmed before, I recommend as a starting project, you should try to create a very simple game such as Pong or Tic Tac Toe. I think you will get a good idea of ​​the game as a whole. From there, you can start your actual project from the experience you have gained in creating Pong.

Finally, the main advice that I can give you, since you are adventuring in your quet, is to never give up, no matter what obstacles you encounter when creating your game.

Good luck ^^

+1
source

Yes, check out the online tutorials. Yes, go to GameDev.net. Yes, NeHe is confused and specialized.

For OpenGL, I would like to combine the OpenGL SuperBible feature so that you know about the context and capabilities of OpenGL with the good old-fashioned Google Search.

It also helps to get to know someone who can help you from time to time. GameDev.net has chats and people are friendly.

0
source

If you need opengl, but with python simplicity - which would be nice to understand the principle of the API at the beginning - check out the shells: http://pyopengl.sourceforge.net/

They are compatible with the latest version of opengl, and their development is quite active.

0
source

All Articles