Jump to content
  • Advertisement
Sign in to follow this  
CodeTitan

What to do with OpenGL?

This topic is 5220 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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
}


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites


///////// GAME INIT HERE, does all pre-game loop initialisation



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



///// 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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!