Jump to content
  • Advertisement
Sign in to follow this  
blanky

OpenGL 2D Engine

This topic is 4730 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

Hey guys, I want to make my 2D engine with OpenGL. However, I want to get the basics out of the way: would I basically texture quads or figures? Or is there another way. Thanks guys, heh, if you could elaborate on the process a bit more (dont have to be entirely specific) that'd be nice, I think that I obviously wont use the Z buffer (or I can if I want the effect that the player is a bit away fromt he background.) Thanks guys! EDIT: Er sorry, didn't read the FAQ, found some info, thanks guys. But I'd still like to know your opinions and tricks if you'd like, just to not waste this topic (since there's no delete feature)

Share this post


Link to post
Share on other sites
Advertisement
For a more true to form 2D engine probably stick with the ortho mode and for get about the z-buffer. If you use the hardware to manage the distance then you will start to run into some other issues. For 2D you generaly want to have full control over all your pixels and the hardware will be scaling the images acording to the depth. Which can change the way things look quite a bit depending on a number of things. It can work but it depends on what your doing exactly and creating smart art that takes all that suff into acount.

I would say in most cases its best just to creat and manage a set of planes. Draw them from back to front and move them acording to how "far" away they are. Far planes scroll less, closer ones more.

It can depend so I what all do you want it for?

Share this post


Link to post
Share on other sites
I'd like a 2D side scroller, but I just wanted to know the basics of making one. I know you use orthographic projection, but would you just texture quads? Etc., what tricks people use in 2D engines and what hints you know that could help me out, nothing specific, just to point me in the right direction, thanks for the help.

Share this post


Link to post
Share on other sites
Quote:
Original post by blankdev
I'd like a 2D side scroller, but I just wanted to know the basics of making one. I know you use orthographic projection, but would you just texture quads? Etc., what tricks people use in 2D engines and what hints you know that could help me out, nothing specific, just to point me in the right direction, thanks for the help.


Yup. Just texture a quad. From there most any 2D technique should apply. Creating a tile engine is place to start. There's loads of info on programing tile engines and they are fairly simple to create. When you build the engine start by creating a map editor for it. That way you can make a map, save it, and load it into whatever it is you want to use it for later.

Share this post


Link to post
Share on other sites
Ah, okay thanks for your help. Although, I'm very new to tool making, do you know of any tutorials on the subject? (perferably map editor making), it can be a very simple one, of course I can figure it out, but to see how everyone else does it, thanks.

Share this post


Link to post
Share on other sites
You can create your scrolling tile engine as complex as your want. I use vertex buffer objects, vertex- and fragment shaders, etc to render my 2D engine.

First you should decide how to setup your engine. It will ofcourse support multiple layers. Then define how to store the layers in memory. Often this is done as an 2D array which with indices of the tile to use. Those tiles will all be stored in one big bitmap. Rendering is then as easy as looping through these indices and display the tiles on the screen.

When you have this running you can start optimizing things if necessary.

Share this post


Link to post
Share on other sites
You can go almost as nuts as you wish. A lot of crazyness isn't need. At least not your first time around. The isometric land forum deals with top down tile engines as well as isometric ones and is the best place to get people help. As for articles and such just run a search on Gamedev and google. There is loads of info on the subject and much of it is easy to understand. Find an aproach that you like and try it out. Just replace any references to sprite drawing with a textured quads and your in the biz.

Below is a screen shot from my last run at a tile engine. A lot of the stuff is personal ideas, much of which never was done or didn't really work. Some things did work fab so I will suggest them for your own editor.


The bottom row is a small list of the selectable tiles. The mouse wheel is used to flip through the full range. Turns out that is a damn cool and handy way of picking your tiles. The large box on the lower left is a preview of the selected tiles. I had it so you could select 2 or 4 tile sets to draw with as well as one. The preview is always in the box. Just one thing you can do. A Colored quad would work too. The purple diamonds spin around and define a "range" of tiles to change. Ignore the event stuff. It had to do with the interactive qualities of the tiles. Something that you should think about tough. Additives were just going to be extra graphics layerd on top of the tiles. Not a tile engine thing.

The main things are making sure you can load and save your map and figuring out how you want to define and use the memory used for for the map. If memory serves I think I just made a character pointer. Then fetched the amount of height * width after I knew what that was. That gives you 256 tile types to play with. It would be cool if you could use a 2D array and have map[hight][width] but you cant. Not without knowing the exact size of the map. So then you dig up your value by Map[xvalue + (yvalue*mapwidth)].

you can also use an array of structures.
{
1. tile number here
2. linked list pointer to next tile.(for layered tiles)
}

Go nuts

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!