Sign in to follow this  
Mad_Koder

2D OpenGL SDL Engine Help

Recommended Posts

I have decided that writeing my own 2d engine is way too much work for a mere 2d side scrolling gravity defineing game, so before loseing an arm and leg from doing so, I was wondering if thier is any free Engines for SDL&&OGL that would be good for a 2D side scroller? If not how about Win32&&OGL? Imensly Apreciated -Mad_Koder (spoof)

Share this post


Link to post
Share on other sites
Hidden
I don't know of any such engine. But I'm not sure exactly what it is you're asking for....

Do you want a GAME engine, something you can just add content to and you're done? If yes, then I guess you're looking for some kind of game maker... unfortunately I cannot help you with that, but I know there are lots of them out there.

If you are looking for some kind of GRAPHICS engine though, then look no further. SDL has everything you need for handling keyboard and mouse input, sound, etc etc. For graphics, you can use OpenGL for 2D graphics as well.

Have you programmed any SDL before? I mean, do you know how to blit and animate sprites, etc etc? If yes, then I assume you wanna use OpenGL to speed up graphics (since SDL is pretty slow at high resolutions). For this, you can write a simple function for loading SDL_Surfaces to GL textures and blit them as quads on the screen instead. (I can also give you this function 100% working, as I wrote one myself just 2-3 days ago...)

If this was not the answer you were looking for, let me know and I will try to help you better. :)

Share this post


Link to post
SDL, would work good yes, but dont know how too make trees and liked list so i cant really code a great oop design, so is it fine to make a game in a non oop style, or will it be a lot harder (how much so)? And yes I do know SDL and how to blit image etc., I could review the tutorials though as i am a tad rusty. Is it a lot faster if you include gl.h and glu.h instead of SDL_opengl.h?

Thanks

~Mad_Koder (spoof)

Share this post


Link to post
Share on other sites
Hidden
I don't know any C++ I'm afraid, as I only program in old C. But you don't need any linked lists and stuff for the game you wanna do... if you were writing a game server linked lists would probably be better, but in your case you'll be just fine with arrays.

To add 100 bullets to you game, you can do something like:


struct {
int xpos;
int ypos;
int direction;
int velocity;
} Bullet[100];



You should always use the SDL_opengl.h header file when you're programming SDL with OpenGL. I think it has to do with cross-platform compability.

Share this post


Link to post
I have a SDL and OpenGL library that was originally intended for 2D game development (I've made a few games with it so far). I use it for all new development, so might be worth a check.

I'm still planning on doing a better release in the new year with nicer namespacing, cleaner shader class design and more stuff, but the 2D core of the library is there and works well.

You'll probably need to roll your own level format, map collision and whatnot, but there's enough stuff there to make a decent sized game without having to spend time writing texture and font loaders (for one).

If you have questions, I'm generally online so you can harass me over AIM or MSN like it says on the site, or use the forums and IRC channel (I'm generally on IRC when I'm online).

Share this post


Link to post
Share on other sites
Quote:
Original post by Ravuya
I have a SDL and OpenGL library that was originally intended for 2D game development (I've made a few games with it so far). I use it for all new development, so might be worth a check.

I'm still planning on doing a better release in the new year with nicer namespacing, cleaner shader class design and more stuff, but the 2D core of the library is there and works well.

You'll probably need to roll your own level format, map collision and whatnot, but there's enough stuff there to make a decent sized game without having to spend time writing texture and font loaders (for one).

If you have questions, I'm generally online so you can harass me over AIM or MSN like it says on the site, or use the forums and IRC channel (I'm generally on IRC when I'm online).

Hey, I tried building PropaneInjector using Xcode using your tutorial, and I recieved this error:

http://img85.imageshack.us/img85/4803/picture1jc1.png

Could you help me out?

Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by Max Piano
Have you linked (inserted in the project) the cpp files?

Yes, I have followed this tutorial exactly
http://ravuya.ballofdoom.com/propaneinjector/howto/Xcode/

Share this post


Link to post
Share on other sites
For v0.7, I think it's been re-namespaced so instead of PI_initSDL and PI_initGL you'll have to use Propane::initSDL and Propane::initGL/initGL3D. It's part of the reason I recommend using v0.4 -- I haven't yet updated the documentation for the 1.0 release effort.

Share this post


Link to post
Share on other sites
To use just SDL, you want SDL_BlitSurface. Perfect for the most simple of graphic work. It doesn't require that much work to get your own 2d game engine going. Basically, you could load an image in to a SDL_Surface, and keep a list of SDL_Rects that square off the tiles and sprites in that image. Make sure to set a Color Key, and each frame cycle, copy the tiles and sprites to the screen surface. For speed consideration, try to place both surfaces in hardware memory.

OpenGL is a bit more complex. I'm still learning it all myself, but apparently the process is to use Orthographic mode, load the graphics into 2d Textures in the hardware memory, and then draw polygons that use those textures. You lose some features, like Palettes since, lets face it, the support for it sucks, and SDL's opengl headers don't cover much. Although, I did figure out a few highspeed texture procedures that could kind of simulate palettes, but I guess that slows down the front side bus.

Share this post


Link to post
Share on other sites
Hidden
Quote:
OpenGL is a bit more complex. I'm still learning it all myself, but apparently the process is to use Orthographic mode, load the graphics into 2d Textures in the hardware memory, and then draw polygons that use those textures. You lose some features, like Palettes since, lets face it, the support for it sucks, and SDL's opengl headers don't cover much. Although, I did figure out a few highspeed texture procedures that could kind of simulate palettes, but I guess that slows down the front side bus.

I'd like to think it's the opposite - I see only advantages with this method. Yes, you lose palette functions, but you get way too many other functions suddenly available because of OpenGL. You can scale graphics with one line of code, you can rotate, use filters, use lighting effects, etc etc...

The complicated part is how to convert an SDL surface into an OpenGL texture and add it in memory. I am supplying a few links below which hopefully will shed some light on this subject!

After you have successfully loaded the textures to memory, you can simply write a function that draws quads at x,y with size w,h and then place the texture on that quad. Placing an image on the screen wouldn't be much harder than calling something like: GLBlit(texture_number_of_the_image, x, y, w, h);

Dig into these links for more info on the subject:

http://osdl.sourceforge.net/OSDL/OSDL-0.3/src/doc/web/main/documentation/rendering/SDL-openGL.html
http://twomix.devolution.com/pipermail/sdl/2002-September/049078.html
http://www.libsdl.org/pipermail/sdl/2005-December/071630.html

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this