Cower.SDL

BlitzMax Forums/BlitzMax Programming/Cower.SDL

N(Posted 2006) [#1]
Is done.

You can download it (and other modules) from here.

For information on what SDL is and can do, visit http://www.libsdl.org

I can't stress this enough when I say please make sure you understand the terms and conditions of the LGPL v2 before using this module.

Now, this uses the SDL dll (and, presumably on other platforms, will use the shared version of SDL), so your code should not be 'under attack' from the LGPL, but I really can't protect you from any of this if you do something stupid (like switch sdlwin.a out with the SDL static library).

If you find any bugs, please report them to me (either by e-mail if you want to ensure I see them as soon as possible or post them here) so I can fix them as soon as I possible.


Robert Cummings(Posted 2006) [#2]
Pretty amazing work Noel, and I mean outstanding.

I don't mean to be cheeky, but please, please, please add these two final extras to the module which just about everyone does with SDL:

There are two main extras to the SDL lib and these are: Loading PNG cos SDL supports alphablended blits (tho I bet it is faster and better to convert from pixmap... with a helper function?)

And... SDL_gfx, which is the most common add-on which enables rotation and scaling for your surfaces.

I gotta say tho, outstanding work. If these final two elements make it in (alpha blended support with image loading and SDL_gfx) Then your donate button is going to take a hammering.


Chris C(Posted 2006) [#3]
good luck with an sdl driver that would be rather nifty!

could you not use a bank for that CD structure thing?
I ended up having to do somthing similar with ode


N(Posted 2006) [#4]
I could, but my way was easier.


assari(Posted 2006) [#5]
Thanks for sharing


Robert Cummings(Posted 2006) [#6]
If anyone feels like sharing some tutorials then perhaps this will be the defacto standard for 2D.


Robert Cummings(Posted 2006) [#7]
Donated :)


I'm gonna donate some more as well if those little extras get in (rotation and blitting alphablended images ie loading from pixmap with alpha)

I suggest to anyone if you use this, donate, its clear lots of hard works gone into it. We gotta support our own.


N(Posted 2006) [#8]
Fixed a couple bugs (not converting signed shorts to ints properly -- brainfart there).

Added SDL_image and SDL_gfx modules as well. SDL_gfx makes use of signed shorts quite a bit, so I've also written wrapper functions to go along with it.

I haven't had a chance to test either module, but they're both fairly simple as far as their public interface goes so I can't imagine them being much of a problem.

Once again, anyone finds any bugs, let me know so I can fix them as soon as possible.


xlsior(Posted 2006) [#9]
Forgive my ignorance, but what exactly does this SDL module do? I really am not familiar with what SDL is, or what the advantages are of using it.

As a side note, I just happened to rebuild my mods, and ran into a minor typo in sdl.bmx:


Compiling:sdl.bmx
Compile Error: Expecting expression but encountered ')'
[C:/CODE/BlitzMax/mod/cower.mod/sdl.mod/sdl.bmx;461;71]
Build Error: failed to compile C:/CODE/BlitzMax/mod/cower.mod/sdl.mod/sdl.bmx
Process complete



One too many closing parenthesis on line 461.


N(Posted 2006) [#10]
Thanks, xlsior. Not sure how that got in there, but apparently I fixed it at some point after uploading and forgot to include it.

Should be fixed and uploaded now.


Boiled Sweets(Posted 2006) [#11]
What is this SDL, what does it do?


Kuron(Posted 2006) [#12]
SDL


N(Posted 2006) [#13]
Fixed a few bugs:
- More crap to do with shorts
- A few to do with byte alignment (God I hate it).
- Bugged SDL_image DLL (that is, it wasn't compiled with any of the neccessary procedures -- my mistake since I forgot to compile it with the neccessary definitions)

Plus I've added some stuff to automate filling of types with structure data. This does not mean you can ignore the original structures, though. I'll be writing wrapper classes for the original structures later, but I'd rather iron out all possible problems before moving on to that.

I looked at a few other libraries included with SDL, such as SDL_net and the like, but decided the ones covered now are the only ones whose functionality are not provided in BMax and SDL alone. There were also convenience libraries like SDL_console and such, but I dismissed them on the grounds that things like that should not be generic plugin-esque libraries.

Anyhow, new library is up at the same spot.


TartanTangerine (was Indiepath)(Posted 2006) [#14]
Please can we have some examples of how this is used properly.

Thanks.

PS. I will donate when I know I can use it.


N(Posted 2006) [#15]
http://noelcower.com/mod/sdl_example.zip

There's something quick & dirty, don't have anything more advanced currently.


Boiled Sweets(Posted 2006) [#16]
so where does this fit in to max exactly?

is it a replacement for the 2d stuff or is it a 3d module prior to the brl 3d module?


Dreamora(Posted 2006) [#17]
You could use it as fallback driver if both hardware based drivers fail, because it runs on CPU and not on GPU.


TartanTangerine (was Indiepath)(Posted 2006) [#18]
Import Cower.SDLUtil

Not included in the archive :(


Boiled Sweets(Posted 2006) [#19]
Runs on CPU?

Erm isn't this a bit redundant these days?


N(Posted 2006) [#20]
Indiepath: Just comment that line out. Also fixed the archive.

That module is so far just a utility set I'm working on to use TStreams with the SDL_RWops interface. It's borked to hell at the moment, though.


Boiled Sweets(Posted 2006) [#21]
Why would anyone want to use just the CPU for gfx processing? I'm not being negative I'm just trying to understand why the need for this module?


Dreamora(Posted 2006) [#22]
Boiled: Explain that S3, SiS and users of older intel cards. Their drivers don't support the needed minimum (TnL for example) nor do they support OpenGL at all.
These type of systems are sold even today ... with 2,5-3Ghz processors! So they will often perform far better on CPU than on GPU.


TartanTangerine (was Indiepath)(Posted 2006) [#23]
I don't think I'll be persuing this much further, sorry. The LPGL is too restrictive and appears to force me to make my source code available for the linked application and other linked modules. The SDL license is fine as I can get around this by linking the the .dll's but these modules would have to be contained within my own application.


N(Posted 2006) [#24]
Hey, your loss, not mine.


Grey Alien(Posted 2006) [#25]
Sounds good Noel. Although I'm not sure I want to drop back to CPU based graphics. Can anyone make a demo showing smooth fast moving objects with no tearing or jerking?


N(Posted 2006) [#26]
http://www.libsdl.org/games.php
http://www.libsdl.org/demos.php

Go nuts.


Grey Alien(Posted 2006) [#27]
Thanks Noel.


TartanTangerine (was Indiepath)(Posted 2006) [#28]
Hey, your loss, not mine.

Sure is :( Since most of my products are commercial having to make my source available is not an option. :(


Robert Cummings(Posted 2006) [#29]
Hi Noel, ignore the naysayers - they don't understand.
Gonna check it out. If I can get everything going, another donation is going in, No-one expects you to work for free dude.


Robert Cummings(Posted 2006) [#30]
Anyone know how to use the rotation part of this?
I am scouring the net for clues at the moment.

Also, the window is named "sdl_app" and if anyone knows how to change this also... :)

ANNNNDD.... how to change the rendering mode? so I can block blit for speed, mask blit for less speed and finally alpha blit?


N(Posted 2006) [#31]
Uploaded a new archive with a quick fix (one procedure had incorrect arguments -- hopefully it's the only one). Thanks to Rob (Jack) for that.

Rob: No idea about rotation.

To change the window name use SDL_WM_SetCaption( WindowTitle$, Null ).

I'm still not sure what you're supposed to pass to the icon parameter (Null in the example), so that's up to you.

And as for rendering mode, also no idea.


Robert Cummings(Posted 2006) [#32]
Thanks!


AntonyWells(Posted 2006) [#33]
Noel, any chance of integrating this with Ogre so we could use the input (Specifically joypad) for cross platform support? OCS is nice but not out for mac while I believe sdl is.


Damien Sturdy(Posted 2006) [#34]
Nice work Noel.

Sorry to spam the thread:- Aurora, Can you point me to an Email address I can use from here? Got some bad news I need to send you.


Robert Cummings(Posted 2006) [#35]
A couple of problems:

- this module is under gpl, meaning you need to disclose your source for what uses it

- noel said he didn't have any intention of using this on mac, and indeed I don't have any intention of using it on mac as mac's own opengl emulation in software is superb

- why not give it a try yourself - it does not seem that hard to someone capable of wrapping ogre.

- bit cheeky asking someone to do the work for something you're selling? I believe in paying my way...


AntonyWells(Posted 2006) [#36]
One eyed I was asking if it was possible, not asking him to do it. Compare and contrast.

Cyngus, yeah same one, AntonyCoder@...


Grisu(Posted 2006) [#37]
Noel, can your lib play mp3 too?


Robert Cummings(Posted 2006) [#38]
No.


N(Posted 2006) [#39]
Noel, any chance of integrating this with Ogre so we could use the input (Specifically joypad) for cross platform support?


Don't know or care to try as I'm not using Ogre.


N(Posted 2006) [#40]
I've uploaded a new version with a fixed function definition.

This has been done for about a week now, but I held off on uploading it since I'd gotten a virus and wasn't sure if it was considerably safe to upload it yet. I feel that by now it is as I've pretty much obliterated the sneaky bastard, but I feel it's only fair to let you know that much.


Robert Cummings(Posted 2006) [#41]
Thanks Noel!


Robert Cummings(Posted 2006) [#42]
Does anyone know how to use SDL graphics to rotate? there's examples on the sdl_gfx homepage but I don't know how its done.

I'd like to use the rotozoom function built into it but I cannot seem to find rotozoom in noels mod.

Have you left these functions out noel?


N(Posted 2006) [#43]
Yeah, looks like I forgot some of them. Woops!

Will get those in shortly.


N(Posted 2006) [#44]
New version uploaded.


Robert Cummings(Posted 2006) [#45]
Thanks noel. It asks for jpeg62.dll, libpng12.dll and zlib1.dll when I compile. I managed to find these online but surely they aren't needed as we have SDL_image.dll ?


N(Posted 2006) [#46]
They are needed because SDL_image has dependencies on those libraries.


Robert Cummings(Posted 2006) [#47]
Thank you for your reply. I am thinking - it is probably better to use blitz's own pixmaps to create the surfaces from? Do you think that is a better idea?

I also need to find out how to do blend modes for speed, for example solidblend, maskblend and alphablend (I think they will all have different speeds).

Good work you have done here though.


Robert Cummings(Posted 2006) [#48]
SetCursor stuff and similar functions are missing from your module.


N(Posted 2006) [#49]
What SetCursor stuff?


N(Posted 2006) [#50]
There we go, found and fixed it.

Not sure how I missed that, but eh.


Robert Cummings(Posted 2006) [#51]
Hey noel thanks, I just took a look at whats missing:



'Ones that I need :)
SDL_WarpMouse
SDL_CreateCursor
SDL_FreeCursor
SDL_SetCursor
SDL_GetCursor
SDL_ShowCursor

'Ones I don't need but are also missing
SDL_LoadBMP
SDL_SaveBMP
SDL_BlitSurface 'Missing but I don't know if its used
SDL_GLattr


I don't know if you added the other cursor stuff. It is good of you to fix your modules, I appreciate it.


N(Posted 2006) [#52]
SDL_LoadBMP and SDL_SaveBMP are macros for SDL_LoadBMP_RW and its Save equivalent.

SDL_BlitSurface is a macro for SDL_UpperBlit. Nothing changes.

SDL_GLattr isn't a function.

All the cursor functions (WarpMouse included) are already in there.


Robert Cummings(Posted 2006) [#53]
Thanks! :)


Robert Cummings(Posted 2006) [#54]
Hi again noel,

SDL_imageFilterMMXon()

Seems to be missing from SDL_GFX lib


N(Posted 2006) [#55]
Fix uploaded.