SetGfxDriver SDLMax2DDriver()

BlitzMax Forums/BlitzMax Programming/SetGfxDriver SDLMax2DDriver()

Robert Cummings(Posted 2006) [#1]
Hi,

SetGfxDriver SDLMax2DDriver()

Need to know how difficult this would be? We need robust fallback for our 2D games.

Ideally then SDL will handle the alpha, the rotation and the scaling etc via drawimage...

What do we need to make this work seamlessly? Here is the current progress:

http://www.blitzmax.com/Community/posts.php?topic=49216


Robert Cummings(Posted 2006) [#2]
Hi

I feel confident in taking a crack at this myself. Can you please give me a quick mini tutorial on how to make a basic Driver framework (ie tell max what one is cls and so on...)


TartanTangerine (was Indiepath)(Posted 2006) [#3]
I'd be interested in this one but only if you can get SDL sprite rotation working well.


Robert Cummings(Posted 2006) [#4]
Hi,

From my findings tonight (I have SDL running happily in bmax) I think we need a 3rd party addon that is very popular called roto zoom for sdl. And this is compiled to create an a file which we use. It's totally compatible with SDL and well known apparently.

Far more important though is you can't actually blit to minus coords. You need to somehow move the buffer. I need another brain?


BeChris(Posted 2006) [#5]
Hi everybody, I just tried to create a SDL backend for Max2D, based on SDL 1.2.11 and SDL_gfx 3.0 (no dll for this last one, c files directly included).

I currently can display images scaled and rotated (thanks to SDL_gfx), also calling SetAlpha will have an effect on displayed image.

I still have a problem with rotation (as SDL_gfx always rotate according to the top left corner of the image, whereas Max2D can rotated according to whichever handle is set before) and alpha channel (which may produce garbage depending on images).

I also receive keyboard and window close events and forward them succesfully to blitzmax internal event handler.

If you want sources and try an example, go grab it at http://perso.wanadoo.fr/chrisgames/sdlmax.zip (windows only for the moment)

(press ESC or close window to stop example).

Is it worth creating a community project ?

Waiting for your comments ...


Damien Sturdy(Posted 2006) [#6]
To draw the sprite as if it's from the center you need to position it relative to the angle you're drawnig it.

Quick botch job:

X=X-(sin(rotation)*width);Y=Y-(cos(rotation)*height)



Mr. Write Errors Man(Posted 2006) [#7]
Wouldn't HGE be a better choise than SDL? It supports rotations and such and still runs on crappier systems.


ozak(Posted 2006) [#8]
Something without crappy GPL license would be preferable so we can link it in directly :)


Russell(Posted 2006) [#9]
Yeah, whatever happened to true public domain?

Russell


BeChris(Posted 2006) [#10]
Hi, I'm glad to announce that I made a lot on this module.

There is now a dedicated page on sourceforge : http://sourceforge.net/projects/sdlmax

You can download there a zip which contains sources and compiled files for Windows and Linux as well as necessary dll and .a.

Among other things, I succeed in making rotozoom well located.

The remaining points are:
- Differents blending modes.
- Handling of alpha/mask color (they are closely linked in SDL).

If someone feel capable to help (I discovered SDL at the same time as I began this project), feel free to drop me an email.

I'm sure we will have in a not so far future a complete Max2D software-only driver.

Please, test it and leave me your feedback.


Robert Cummings(Posted 2006) [#11]
Hi Chris,

I have been using the Noel cower SDL lib so far, and I thank you for your hard work on this library. Amazing job so far.

Is it cross-platform and do you support the main SDL calls (for example if I need to optimise sdl surfaces for speed? Just curious.


Grey Alien(Posted 2006) [#12]
But surely it can't be very fast at all the fancy stuff (glow, alpha, rotate, scale etc)? Mind you if you have a detail setting in your game and you have to fall back to SDL, you could set it LOW detail.


BeChris(Posted 2006) [#13]
Hi everybody.

One Eyed Jack: The module should be cross-platform (it ran succesfully under windows and linux) but as I don't own a Mac ...
Furthermore, I don't understand the meaning of "do you support the main SDL calls".

Grey Alien: I started to test the driver with all samples and games given with blitzmax. Some run very well, at the same speed as with default D3D or GL driver.
Some others (radialblur, zombie blast) are very very slow.

To be honest, my objective is to make possible to run very simple games. My new upcoming game Cavern Challenge is a good example : 2D, very simple graphics with no realtime rotation or zoom.