http://rapidshare.com/files/366535729/dshlib_for_cpp_forums_21-Mar-2010.zip.html
Forgive the rapidshare, but I no longer have webhosting.
googlepages doesn't work anymore, geocities is nonexistant, and I lost touch with the guy who was giving me arc-nova space.
Basic usage:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <iostream>
#include "SDL.h"
#include "dshlib/dshlib.h"
int main()
{
using namespace dshlib;
// dshlib doesn't initialize SDL -- do this yourself
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
// initialize the output device
SDLAudioOut audout(44100,2,100); // 44100 KHz, 2 channels (stereo), 100 ms latency
// create a 'BGMSound'. Consists of 2 parts: an "intro" portion
// and a "loop" portion. The intro portion plays once, followed by the
// loop portion which plays repeatedly.
// this looks more complicated than it is. The complication is due to the flexibility you have here.
// SoundSources are loaded from files
// StreamedSounds require a SoundSource (streamed vs. buffered)
// Basically there's a lot of abstraction.
BGMSoundPtr bgm = new BGMSound(
new StreamedSound( SoundSource::Load( new File("introportion.ogg") ) ),
new StreamedSound( SoundSource::Load( new File("loopportion.ogg") ) )
);
// play sounds by playing them in the output device's mixer
audout.GetMixer().PlaySound( bgm );
// enjoy the music
char c;
cin >> c;
// destroy the audio output device before you SDL_Quit
// (or you can have the destructor destroy it -- but make
// sure it happens before you SDL_Quit)
audout.Destroy();
SDL_Quit();
return 0;
}
|
Don't worry about the 'new's, pretty much everything in dshlib uses smart pointers.
I'm working on documentation but it's huge and incomplete, and boring as hell to work on.
Other pieces of dshlib:
-) better random number generators (well better than rand())
-) utf string class(es)
-) CRC32 stuffs
-) zip file reading/writing
-) zlib wrappers
-) abstraction for files, filesystems, and other system constants (not unlike Qt/wx/etc... only not nearly as complete as them)
-) really really basic threads/mutexes which I'm thinking of revamping completely.
Fun stuff.
I'm more than happy to answer any questions. And I'm open to criticism.
EDIT: found a bug in RNGBase. I'll fix tomorrow