Beispiel #1
0
string SoundPlugin::fullName(const char *name)
{
    string sound;
    if ((name == NULL) || (*name == 0))
        return sound;
#ifdef WIN32
    char c = name[0];
    if (((((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) && (name[1] == ':')) ||
            ((c == '\\') && (name[1] == '\\'))){
#else
    if (name[0] == '/'){
#endif
        sound = name;
    }else{
        sound = "sounds/";
        sound += name;
        sound = app_file(sound.c_str());
    }
    return sound;
}

void SoundPlugin::playSound(const char *s)
{
    if ((s == NULL) || (*s == 0))
        return;
    string sound = fullName(s);
#ifdef WIN32
    sndPlaySoundA(sound.c_str(), SND_ASYNC | SND_NODEFAULT);
#else
#ifdef USE_KDE
    if (getUseArts()){
        KAudioPlayer::play(sound.c_str());
        return;
    }
#endif
    ExecParam p;
    p.cmd = getPlayer();
    p.arg = sound.c_str();
    Event e(EventExec, &p);
    e.process();
#endif
}

#ifdef WIN32

/**
 * DLL's entry point
 **/
int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
    return TRUE;
}

/**
 * This is to prevent the CRT from loading, thus making this a smaller
 * and faster dll.
 **/
extern "C" BOOL __stdcall _DllMainCRTStartup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
    return DllMain( hinstDLL, fdwReason, lpvReserved );
}
Beispiel #2
0
extern "C" void WinMainCRTStartup()
{
	//Sleep(15000);
	
	HDC hDC;
	HGLRC context;
	CreateGLWindow(&hDC, &context);
	Demo demo;
	demo.Init();

	MusicInit(music);
	sndPlaySoundA((const char*)&music, SND_ASYNC|SND_MEMORY|SND_LOOP);
    
    do
    {
		demo.Step();
		demo.RenderFrame();
		
		SwapBuffers(hDC);
		AppProcessMessages();
	}
	while(!GetAsyncKeyState(VK_ESCAPE));

    ExitProcess(0);
}