Advertisement

SDL Library... Bad or Good ???

Started by April 20, 2003 09:47 AM
37 comments, last by brucesinner 21 years, 10 months ago
quote:
Original post by Angasule
But your post sounds like you just like to reinvent the wheel. Whatever rocks your boat.

*BZZZ* Want to play again?
I hate re-work. If you''ll notice a large percentage of my posts are about code re-use. What I like are good, extensible, OOP, API''s. I''ll wrap API''s often times so that I never ever have to re-write code, I can swap out underlying implementations at any time.

Wrapping is not re-implementing.


- sighuh?
- sighuh?
I dont wanna get into this debate (too much..) but i will say this.

SDL is great, if you think otherwise, you are very mislead.

As for the people saying stuff about using SDL instead of OpenGL WHAT ARE YOU ON, SDL only makes a window for you, unless you wanna use teh Sound, Input, Multi Threading, Timing or CD sub-systems, SDL does not do any 3D code at all, it isint supposed to (as someone said before), it is just like a normal OpenGL App, you use all the same functions, nothing different, no SDL shortcuts.

If anyone is going to post a reply, ATLEAST KNOW what your talking about, ...i assume half the people here have not personally USED SDL.

Smokey`
Advertisement
Yep, SDL is great. No question about that.




Visit
There is *never* a royalty fee involved with the LGPL.
If you dynamically link to SDL, then it''s just like any other lib, save that if you distribute the SDL lib along with your program you must also distribute SDL''s (not your own program''s) source, or provide a way to get it (I guess giving the SDL URL would be ok if it hasn''t been modified?).
If you link statically, then you must release the source code to your own program, too (I think there is talk about this on the SDL list archives, the devs are ok with static link if I recall correctly, but better check out yourself). For most of us, static linking is not a need so the end result is that you have a good library that is free and access to its code, and no obligation to release your own code.
Oh good that I found this topic I just wanted to ask if I should use GLUT or switch to SDL, currently I''m using the GLUT GameMode to go into fullscreen. Older GLUT versions have been known to be slower in fullscreen than say NeHe''s basecode, this should be different with the GameMode now, what about SDL? Does anyone have any experiences with it? I think I should try SDL myself, I''m only interested in switching to fullscreen and handling keyboard/mouse/joystick input. Does SDL support joystick input?

Baraclese
Sorry but GLUT is garbage compared to SDL..

Personally I don''t give a damn if you like SDL or not, I use it a lot. But you have to give it credit for what it does well, and don''t try to mislead other people just because you don''t understand it''s value.


"I think I can do a better job than they can, and I don''t need their library."
Ok, you can waste all your coding time learning DX and have a game that runs only on Windows and Xbox, or you can spend a fraction of that time learning SDL, and have a game *finished* that compiles and runs on nearly everything, never needing to look at a line of DX code..

Two beginners start a project, knowing nothing, one uses SDL one uses so called "real programming" with straight DirectX API.
Who do you (honestly) think will finish first?
Now think, how hard of a time will the DX-er have porting to linux if they later decided to?

"It claims to be better then DirectX but the input only lets two keys be held down at once like the normal Windows API."
Hmm. Strange. That could be BECAUSE IT _USES_ THE WINDOWS API

" It has no 3D support and it all needs to be done in OpenGL."
Why would it have "3d support" when openGL more than takes care of 3D rendering? It''s not a graphics library and I doubt anyone can write one better than SGI has. OpenGL has no input support and nobody is crying about that..

"The 2D commands are sooooo slow!"
Well, it uses DirectX for blitting, so you are calling DirectX slow? (BTW - an alternative is to learn how to do 2D with OpenGL...I think it''s called "glOrtho2D" look it up)

"What worries me the most is that you never really now EXACTLY what the library is doing..."
It''s OPEN SOURCE so you DO know EXACTLY what it does.
Grab the source and look around, if you don''t like it, fix it.

"I can''t remember it claiming to be better that DirectX, and since it actually uses DirectX this struck me as being strange"
I believe it was bloodshed.net (of DevC++ fame) who started this. It''s not true. It wraps DX. But it''s much easier to use and does all the same things DX can (just that it can also do it on Linux/Mac/all OS''s and not only windows, like DX..)
So to me, that''s much better.

"I don''t think a pro would use SDL "
Really? John Carmack and Loki/Blizzard use SDL for their linux ports? Are they "pros" ?

"Alot of people are just too lazy to do anything themselves, or even learn anything themselves..."
Using SDL virtually replaces the need to learn DX, glX, much of the Win32API, and various other OS''s APIs which to me is a complete waste of time. I have many other things I can be learning (like OpenGL) rather than "Duhh, how do I make an opengl window in *THIS* OS?"

this place is lame
Advertisement
quote:
Original post by Scet
I agree with neurokaotix. I don''t like depending on other peoples libraries for programming. Ive never used GLUT and I perfer to do "real" programming using the API calls. If I was programming for Linux or MAC I would do it the same way.

I have used SDL and I didn''t think it was that great. It claims to be better then DirectX but the input only lets two keys be held down at once like the normal Windows API. It has no 3D support and it all needs to be done in OpenGL. The 2D commands are sooooo slow! and it doesn''t even come with sound you need to download an extra mixer library.


Get your facts straight before posting. SDL when used with windows wraps around DX. So it can''t really be better, it''s just a simpler way to use DX instead of having to mess with the APIs directly. It save alot of time when porting games to many platforms as you only have to program the SDL code once and you should be able to just compile the code on all supported platform without having to change the code. As for Neurokaotix''s rant about being able to do better, there will always be better solutions than the one suggested.


[Cyberdrek | the last true sorcerer | Spirit Mage - mutedfaith.com][ Administrator TheLinuxForum.tk]
[Cyberdrek | ]
quote:
Original post by Shadow_0f_Light
The thing about using SDL isn''t that it wonderfully does every thing for you... but what do you really learn? What happens one day when your all growed up and have to write a program for you employer and all you know how to do is use SDL rather than actually use DirectX or OpenGl? It seems to me that rather than do the work you self you just stand on what some one else has done. Sure that''s what it''s meant to do, but I''d rather know that I wrote every line of code and that when it finally eats it self (and it will, there is always a problem you didn''t see) that it''s not because of some library I based my program on. I guess the problem that get''s me the most is that if you go into a forum lately there are almost more requests for working code than there is for actual help. It''s not the I enjoy ''reinventing the wheel'' I just think that the clunky old wagon wheel could be redesigned... and if no one is willing to take the time to improve it, then I pray to God I don''t get stuck programming with any of you. Just to clarify my stand point any of you who prefer to code it your self I''d be glad to help... (wow I was really harsh)...


When you work for a company, telling your boss, I can write that app but it''ll take me 2 months because I don''t want to use a wrapper ( which is de defacto at the company, for instance ) will only get you fired. Especially if you can get the job done with the wrapper in less time say 2 or 3 weeks. Boss'' want the programs to be shipped to the clients ASAP. Not some dork who thinks he can rewrite the world just because he prefers that his code breaks rather than a proven API...




[Cyberdrek | the last true sorcerer | Spirit Mage - mutedfaith.com][ Administrator TheLinuxForum.tk]
[Cyberdrek | ]

quote:
Original post by Scet
and it doesn''t even come with sound you need to download an extra mixer library.


YOUR BRAIN IS RUNNING WHEN YOU WRITE ???

DO YOU KNOW WHAT THE HELL YOU ARE TALKING ABOUT ???

I THINK YOU HAVE NEVER READ CHAP 10 OF SDL

Chapter 10. Audio
Table of Contents
SDL_AudioSpec — Audio Specification Structure
SDL_OpenAudio — Opens the audio device with the desired parameters.
SDL_PauseAudio — Pauses and unpauses the audio callback processing
SDL_GetAudioStatus — Get the current audio state
SDL_LoadWAV — Load a WAVE file
SDL_FreeWAV — Frees previously opened WAV data
SDL_AudioCVT — Audio Conversion Structure
SDL_BuildAudioCVT — Initializes a SDL_AudioCVT structure for conversion
SDL_ConvertAudio — Convert audio data to a desired audio format.
SDL_MixAudio — Mix audio data
SDL_LockAudio — Lock out the callback function
SDL_UnlockAudio — Unlock the callback function
SDL_CloseAudio — Shuts down audio processing and closes the audio device.
Sound on the computer is translated from waves that you hear into a series of values, or samples, each representing the amplitude of the wave. When these samples are sent in a stream to a sound card, an approximation of the original wave can be recreated. The more bits used to represent the amplitude, and the greater frequency these samples are gathered, the closer the approximated sound is to the original, and the better the quality of sound.

This library supports both 8 and 16 bit signed and unsigned sound samples, at frequencies ranging from 11025 Hz to 44100 Hz, depending on the underlying hardware. If the hardware doesn''t support the desired audio format or frequency, it can be emulated if desired (See SDL_OpenAudio())

A commonly supported audio format is 16 bits per sample at 22050 Hz.

/***************************************/

the extra library you mean is SDL_MIXER(always sdl)

NOW here ALL ( i say ALL ) the code you need to play background music with SDL_MIXER
it work with files:
-wav
-mod
-it
-s3m
-XM
and others that i dont imagine

void musica ( Mix_Music *music,char *song )

{
int audio_rate=22050;
Uint16 audio_format=MIX_DEFAULT_FORMAT;
int audio_channels=1;
int audio_buffers=8192;

Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers);

Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);

Mix_SetMusicCMD(getenv("MUSIC_CMD"));
music = Mix_LoadMUS(song);
Mix_VolumeMusic(MIX_MAX_VOLUME );
Mix_PlayMusic(music, -1);
}


void stop_musica ( Mix_Music *music )
{

Mix_HaltMusic();
Mix_FreeMusic(music);
music = NULL;
}
Dont you just love it when people trash something that they dont know anything about? I am all for SDL, here is why.
Its 2D API with OpenGL support by some calls.
Its has support for input, drawing, sound, cdrom. (native)
You can easly use other libs with SDL, like networking, more sound and graphic formats.
Its cross platform.
Its simple to use, its easy to setup. Like most of you know, to get a basic window up would take about a few lines of code, around 10.

The reason why yuo dont get 200+ fps is because your hardware is optimized to render 3d much faster then 2d sprites. But for what SDL is I think its great.

If you want to just program for windows I would still use SDL, but if you want to use DX go for it. For the people that go on about how SDL is slow and you could write something better. Why not do it? Make your code faster then SDL while keeping it cross platform? Send it in to SDL so it can be used by many people. I think its stupid to rewrite everything you do. Hell I hate rewriting an SDL app over and over, so I made a framework. But its better then writing 150 lines of code compared to 10.

I got an idea, why not make an API that is just like SDL BUT! It doesnt use the system libs but you write your own code to do everything from drawing, to sound, to input. That way you can make it really fast! But I am sure you wouldnt be kind enough to make it free.

SDL is great for what it was made to do. Its ment to be generic with basic support for drawing, input, sound. If you want to add stuff go for it.
Interested in being apart of a team of people that are developing a toolkit that can help anyone product an online game? Then click here http://tangle.thomson.id.au/

This topic is closed to new replies.

Advertisement