ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi. I'm working on a 2D game (see sig) and after reading thru the SDL newsgroup I've given thought to using OpenGL for rendering graphics in two dimensional space only. So now my problem is finding a good guide to help me accomplish this. I'm well aware of http://nehe.gamedev.net/ and I've glanced briefly thru the tutorials there, but everything seems to be 3D based and quite honestly I don't want to spend time learning how to use OpenGL for 3D imaging if I'm never going to use it. Of course I will use the tutorials on there to learn about cell shading, lighting, etc., but I just need a simple guide to help me get started. I don't have a great deal of experience with graphic programming, but I've managed to implement video code in my game so far using the SDL_image library, which was very easy (and fun) to learn and use.
So does anyone have any sources that can help me get my feet wet with using OpenGL in a 2D application? I've tried googling myself and looked around the SDL website but couldn't find what I was looking for. Thanks for any help you can provide.
using opengl for 2d is essentially using it in 3d with a constant coordinate(probably z). the only opengl you need to know how to do is placing and texturing quads which is essentially covered in nehe 2&6 but going through nehe 1-6 wouldnt do you any harm.
i dont think effects like lighting or blending will work if you dont do stuff in 3d cos they dont really make sense in 2d so if you want to use them your gonna have to learn 3d anyway.
Well the game is a top-down approach like Final Fantasy games. So what if I want to do something like say, in a dark dungeon I darken the screen that isn't within a certain circular radius of the character? Or what if I want to do something like simulate clouds overhead casting shadows on the ground? That makes sense to do in 2D, doesn't it? Thanks for your help though, I'll read tutorials 1-6 so I can have a strong backbone, even if I don't necessarily use everything I learn there.
As Kev82 said, you're likely going to just need to know how to draw textured quads. Your circular lighting, and cloud shadow idea can be done by blending quads together, so you'll want to look at blending a bit too.
You could use OpenGL lights for the circle of light, but unless your quads are highly tessellated (that is, you define them with lots of verticies), you probably won't get the effect you want. OpenGL does lighting on a per-vertex basis, so if you are shining an OpenGL spotlight in the middle of a quad, and it touches no vertices, you will see no light.
You'd probably be better off with a "light map" technique, where you have your lighted area defined by another texture, in which you blend with the quads you've already drawn. Essentially the same technique could be used for your cloud shadows.
Depending on the hardware you are targetting, you might also want to look at multi-texturing (drawing polygons that have more than 1 texture assigned to them). Multitexturing should be supported on pretty much any card worth its 3d capabilities, but might not be on some ancient cards that were never really meant for 3d gaming.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.