• Advertisement
Sign in to follow this  

Making a game with C++ and OpenGL

This topic is 3038 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've been doing some minor programming for a few years. Used BlitzBasic for a little while, but then I moved to C++. I wanted to try making a game from scratch with OpenGL and GLUT. Is it worth it to trudge through the textbooks and learn every aspect of 3D rendering, or am I better off just using something like SDL. I know GLUT doesn't have anything for audio playback in it, so I would have to use something like OpenAL. I'm starting to think I could save myself a lot of frustration by using SDL which has all the makin's for a game. Have any of you been in this situation? Should use SDL, but continue to read my OpenGL book? I believe SDL uses OpenGL for rendering. Is it possible to interact directly with OpenGL through SDL, even access the OpenGL Shader Language (I have no idea how to use this, it just sounds interesting and potentially very powerful.)

Share this post


Link to post
Share on other sites
Advertisement
My story: no internet (just since a year), one semester of C programming (it was almost useless), no knowledge of any libraries, instead of glut, and openGL. I had the legendary "read book" (for openGL 1.2). But I jumped in the thing and started everything from starch. And after 2 or 3 years, I had a small demo (in my signature).
Sometimes I didn't do anything on it for months. And mostly on some weekends (I had no time).

Ok I took the opportunity to advertise my simple demo again. SORRY!

Share this post


Link to post
Share on other sites
Stick with SDL unless you are good at 3D math. If you don't know the difference between a right hand and left hand coordinate system or how to find the inverse of a matrix, etc. you'll be wasting 1/2 your time on that!

Share this post


Link to post
Share on other sites
You could use SFML, its in my opinion SDL for C++ (as in its written with classes and OO in mind), it also offers hardware acceleration of 2D sprites through OpenGL, as well as sound (with OpenAL), and some other stuff.
You can also drop into OpenGL easily if you wanted too.

Share this post


Link to post
Share on other sites
SDL can be initialized in an OpenGL mode. I think GLUT is no longer worked on. I think it's easier to make an SDL program cross-platform too.

I'm pretty new to programming and I started with GLUT because there's a pretty good tutorial out there (GLUT Lighthouse tutorial) and many other tutorials use it out there.

I had some OpenGL code running with GLUT and recently got OpenGL to render with SDL. SDL doesn't have sound in the core API, but there is an SDL_mixer thing out there (haven't used it).

I think GLUT had some sort of main loop function built in while in SDL it seems you write your own. Maybe you could bypass the GLUT gameloop but I'm not sure how that would be done. That's why I switched to SDL.

A couple tutorials showing how to set up SDL

http://ubuntu-gamedev.wikispaces.com/3D+HowTos

http://www.lazyfoo.net/SDL_tutorials/lesson36/index.php

Share this post


Link to post
Share on other sites
Quote:
Original post by daviangel
Stick with SDL unless you are good at 3D math. If you don't know the difference between a right hand and left hand coordinate system or how to find the inverse of a matrix, etc. you'll be wasting 1/2 your time on that!


All you need to know to do OpenGL is the basics of the carthesian coordinate system. You can do basic (yet cool) OpenGL stuff just fine without any advanced knowledge of algebra. From there you can go gaining knowledge as you need it.

Share this post


Link to post
Share on other sites
Quote:
Original post by owl
Quote:
Original post by daviangel
Stick with SDL unless you are good at 3D math. If you don't know the difference between a right hand and left hand coordinate system or how to find the inverse of a matrix, etc. you'll be wasting 1/2 your time on that!


All you need to know to do OpenGL is the basics of the carthesian coordinate system. You can do basic (yet cool) OpenGL stuff just fine without any advanced knowledge of algebra. From there you can go gaining knowledge as you need it.

Yes but if you lack the mathematical prerequisites or maturity you will be more confused than not like this recent OpenGL posting.

Share this post


Link to post
Share on other sites
First most important thing: If it's your very first game, you should probably not aim for good graphics at all, and be happy with for instance basic frame buffer SDL. It's more important to get something that's playable onto the screen than the look of it.

----------

Otherwise:
I switched to OpenGL from conventional frame buffer rendering (SDL without OpenGL) recently, and I find that rendering 2D graphics with OGL is easier than I thought.

The math (= linear algebra in this case) required is a lot more obvious in two dimensions than three. I must say that by using the built in matrix stack you can avoid manually doing transforms in most cases. So I found it very easy (though admittedly I've had a basic university course in linear algebra, but I'm no math genius). However in my opinion someone without any knowledge of basic vector math will still struggle with making most kinds of 2D games even with simple SDL frame buffer graphics.

The reason I think OpenGL is considered harder than conventional frame buffers is that a lot of the concepts are more abstract. With frame buffers you are reasoning in terms of pixels. In OpenGL you need to deal with a much larger and flexible system and find how to make it do the 2D rendering you desire.

I've dealt with it by wrapping all OGL code up in an interface that looks like a regular 2D graphics API to the rest of the program. This way I can reason mostly in the 2D terms I'm used with. (Though I did do away with using pixels as the basic coordinate system as I never found them practical, because internally I was always using application specific world coordinates regardless.)

By the way, I found the following tutorial useful just to get started with rendering quads: http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL

[Edited by - Beyond_Repair on October 31, 2009 5:22:29 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by jasongosen
I've been doing some minor programming for a few years. Used BlitzBasic for a little while, but then I moved to C++. I wanted to try making a game from scratch with OpenGL and GLUT. Is it worth it to trudge through the textbooks and learn every aspect of 3D rendering, or am I better off just using something like SDL.

If you want to learn how to write your own rendering code, then sure, read up on it. But if you want to build a game, why not use an existing engine (and a higher-level language, while we're at it)?

Share this post


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

  • Advertisement