QTfrontend/SDLs.cpp
changeset 2191 20c62f787a4d
parent 2050 8149802b4f14
child 2192 4763a778c033
equal deleted inserted replaced
2190:cfcad6142d48 2191:20c62f787a4d
    21 #include "SDL.h"
    21 #include "SDL.h"
    22 #include "hwconsts.h"
    22 #include "hwconsts.h"
    23 
    23 
    24 SDLInteraction::SDLInteraction()
    24 SDLInteraction::SDLInteraction()
    25 {
    25 {
    26 	music = NULL;
    26 	music = -1;
    27 
    27 
    28 	SDL_Init(SDL_INIT_VIDEO);
    28 	SDL_Init(SDL_INIT_VIDEO);
       
    29 	openal_init(50);
       
    30 
    29 }
    31 }
    30 
    32 
    31 SDLInteraction::~SDLInteraction()
    33 SDLInteraction::~SDLInteraction()
    32 {
    34 {
    33 	SDL_Quit();
    35 	SDL_Quit();
       
    36 	openal_close();
    34 }
    37 }
    35 
    38 
    36 QStringList SDLInteraction::getResolutions() const
    39 QStringList SDLInteraction::getResolutions() const
    37 {
    40 {
    38 	QStringList result;
    41 	QStringList result;
    51 				result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h);
    54 				result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h);
    52 	}
    55 	}
    53 
    56 
    54 	return result;
    57 	return result;
    55 }
    58 }
       
    59 
    56 void SDLInteraction::StartMusic()
    60 void SDLInteraction::StartMusic()
    57 {
    61 {
    58 	if (!music)
    62 	if (music < 0) {
    59     {
    63 		music = openal_loadfile(QString(datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData());
    60    	    SDL_Init(SDL_INIT_AUDIO);
    64 		openal_toggleloop(music);
    61 	    Mix_OpenAudio(22050, 0x8010, 2, 512);
    65 		openal_setvolume(music,66);
    62   
       
    63 	    Mix_VolumeMusic(33);
       
    64 		music = Mix_LoadMUS(QString(datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData());
       
    65     }
    66     }
    66 
    67 	openal_fadein(music, 50);
    67 	Mix_FadeInMusic(music, -1, 3000);
       
    68 }
    68 }
    69 
    69 
    70 void SDLInteraction::StopMusic()
    70 void SDLInteraction::StopMusic()
    71 {
    71 {
    72 	Mix_FadeOutMusic(2000);
    72 	openal_fadeout(music, 50);
    73 }
    73 }