Jump to content
  • Advertisement
Sign in to follow this  
michaelr

2D tile maps w/ OpenGL

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

This has probably been hashed to death, but the search function was returning OLEDB errors, so I'll ask anyways. Basically I want to do regular 2D type maps (dragon warrior, zelda, ultima, etc.) and I'd like to use OpenGL if its possible to pull it off with it. I really have not ran across any good explanations on how to do this things. I'm pretty proficient with DirectDraw, but the 3D API (Direct3D & OpenGL) are a bit of a mystery to me. Does anyone have any examples or other tips that could help me figure this out? I'd like to take good advantage of all the 3D effect (alpha blending, etc.), which is why I'm trying to take this plunge. thanks, Mike

Share this post


Link to post
Share on other sites
Advertisement
its pretty much the EXACT same thing. theres not much difference between drawing a quad to the screen via OpenGL, then drawing a 2d surface to a screen. in fact, once you write the Draw_Quad() function, you dont even have to look at it again if you dont want to. just call Draw_Quad(x,y,w,h) instead of Draw_Surface(x,y). its pretty easy.

start reading tutorials, it shouldnt take more then a week or 2 to figure out how to draw primitives to the screen and stuff.

Share this post


Link to post
Share on other sites
Quote:
its pretty much the EXACT same thing. theres not much difference between drawing a quad to the screen via OpenGL, then drawing a 2d surface to a screen. in fact, once you write the Draw_Quad() function, you dont even have to look at it again if you dont want to. just call Draw_Quad(x,y,w,h) instead of Draw_Surface(x,y). its pretty easy.


I think the problem the original poster is having is one that I myself have had. The complete lack of 2d to 3d explaination. For someone who has never had any interest in 3d API's, it is like going from simple algebra to calculus/trig without having certain important terms explained to you inbetween.

I do have to say though that all is not because of lack of documentation. I think that there is an enormous amount of documentation for people familiar with 3d API's to go to 2d. This of course brings up the point that one could always become familiar with using a 3d API first for it's intended purpose and THEN move back to 2d. This of course is frustrating to most people who just want hardware scaling, alpha and rotation leaving them lost and confused as to why this is such a pain in the butt.

I think I need to sit down tonight and compile a list of questions I have regarding 2d to 3d conversions so that maybe I can put something together for people like myself who need a direct link as to what does what as you would do in 2d. I will probably use SDL and OpenGL since virtually anyone can use those and test it regardless of compiler or OS not to mention the window initialization code most people complain about is mostly wrapped up in SDL :)

Sorry to kind of hijak the post.

Share this post


Link to post
Share on other sites
evillive, i think you are over-estimating the difficulties of using a 3d API.

i've never used D3D, i use OpenGL w / SDL. i converted my 2d RPG project mid-stride, and never looked back. it only took about a week or so to do.

once you get past the initialization stuff (BTW: you DONT have to understand all of this stuff to use it, dont forget that!!!), its pretty simple. drawing a quad isnt much more difficult then drawing a surface.

go to the NeHe. Lessons 1,2,3 and 6 are the only lessons you need to get started. follow the tutorials, and download the SDL versions at the bottom of the page. in that second tutorial, you learn how to draw a quad. this is all you need!! tutorial 6 shows you how to bind a texture (its simple), and thats it. your tiles, sprites, everything is just a quad with a texture on it. its pretty simple. the only thing you have to do is set up an Ortho projection. doing this, you can make 0,0 the top left corner of the screen, and one OpenGL unit == one pixel. then its EXACTLY like SDL! if you need help, feel free to ask here or at the OpenGL forum. dont let it imtimidate you, its easier then it looks. like i said, you DONT have to understand all of the initialization code. i sure as hell dont [smile].

Share this post


Link to post
Share on other sites
I concur. I did similar things using directx. You eventually stuff all that junk into its own class anyways, so once it's done you can ignore all of the API trickery and terms that make no sense. To actually print a picture to the screen takes maybe 20 lines of code. To print text, it's closer to 2.

Perhaps I'll write up a tutorial for it one day.

Share this post


Link to post
Share on other sites
Much thanks for all the tips you all have given. I will give the SDL/OpenGL stuff a try since I'm a little familar with SDL from where I tried to do an ultimate cross platform RPG a while back (had it running on Win/x86, Win/Alpha, BeOS/x86 and MacOSX). Its been a while, but it sounds like the best route to try at the moment.

thanks,
mike

Share this post


Link to post
Share on other sites
I got a nice Tile Editor in OpenGL. If you're interested, grab it at http://openglgui.sourceforge.net/code.html - OpenGL 2D/3D Map Editor.

Good luck.

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!