What to do with OpenGL?

Started by
9 comments, last by CodeTitan 19 years, 8 months ago
I am learning OpenGL. I understand primitives and lighting. I want to create a simple game at this point, but I have no idea whether there is something more I need to learn or if I can create something now. Is there more I need to learn before I can actually create a simple game? Or does anyone have any ideas on what I could create with my limited knowledge?
Advertisement
Hi!

Well, one of the first games I coded with OpenGL was a race game inside a tube. sections of cylinders put together, and closed to make one interesting circuit.

For this kind of games, some math knowledge might be needed, but it remains feasable.

Another kind of game you could try is a first person shooter, in a square room. Then, try to have several rooms. Represent ennemies as cylinders.

It that's look a bit complicated for a fist try, do a 3D Pong. That will give you enough experience to go for more complicated games.

Good luck!
Thank you for the ideas! They seem like the perfect place to start.
Actually, I have a couple of questions. When I write the tube game, should I texture the objects? And if I wanted to create a box in which the player moves, would I just create a large cube and put the player in it?
Yes - just create a cube and put the player inside. There are even things called "sky boxes". Those are just textured cubes, that represent the scenery beyond the map and sky.

And also - maybe what are you thinking of are meshes. Files created by 3D graphic, loaded by the engine and rendered. But that's not important now (since, it is pretty complicated). Using just textured polygons for 3D pong, or simple 3D shooter is enough.

For the texturing - if you have some good textures, that would look better than smooth shaded polygons, use them. Otherwise do not [smile]. But I think, you shouldn't bother getting some "cool" textures, if you just want to do a game.

Maybe, if someone made a 3D FPS without texturing, it would look cool... [smile]

But for now - just do what you want, with what you can do.

So - my advice is as usual - just try it and you'll see [smile]

Oxyd
The problem I see with most tutorials on OpenGL is that they tend to be focused on showing a particular effect, "here's how you do particles", "here's how to load a model", etc. What's lacking is that they don't tell you how to tie these sort of things together in a gaming context. I think that it'd be good to learn about how to handle game entities, effects and such like as this would put you in good stead for your future development of games. Most tutorials tend to throw in global variables and the like, which to be fair can be dangerous when coding a game. It doesn't have to be complex, something simple like PacMan or space invaders will have enough entity management for you to cut your teeth on and should hopefully provide you with the basics of using OpenGL and understand it's capabilities in a real context that lies outside the realm of tech demos.
Here's a specific coding question; Where, in this SDL loop, should I put my GameInit(), GameMain(), and GameShutdown() functions? I have the functions defined, I just don't know where to run them.
bool bRunning = true;SDL_Event event;while(bRunning){    if(SDL_PollEvent(&event))    {        switch(event.type)        {            case SDL_QUIT: // test to see if the user closed the app                bRunning = false;            break;            case SDL_KEYDOWN: /* Handle a KEYDOWN event */                if(event.key.keysym.sym==SDLK_ESCAPE)                bRunning = false; // quit if ESCAPE is pressed            break;        }    }    // here we would call our main rendering function    // for now we just refresh the Window.    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear screen and depth buffer    glLoadIdentity(); // reset current model view matrix    SDL_GL_SwapBuffers(); // finally we swap our buffers}

Init is before SDL loop, with SDL init. Shutdown is after SDL loop, with SDL shutdown. SDL loop is your main game loop, so is your game main.
-- Jonathan
///////// GAME INIT HERE, does all pre-game loop initialisationbool bRunning = true;SDL_Event event;while(bRunning){    if(SDL_PollEvent(&event))    {        switch(event.type)        {            case SDL_QUIT: // test to see if the user closed the app                bRunning = false;            break;            case SDL_KEYDOWN: /* Handle a KEYDOWN event */                if(event.key.keysym.sym==SDLK_ESCAPE)                bRunning = false; // quit if ESCAPE is pressed            break;        }    }    // here we would call our main rendering function    ///// GAME MAIN HERE, performs per-frame logic updates    // for now we just refresh the Window.    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear screen and depth buffer    glLoadIdentity(); // reset current model view matrix    //////// RENDER HERE - Performs rendering after game logic is updated    SDL_GL_SwapBuffers(); // finally we swap our buffers} ///////////// GAMESHUTDOWN HERE, closes everything down and frees memory



Hope that helped a bit :)
Back on the game idea, you could do something like "Light Cycles" (that game in Tron). You could just replace the bikes with some OpenGL primitive.

This topic is closed to new replies.

Advertisement