Ejemplo n.º 1
0
/*
	WM_COMMAND
*/
VOID DlgPlayList::Cls_OnCommand(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
{
	switch (id)
	{
		case IDC_PLAYLIST:
		{
			if (codeNotify == LBN_DBLCLK)
			{
				INT idx = SendMessage(hPlayList, LB_GETCURSEL, 0, 0);			//получение индекса выделенного элемента
				Application::_this->hStream = songs[idx].hStream;				//присвоение основному потоку поток выбранного элемента
				Application::_this->secPlaying = 0;								//обнуление секунд
				Application::_this->setRangeTrackBarPlaySong(Application::_this->hStream);		//установка диапазона для полосы прокурутки
				DlgEqualizer::_this->SetFX(Application::_this->hStream);		//установка настроек для каналов регуляции звучания
				BASS_Stop();			//остановка потока
				BASS_ChannelStop(Application::_this->hStream);		//остановка канала
				BASS_Start();			//запуск потока
				BASS_ChannelPlay(Application::_this->hStream, TRUE);	//запуск канала
				SetTimer(GetParent(hDlg), Application::_this->id_timer, 1000, 0);			//запуск таймера для времени проигрывания
				SetTimer(GetParent(hDlg), Application::_this->idTimerBySpectr, 100, 0);		//запуск таймера для спектра
				BASS_ChannelSetAttribute(Application::_this->hStream, BASS_ATTRIB_VOL, Application::_this->numVolume);
			}
			break;
		}
		case IDC_ADDSONG:
		{
			SendMessage(GetParent(hwnd), WM_COMMAND, IDC_ADDSONG, 0);
			break;
		}
		default:
			break;
	}
}
Ejemplo n.º 2
0
/*
	Play
*/
VOID Application::play(HSTREAM stream)
{
	BASS_Start();
	BASS_ChannelPlay(stream, TRUE);
	equalizer.SetFX(stream);
	BASS_ChannelSetAttribute(stream, BASS_ATTRIB_VOL, numVolume);
}
Ejemplo n.º 3
0
/// <summary>
/// Reanuda la reproducción de audio (LShift + R).
/// </summary>
void CSoundManager::Resume()
{
	bool result = BASS_Start()?true:false;

	if (result == false)
	{
		// Guarda mensaje de error en el log
		std::string msg_error = "CSoundManager::Pause->Error al reanudar la reproducción del audio.";
		LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str());
		throw CException(__FILE__, __LINE__, msg_error);
	}
}
Ejemplo n.º 4
0
void LoadedSample::PlaySample ()
{
    if ( m_playing ) BASS_Start();
    else
    {
        m_channel = BASS_SampleGetChannel( m_sample, FALSE );
		BOOL ret = BASS_ChannelPlay(m_channel, FALSE); 
		int err =BASS_ErrorGetCode();

		int x = 0;
    }
}
Ejemplo n.º 5
0
void Player::play(QString stationId) {

    stop();
    if( !playList.contains(stationId))
    {
        return;
    }

    HSTREAM stream = BASS_StreamCreateURL(playList.value(stationId).toStdString().c_str(),0,BASS_STREAM_BLOCK|BASS_STREAM_STATUS|BASS_STREAM_AUTOFREE,MyDownload,0);

    BASS_Start();

    if( stream)
    {
        bool buffering = true;
        while(buffering)
        {
            QWORD progress = BASS_StreamGetFilePosition(stream,BASS_FILEPOS_BUFFER)*100/BASS_StreamGetFilePosition(stream,BASS_FILEPOS_END);
            webView()->page()->mainFrame()->evaluateJavaScript(QString("PlayerHud.updateBufforStatus("+ QString::number(progress) +")"));
            if( progress>=100)
            {
                buffering = false;
                webView()->page()->mainFrame()->evaluateJavaScript("PlayerHud.clearBufforStatus()");
            }

        }
        const char *meta=BASS_ChannelGetTags(stream,BASS_TAG_META);
        if( !meta)
        {
            meta = BASS_ChannelGetTags(stream,BASS_TAG_OGG);
        }
        if( meta)
        {
            qDebug() << meta;
            QRegularExpression rx("StreamTitle='(.+)';StreamUrl");
            QRegularExpressionMatch match = rx.match(QString(meta));
            if (match.hasMatch()) {
                qDebug() << match.captured(1);
                webView()->page()->mainFrame()->evaluateJavaScript("setRadiostationTag('"+ match.captured(1) +"')");
            }
        }
        BASS_ChannelPlay(stream,FALSE);
        playStatus = true;

    }
    else
    {
        qDebug() << BASS_ErrorGetCode();
        return;
    }
    return;
}
Ejemplo n.º 6
0
/*************************************************************************
* Initialize bass
*************************************************************************/
void InitSound() 
{
	if (!BASS_Init(-1, 44100, 0, g_hWnd, 0)) {
		OutputDebugString("Failed to initialize bass");
		ExitProcess(0);
	}

	g_stream = BASS_StreamCreateFile(false, "../data/4kintro.mp3", 0, 0, 0);
	if (!g_stream) {
		OutputDebugString("Failed to load mp3");
		ExitProcess(0);
	}
	BASS_Start();
	BASS_ChannelPlay(g_stream, false);
}
Ejemplo n.º 7
0
/// <summary>
/// Inicializa los canales de sonido.
/// </summary>
///<param name="initSoundXML">Ubicación del fichero xml.</param>
///<returns>Boleano que representa si la operación se realizó exitosamente.</returns>
bool CSoundManager::Init (const std::string& initSoundXML)
{
	m_bIsOk = BASS_Init(1, 44100, BASS_DEVICE_3D, 0, NULL) ? true : false;
 

	if (m_bIsOk == true)
	{
		// Parsea el xml
		m_bIsOk = Load(initSoundXML);

		if (m_bIsOk == true)
		{
			m_bIsOk = BASS_Set3DPosition(NULL, NULL, NULL, NULL) ? true : false; 
				
			if (m_bIsOk == true)
			{
				m_bIsOk = BASS_Set3DFactors(1.0, 1.0, 1.0) ? true : false;
				BASS_Apply3D();

				if (m_bIsOk == true)
				{					
					// Asigna el master volume. Usar 1 para volumen máximo
					//m_bIsOk = BASS_SetVolume(1.0f) ? true : false;

					if (m_bIsOk == true)
					{
						m_bIsOk = BASS_Start() ? true : false;

						if (m_bIsOk == true)
						{
							std::string msg_info = "CSoundManager::Init: Sonidos cargados exitosamente.";
							LOGGER->AddNewLog(ELL_INFORMATION, msg_info.c_str());
							return m_bIsOk;
						}
					}
				}
			}
		}
	}
	std::string msg_error = "CSoundManager::Init: Error cargando sonidos.";
	LOGGER->AddNewLog(ELL_INFORMATION, msg_error.c_str());
	return m_bIsOk;
}
Ejemplo n.º 8
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CSoundSystem
//  - prototype : bool Init(HWND hWnd)
//
//  - Purpose   : Initializes sound system.
//
// -----------------------------------------------------------------------------
bool CSoundSystem::Init(HWND hWnd)
{
    if(m_bActive)
    {
        Close();
    }

    if(BASS_Init(-1, 44100, 0, hWnd) != TRUE)
    {
        CLogger::ErrorWindow("CSoundSystem::Init(): BASS_Init() failed.");
        return false;
    }

    if(BASS_Start() != TRUE)
    {
        CLogger::ErrorWindow("CSoundSystem::Init(): BASS_Start() failed.");
        return false;
    }

    BASS_SetGlobalVolumes(100, 100, 100);

    m_bActive = true;
    return m_bActive;
}
int WINAPI WinMain( HINSTANCE instance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
    MSG         msg;
    int         done=0;
    WININFO     *info = &wininfo;

    info->hInstance = GetModuleHandle( 0 );

    //if( MessageBox( 0, "fullscreen?", info->wndclass, MB_YESNO|MB_ICONQUESTION)==IDYES ) info->full++;

    if (!window_init(info))
    {
        window_end(info);
        MessageBox(0, "window_init()!", "error", MB_OK|MB_ICONEXCLAMATION);
        return 0;
    }

	if (initGL(info))
	{
		return 0;
	}

    //intro_init();

	// start music playback
#ifdef MUSIC
	BASS_Init(-1,44100,0,info->hWnd,NULL);
	HSTREAM mp3Str=BASS_StreamCreateFile(FALSE,"Musik/set1.mp3",0,0,0);
	BASS_ChannelPlay(mp3Str, TRUE);
	BASS_Start();
#endif

	// Initialize COM
	HRESULT hr = CoInitialize(NULL);
	if (FAILED(hr)) exit(-1);

	// Example editor usage
	char errorText[MAX_ERROR_LENGTH+1];
	char filename[SM_MAX_FILENAME_LENGTH+1];
	sprintf_s(filename, SM_MAX_FILENAME_LENGTH, "shaders/%s", usedShader[usedIndex]);
	if (editor.loadText(filename, errorText))
	{
		MessageBox(info->hWnd, errorText, "Editor init", MB_OK);
		return -1;
	}

    long to=timeGetTime();
    while( !done )
        {
		long t = timeGetTime() - to;

        while( PeekMessage(&msg,0,0,0,PM_REMOVE) )
        {
            if( msg.message==WM_QUIT ) done=1;
		    TranslateMessage( &msg );
            DispatchMessage( &msg );
        }

		glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT);

        intro_do(t);
		editor.render(t);

		SwapBuffers( info->hDC );
	}

    window_end( info );

#ifdef MUSIC
	// music uninit
	BASS_ChannelStop(mp3Str);
	BASS_StreamFree(mp3Str);
	BASS_Free();
#endif

	// Un-initialize COM
	CoUninitialize();

    return( 0 );
}
Ejemplo n.º 10
0
void ds::Audio::Start( )
{
	BASS_Start( );
}
Ejemplo n.º 11
0
BOOL CALLBACK dialogproc(HWND h,UINT m,WPARAM w,LPARAM l)
{
	switch (m) {
		case WM_COMMAND:
			switch (LOWORD(w)) {
				case IDCANCEL:
					DestroyWindow(h);
					return 1;
				case 10:
					{
						char file[MAX_PATH]="";
						ofn.lpstrFilter="playable files\0*.mo3;*.xm;*.mod;*.s3m;*.it;*.mtm;*.mp3;*.mp2;*.mp1;*.ogg;*.wav\0All files\0*.*\0\0";
						ofn.lpstrFile=file;
						if (GetOpenFileName(&ofn)) {
							memcpy(path,file,ofn.nFileOffset);
							path[ofn.nFileOffset-1]=0;
							// free both MOD and stream, it must be one of them! :)
							BASS_MusicFree(chan);
							BASS_StreamFree(chan);
							if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,floatable?BASS_SAMPLE_FLOAT:0))
								&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_LOOP|BASS_MUSIC_RAMP|(floatable?BASS_MUSIC_FLOAT:0)))) {
								// whatever it is, it ain't playable
								MESS(10,WM_SETTEXT,0,"click here to open a file...");
								Error("Can't play the file");
								break;
							}
							if (BASS_ChannelGetFlags(chan)&BASS_SAMPLE_MONO) {
								// mono = not allowed
								MESS(10,WM_SETTEXT,0,"click here to open a file...");
								BASS_MusicFree(chan);
								BASS_StreamFree(chan);
								Error("mono sources are not supported");
								break;
							}
							MESS(10,WM_SETTEXT,0,file);
							// setup DSPs on new channel
							SendMessage(win,WM_COMMAND,11,0);
							SendMessage(win,WM_COMMAND,12,0);
							SendMessage(win,WM_COMMAND,13,0);
							// play both MOD and stream, it must be one of them!
							BASS_MusicPlay(chan);
							BASS_StreamPlay(chan,0,BASS_SAMPLE_LOOP);
						}
					}
					return 1;
				case 11: // toggle "rotate"
					if (MESS(11,BM_GETCHECK,0,0)) {
						rotpos=0.7853981f;
						rotdsp=BASS_ChannelSetDSP(chan,&Rotate,0);
					} else
						BASS_ChannelRemoveDSP(chan,rotdsp);
					break;
				case 12: // toggle "echo"
					if (MESS(12,BM_GETCHECK,0,0)) {
						memset(echbuf,0,sizeof(echbuf));
						echpos=0;
						echdsp=BASS_ChannelSetDSP(chan,&Echo,0);
					} else
						BASS_ChannelRemoveDSP(chan,echdsp);
					break;
				case 13: // toggle "flanger"
					if (MESS(13,BM_GETCHECK,0,0)) {
						memset(flabuf,0,sizeof(flabuf));
						flapos=0;
					    flas=FLABUFLEN/2;
					    flasinc=0.002f;
						fladsp=BASS_ChannelSetDSP(chan,&Flange,0);
					} else
						BASS_ChannelRemoveDSP(chan,fladsp);
					break;
			}
			break;

		case WM_INITDIALOG:
			win=h;
			GetCurrentDirectory(MAX_PATH,path);
			memset(&ofn,0,sizeof(ofn));
			ofn.lStructSize=sizeof(ofn);
			ofn.hwndOwner=h;
			ofn.hInstance=inst;
			ofn.nMaxFile=MAX_PATH;
			ofn.lpstrInitialDir=path;
			ofn.Flags=OFN_HIDEREADONLY|OFN_EXPLORER;
			// initialize - default device, 44100hz, stereo, 16 bits, floating-point DSP
			if (!BASS_Init(-1,44100,BASS_DEVICE_FLOATDSP,win)) {
				Error("Can't initialize device");
				DestroyWindow(win);
				return 1;
			}
			BASS_Start();
			// check for floating-point capability
			floatable=BASS_StreamCreate(44100,BASS_SAMPLE_FLOAT,NULL,0);
			if (floatable) BASS_StreamFree(floatable); // woohoo!
			return 1;
	}
	return 0;
}
Ejemplo n.º 12
0
void main(int argc, char **argv)
{
	BUFSTUFF b,b2;
	BASS_3DVECTOR p={0,0,0};

	printf("BASS 2 stereo channels on 4 speakers example : MOD/MPx/OGG/WAV\n"
			"--------------------------------------------------------------\n"
			"       Set your soundcard's output to 4 or 5.1 speakers\n");

	/* check that BASS 1.6 was loaded */
	if (BASS_GetVersion()!=MAKELONG(1,6)) {
		printf("BASS version 1.6 was not loaded\n");
		return;
	}

	if (argc!=3) {
		printf("\tusage: 4speaker <file1> <file2>\n");
		return;
	}

	/* setup output - default device, 44100hz, stereo, 16 bits */
	if (!BASS_Init(-1,44100,BASS_DEVICE_3D,0))
		Error("Can't initialize device");

	/* try initializing the 1st (front) file */
	if (!(b.dstr=BASS_StreamCreateFile(FALSE,argv[1],0,0,BASS_STREAM_DECODE)))
		if (!(b.dstr=BASS_MusicLoad(FALSE,argv[1],0,0,BASS_MUSIC_DECODE|BASS_MUSIC_RAMPS)))
			Error("Can't play the 1st file");
	if (BASS_ChannelGetFlags(b.dstr)&BASS_SAMPLE_MONO)
		Error("The 1st stream is mono!");

	/* try initializing the 2nd (rear) file */
	if (!(b2.dstr=BASS_StreamCreateFile(FALSE,argv[2],0,0,BASS_STREAM_DECODE)))
		if (!(b2.dstr=BASS_MusicLoad(FALSE,argv[2],0,0,BASS_MUSIC_DECODE|BASS_MUSIC_RAMPS)))
			Error("Can't play the 2nd file");
	if (BASS_ChannelGetFlags(b2.dstr)&BASS_SAMPLE_MONO)
		Error("The 2nd stream is mono!");

	printf("front : %s\n",argv[1]);
	printf("rear  : %s\n",argv[2]);

	/* Get sample rates and allocate buffers */
	BASS_ChannelGetAttributes(b.dstr,&b.freq,0,0);
	b.buf=malloc(b.freq*4); // 1 sec buffer
	BASS_ChannelGetAttributes(b2.dstr,&b2.freq,0,0);
	b2.buf=malloc(b2.freq*4); // 1 sec buffer

	/* Create streams to play the 1st decoded data, and link them */
	b.lstr=BASS_StreamCreate(b.freq,BASS_SAMPLE_MONO|BASS_SAMPLE_3D,(STREAMPROC*)&stream_left,(DWORD)&b);
	b.rstr=BASS_StreamCreate(b.freq,BASS_SAMPLE_MONO|BASS_SAMPLE_3D,(STREAMPROC*)&stream_right,(DWORD)&b);
	BASS_ChannelSetLink(b.lstr,b.rstr);

	/* Create streams to play the 2nd decoded data, and link them */
	b2.lstr=BASS_StreamCreate(b2.freq,BASS_SAMPLE_MONO|BASS_SAMPLE_3D,(STREAMPROC*)&stream_left,(DWORD)&b2);
	b2.rstr=BASS_StreamCreate(b2.freq,BASS_SAMPLE_MONO|BASS_SAMPLE_3D,(STREAMPROC*)&stream_right,(DWORD)&b2);
	BASS_ChannelSetLink(b2.lstr,b2.rstr);

	/* position the streams */
	p.z=3; // front
	p.x=-1.5; // left
	BASS_ChannelSet3DPosition(b.lstr,&p,0,0);
	p.x=1.5; // right
	BASS_ChannelSet3DPosition(b.rstr,&p,0,0);
	p.z=-3; // rear
	p.x=-1.5; // left
	BASS_ChannelSet3DPosition(b2.lstr,&p,0,0);
	p.x=1.5; // right
	BASS_ChannelSet3DPosition(b2.rstr,&p,0,0);
	BASS_Apply3D();

	BASS_Start();
	/* start it! */
	b.writepos=b.readposl=b.readposr=0;
	BASS_StreamPlay(b.lstr,FALSE,0); // start front
	b2.writepos=b2.readposl=b2.readposr=0;
	BASS_StreamPlay(b2.lstr,FALSE,0); // start rear

	while (!_kbhit() && (BASS_ChannelIsActive(b.lstr) || BASS_ChannelIsActive(b2.lstr))) {
		/* display some stuff and wait a bit */
		printf("pos %09I64d %09I64d - cpu %.1f%%  \r",
			BASS_ChannelGetPosition(b.lstr)*2,BASS_ChannelGetPosition(b2.lstr)*2,BASS_GetCPU());
		Sleep(50);
	}

	BASS_Free();
	free(b.buf);
}
//WinMain -- Main Window
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine, int nCmdShow )
{
    MSG msg;
    msg.message = WM_CREATE;

    WNDCLASS wc;
    wc.style = CS_HREDRAW|CS_VREDRAW;
    wc.lpfnWndProc = WindowProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(GetModuleHandle(NULL), IDI_APPLICATION);
    wc.hCursor = LoadCursor (NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = "chockngt";

    RegisterClass (&wc);

    // Create the window
    //mainWnd = CreateWindow (szAppName,szAppName,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,CW_USEDEFAULT,CW_USEDEFAULT,1024,600,0,0,hInstance,0);
    mainWnd = CreateWindow("chockngt","chockngt",WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,hInstance,0);
    glInit();

    ShowWindow(mainWnd,SW_SHOW);
    UpdateWindow(mainWnd);

    // Initialize Swarm positions and stuff
    initSwarm();

    long startTime = timeGetTime();
    long lastTime = 0;

    // start music playback
    BASS_Init(-1,44100,0,mainWnd,NULL);
    mp3Str=BASS_StreamCreateFile(FALSE,"GT_muc.mp3",0,0,0);
    BASS_ChannelPlay(mp3Str, TRUE);
    BASS_Start();
    float fCurTime;
    GetAsyncKeyState(VK_ESCAPE);

    do
    {
        SetCursor(FALSE);

        while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
        {
            if (!IsDialogMessage(mainWnd, &msg))
            {
                TranslateMessage (&msg);
                DispatchMessage (&msg);
            }
        }
        if (msg.message == WM_QUIT) break; // early exit on quit

        // update timer
        long curTime = timeGetTime() - startTime;
        fCurTime = (float)curTime * 0.001f;
        long deltaTime = curTime - lastTime;
        float fDeltaTime = (float) deltaTime * 0.001f;
        lastTime = curTime;

        // render
        wglMakeCurrent(mainDC, mainRC);

        glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glDisable(GL_DEPTH_TEST);

        // draw background
        //drawQuad(-1.0f, 1.0f, -1.0f, 1.0f, 0.4f, 1.0f, 1.0f);
        glEnable(GL_DEPTH_TEST);

        // Distance to the center object
        // TODO: Hitchcock-effect by means of gluPerspective!
        float cameraDist = 20.0f;
        float cameraComeTime = 150.0f;
        if (fCurTime > cameraComeTime)
        {
            cameraDist = 3.0f + 17.0f / (1.0f + 0.1f * ((fCurTime - cameraComeTime) * (fCurTime - cameraComeTime)));
        }

        // set up matrices
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        // TODO aspect
        //gluPerspective(25.0,  1.8, 0.1, 100.0);
        gluPerspective(500.0f / cameraDist,  1.8, 0.1, 100.0);
        //gluPerspective(25.0,  1.8, 1.1, 100.0);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        //gluLookAt(0.0, 0.0, -cameraDist,
        //		  0.0, 0.0, 0.0,
        //		  0.0, 1.0, 0.0);
        gluLookAt(1., 0.5, -cameraDist,
                  1., 0.5, 0.0,
                  0.0, 1.0, 0.0);


        // lighting:
        float ambient[4] = {0.3f, 0.23f, 0.2f, 1.0f};
        //float diffuse[4] = {1.8f, 1.7f, 0.8f, 1.0f};
        float diffuse[4] = {0.9f, 0.85f, 0.4f, 1.0f};
        float diffuse2[4] = {0.45f, 0.475f, 0.2f, 1.0f};
        //float diffuse2[4] = {0.0f, 0.0f, 0.0f, 1.0f};
        float specular[4] = {1.0f, 1.0f, 1.0f, 1.0f};
        float lightDir[4] = {0.7f, 0.0f, 0.7f, 0.0f};
        float allOnes[4] = {1.0f, 1.0f, 1.0f, 1.0f};
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
        glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
        glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
        glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
        glLightfv(GL_LIGHT0, GL_POSITION, lightDir);
        //glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, allOnes);
        //glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, allOnes);
        //glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, allOnes);
        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

        float metaAmount = 1.0f;
        int signedDistanceID = 1; // sphere
        if (fCurTime > 61.0f) signedDistanceID = 2; // metaballs
        //signedDistanceID = 0; // nothing

        int pathID = 0; // 8 moveTo points
        if (fCurTime > 80.0f)
        {
            pathID = 1; // 4 lines
            signedDistanceID = 0; // Nothing

            if (fCurTime > 130.0f)
            {
                pathID = 0; // 4 move to points
                signedDistanceID = 2; // metaballs
            }
        }

        // In reversed field
        if (fCurTime > 170.0f)
        {
            pathID = 0;
            signedDistanceID = 2;
            if (fCurTime > 190.0f)
            {
                pathID = 1;
                signedDistanceID = 0;
            }
            if (fCurTime > 210.0f)
            {
                pathID = 1;
                signedDistanceID = 2;
            }
            if (fCurTime > 217.0f)
            {
                pathID = 0;
                signedDistanceID = 1;
            }
        }

        // generate destiations
        float overshoot = 0.0f;
        if (fCurTime > 19.f)
        {
            float relTime = fCurTime - 19.f;
            overshoot = 2.0f * sin(relTime*0.17f) * (-cos(relTime * 0.75f) + 1.0f);
        }
        if (fCurTime > 200.0f)
        {
            float relTime = (fCurTime - 200.0f);
            overshoot /= relTime * relTime + 1.0f;
        }
        updateSwarmDestinations(pathID, fDeltaTime, overshoot);

        // update direction of the Triangles
        updateSwarmWithSignedDistance(signedDistanceID, fDeltaTime, metaAmount);

        // move all triangles
        moveSwarm(fDeltaTime);

        // Set how many triangles to render for each path
        int numTrisRender1 = (curTime - 11300) / 8;
        int numTrisRender2 = (curTime - 3300) / 2;
        numTrisRender1 = numTrisRender1 > NUM_TRIANGLES ? NUM_TRIANGLES : numTrisRender1;
        numTrisRender1 = numTrisRender1 < 0 ? 0 : numTrisRender1;
        numTrisRender2 = numTrisRender2 > NUM_TRIANGLES ? NUM_TRIANGLES : numTrisRender2;
        numTrisRender2 = numTrisRender2 < 0 ? 0 : numTrisRender2;
        float triBrightness = fCurTime / 30.0f + 0.2f;
        if (triBrightness > 1.0f) triBrightness = 1.0f;

        // render tris
        glBegin(GL_TRIANGLES);
        for (int i = 0; i < numTrisRender1; i++)
        {
            //glNormal3f(0.3f, 0.5f, 0.2f);
            float right[3];
            right[0] = tris.direction[i][1] * tris.normal[i][2] - tris.direction[i][2] * tris.normal[i][1];
            right[1] = tris.direction[i][2] * tris.normal[i][0] - tris.direction[i][0] * tris.normal[i][2];
            right[2] = tris.direction[i][0] * tris.normal[i][1] - tris.direction[i][1] * tris.normal[i][0];
            glNormal3fv(tris.normal[i]);
            glVertex3f(tris.position[i][0] + 0.2f * tris.direction[i][0], tris.position[i][1] + 0.2f * tris.direction[i][1], tris.position[i][2] + 0.2f * tris.direction[i][2]);
            glVertex3f(tris.position[i][0] + 0.2f * right[0], tris.position[i][1] + 0.2f * right[1], tris.position[i][2] + 0.2f * right[2]);
            glVertex3f(tris.position[i][0] - 0.2f * right[0], tris.position[i][1] - 0.2f * right[0], tris.position[i][2] - 0.2f * right[0]);
        }
        glEnd();

        glDepthMask(FALSE);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA,GL_ONE);
        glDisable(GL_LIGHTING);
        float beating = 1.0f - 0.25f * fabsf((float)sin(fCurTime*4.652f));
        glBegin(GL_TRIANGLES);
        for (int i = 0; i < numTrisRender2; i++)
        {
            const float colorA[3] = {0.3f, 0.5f, 1.0f};
            const float colorB[3] = {1.0f, 0.8f, 0.3f};
            const float colorC[3] = {2.0f, 0.4f, 0.1f};
            float color[3];
            float colorT = fCurTime * 0.01f;
            if (colorT > 1.0f) colorT = 1.0f;
            for (int c = 0; c < 3; c++)
            {
                color[c] = colorA[c] * (1.0f - colorT) + colorT * colorB[c];
            }
            if (fCurTime > 100.0f)
            {
                colorT = (fCurTime - 100.0f) * 0.1f - ((i*i*17)%63) * 0.1f;
                if (colorT < 0.0f) colorT = 0.0f;
                if (colorT > 1.0f) colorT = 1.0f;
                for (int c = 0; c < 3; c++)
                {
                    color[c] = colorB[c] * (1.0f - colorT) + colorT * colorC[c];
                }
            }
            // Some color noise
            for (int c = 0; c < 3; c++)
            {
                float n = ((((i*i+13)*(c*c+7)+(i*(c+1))) % 100) - 50) * 0.0025f;
                color[c] += n;
            }

            //glNormal3f(0.3f, 0.5f, 0.2f);
            glColor4f(color[0], color[1], color[2], beating * 0.1f * triBrightness);
            float right[3];
            right[0] = tris.direction[i][1] * tris.normal[i][2] - tris.direction[i][2] * tris.normal[i][1];
            right[1] = tris.direction[i][2] * tris.normal[i][0] - tris.direction[i][0] * tris.normal[i][2];
            right[2] = tris.direction[i][0] * tris.normal[i][1] - tris.direction[i][1] * tris.normal[i][0];
            glNormal3fv(tris.normal[i]);
            glVertex3f(tris.position[i][0] + 0.6f * tris.direction[i][0],
                       tris.position[i][1] + 0.6f * tris.direction[i][1],
                       tris.position[i][2] + 0.6f * tris.direction[i][2] - 0.1f);
            glVertex3f(tris.position[i][0] + 0.6f * right[0] - 0.2f * tris.direction[i][0],
                       tris.position[i][1] + 0.6f * right[1] - 0.2f * tris.direction[i][1],
                       tris.position[i][2] + 0.6f * right[2] - 0.2f * tris.direction[i][2] - 0.001f);
            glVertex3f(tris.position[i][0] - 0.6f * right[0] - 0.2f * tris.direction[i][0],
                       tris.position[i][1] - 0.6f * right[0] - 0.2f * tris.direction[i][1],
                       tris.position[i][2] - 0.6f * right[0] - 0.2f * tris.direction[i][2] - 0.001f);
        }
        glEnd();
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glDisable(GL_DEPTH_TEST);
        glBegin(GL_TRIANGLES);
        if (fCurTime > 219.0f)
        {
            float alpha = (fCurTime - 219.0f) * 0.5f;
            alpha = alpha > 1.0f ? 1.0f : alpha;
            glColor4f(0.0f, 0.0f, 0.0f, alpha);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();
            glVertex3f(-180.0f, 180.0f, 1.0f);
            glVertex3f(180.0f, 0.0f, 1.0f);
            glVertex3f(-180.0f, -180.0f, 1.0f);
        }
        glEnd();
        glDepthMask(TRUE);

        // draw credits
        if (fCurTime > 221.0f)
        {
            float alpha = (fCurTime - 221.0f) * 1.0f;
            alpha = alpha > 1.0f ? 1.0f : alpha;
            drawQuad(-1.3f, 0.7f, -0.1f, 0.4f, 0.0f, 0.175f, alpha);
            drawQuad(-0.7f, 1.3f, -0.5f, 0.0f, 0.175f, 0.35f, alpha);
        }

        glEnable(GL_DEPTH_TEST);
        glDisable(GL_BLEND);


        //glColor3ub(200, 100, 50);
        //glEnable(GL_BLEND);
        //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

        // swap buffers
        wglSwapLayerBuffers(mainDC, WGL_SWAP_MAIN_PLANE);

        //Sleep(5);
    } while (msg.message != WM_QUIT && fCurTime < 230.0f && !GetAsyncKeyState(VK_ESCAPE));

    // music uninit
    BASS_ChannelStop(mp3Str);
    BASS_StreamFree(mp3Str);
    BASS_Free();

    glUnInit();

    return msg.wParam;
}
Ejemplo n.º 14
0
int main(int argc, char *argv[])
{
	int ret = 0;
	try {
		// initialize directx 
		IDirect3D9 *d3d = Direct3DCreate9(D3D_SDK_VERSION);
		if (!d3d)
			throw std::string("This application requires DirectX 9");

		// create a window
		HWND hwnd = CreateWindowEx(0, "static", "GNU Rocket Example",
		    WS_POPUP | WS_VISIBLE, 0, 0, width, height, 0, 0,
		    GetModuleHandle(0), 0);

		// create the device
		IDirect3DDevice9 *device = NULL;
		static D3DPRESENT_PARAMETERS present_parameters = {width,
		    height, D3DFMT_X8R8G8B8, 3, D3DMULTISAMPLE_NONE, 0,
		    D3DSWAPEFFECT_DISCARD, 0, WINDOWED, 1, D3DFMT_D24S8,
		    0, WINDOWED ? 0 : D3DPRESENT_RATE_DEFAULT, 0
		};
		if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT,
		    D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING,
		    &present_parameters, &device)))
			throw std::string("Failed to create device");

		// init BASS
		int soundDevice = 1;
		if (!BASS_Init(soundDevice, 44100, 0, hwnd, 0))
			throw std::string("Failed to init bass");

		// load tune
		HSTREAM stream = BASS_StreamCreateFile(false, "tune.ogg", 0, 0,
		    BASS_MP3_SETPOS | (!soundDevice ? BASS_STREAM_DECODE : 0));
		if (!stream)
			throw std::string("Failed to open tune");

		// let's just assume 150 BPM (this holds true for the included tune)
		float bpm = 150.0f;

		// setup timer and construct sync-device
		BassTimer timer(stream, bpm, 8);
		std::auto_ptr<sync::Device> syncDevice = std::auto_ptr<sync::Device>(
		    sync::createDevice("sync", timer));
		if (!syncDevice.get())
			throw std::string("Failed to connect to host?");

		// get tracks
		sync::Track &clearRTrack = syncDevice->getTrack("clear.r");
		sync::Track &clearGTrack = syncDevice->getTrack("clear.g");
		sync::Track &clearBTrack = syncDevice->getTrack("clear.b");

		sync::Track &camRotTrack  = syncDevice->getTrack("cam.rot");
		sync::Track &camDistTrack = syncDevice->getTrack("cam.dist");

		LPD3DXMESH cubeMesh = NULL;
		if (FAILED(D3DXCreateBox(device, 1.0f, 1.0f, 1.0f, &cubeMesh, NULL)))
			return -1;

		// let's roll!
		BASS_Start();
		timer.play();

		bool done = false;
		while (!done) {
			float row = float(timer.getRow());
			if (!syncDevice->update(row))
				done = true;

			// setup clear color
			D3DXCOLOR clearColor(clearRTrack.getValue(row), clearGTrack.getValue(row), clearBTrack.getValue(row), 0.0);

			// paint the window
			device->BeginScene();
			device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, clearColor, 1.0f, 0);

/*			D3DXMATRIX world;
			device->SetTransform(D3DTS_WORLD, &world); */

			float rot = camRotTrack.getValue(row);
			float dist = camDistTrack.getValue(row);
			D3DXVECTOR3 eye(sin(rot) * dist, 0, cos(rot) * dist);
			D3DXVECTOR3 at(0, 0, 0);
			D3DXVECTOR3 up(0, 1, 0);
			D3DXMATRIX view;
			D3DXMatrixLookAtLH(&view, &(eye + at), &at, &up);
			device->SetTransform(D3DTS_WORLD, &view);

			D3DXMATRIX proj;
			D3DXMatrixPerspectiveFovLH(&proj, D3DXToRadian(60), 4.0f / 3, 0.1f, 1000.f);
			device->SetTransform(D3DTS_PROJECTION, &proj);

			cubeMesh->DrawSubset(0);

			device->EndScene();
			device->Present(0, 0, 0, 0);

			BASS_Update(0); // decrease the chance of missing vsync
			MSG msg;
			while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
				TranslateMessage(&msg);
				DispatchMessage(&msg);

				if (WM_QUIT == msg.message) done = true;
				if ((WM_KEYDOWN == msg.message) && (VK_ESCAPE == LOWORD(msg.wParam))) done = true;
			}
		}

		BASS_StreamFree(stream);
		BASS_Free();

		device->Release();
		d3d->Release();
		DestroyWindow(hwnd);
	} catch (const std::exception &e) {
#ifdef _CONSOLE
		fprintf(stderr, "*** error: %s\n", e.what());
#else
		MessageBox(NULL, e.what(), NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
#endif
		ret = -1;
	} catch (const std::string &str) {
#ifdef _CONSOLE
		fprintf(stderr, "*** error: %s\n", str.c_str());
#else
		MessageBox(NULL, e.what(), NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
#endif
		ret = -1;
	}

	return ret;
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
#ifndef SYNC_PLAYER
	bool should_save = false;	// whether to save tracks when done.
								// don't save unless we actually connect.
#endif

	HSTREAM stream;

	const struct sync_track *clear_r, *clear_g, *clear_b;
	const struct sync_track *cam_rot, *cam_dist;

	setup_sdl();

	/* init BASS */
	if (!BASS_Init(-1, 44100, 0, 0, 0))
		die("failed to init bass");
	stream = BASS_StreamCreateFile(false, "tune.ogg", 0, 0,
	    BASS_STREAM_PRESCAN);
	if (!stream)
		die("failed to open tune");

	sync_device *rocket = sync_create_device("sync");
	if (!rocket)
		die("out of memory?");

#ifndef SYNC_PLAYER
	if (sync_connect(rocket, "localhost", SYNC_DEFAULT_PORT))
		die("failed to connect to host");
#endif

	/* get tracks */
	clear_r = sync_get_track(rocket, "clear.r");
	clear_g = sync_get_track(rocket, "clear.g");
	clear_b = sync_get_track(rocket, "clear.b");
	cam_rot = sync_get_track(rocket, "cam.rot"),
	cam_dist = sync_get_track(rocket, "cam.dist");

	/* let's roll! */
	BASS_Start();
	BASS_ChannelPlay(stream, false);

	bool done = false;
	while (!done) {
		double row = bass_get_row(stream);
#ifndef SYNC_PLAYER
		if (sync_update(rocket, (int)floor(row), &bass_cb, (void *)&stream)) {
			if (sync_connect(rocket, "localhost", SYNC_DEFAULT_PORT) == 0)
				should_save = true;
		}
#endif

		/* draw */

		glClearColor(float(sync_get_val(clear_r, row)),
		             float(sync_get_val(clear_g, row)),
		             float(sync_get_val(clear_b, row)), 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		float rot = float(sync_get_val(cam_rot, row));
		float dist = float(sync_get_val(cam_dist, row));

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(60.0f, 4.0f / 3, 0.1f, 100.0f);

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		glPushMatrix();
		gluLookAt(sin(rot) * dist, 0, cos(rot) * dist,
		          0, 0, 0,
		          0, 1, 0);

		glEnable(GL_DEPTH_TEST);
		draw_cube();

		glPopMatrix();
		SDL_GL_SwapBuffers();

		BASS_Update(0); /* decrease the chance of missing vsync */

		SDL_Event e;
		while (SDL_PollEvent(&e)) {
			if (e.type == SDL_QUIT ||
			    (e.type == SDL_KEYDOWN &&
			    e.key.keysym.sym == SDLK_ESCAPE))
				done = true;
		}
	}

#ifndef SYNC_PLAYER
	if(should_save)		//don't clobber if user just ran it then hit Esc
		sync_save_tracks(rocket);
#endif
	sync_destroy_device(rocket);

	BASS_StreamFree(stream);
	BASS_Free();
	SDL_Quit();

	return 0;
}
Ejemplo n.º 16
0
Archivo: main.c Proyecto: kusma/cb-bart
int main(){
	MSG message;
	HSTREAM stream = 0;
	object *room;
	object *sphere;
	object *sphere_copy;
	rtt_target *rendertarget;

	rtt_target *fucking_shit;

	int loading;
	int bjork_texture;
	int yo_plus;
	int carlb;
	int i;
	int veldig_kule;
	int greets;
	int mothafuckas;

	vector particles[PARTICLE_COUNT];
	make_random_particles(particles, PARTICLE_COUNT, 200);

	if(!mumps_open("CARL B!!!!1",WIDTH,HEIGHT,32,32,-1,FULLSCREEN)) error("kunne ikke lage bartevindu");
	if(!init_extensions()){
		mumps_close();
		error("kunne ikke bruke fet opengl-extension");
	}
	if (!BASS_Init(-1, 44100, 0, 0, 0)) {
		mumps_close();
		error("kunne ikke åpne fet lyd");
	}
	stream = BASS_StreamCreateFile(FALSE, "data/uglespy.ogg", 0, 0, BASS_MP3_SETPOS | BASS_STREAM_PRESCAN | 0);
	if (!stream) {
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fet lyd 2.0");
	}

	loading = load_texture("loading.jpg", FALSE);
	if(loading==-1){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett bilde");
	}

	glClearColor(0,0,0,0);
	glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
	fullscreen_image(loading);
	glFlush();
	mumps_update();


	room = load_object("cylinder01.kro");
	if(!room){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett objekt");
	}

	sphere = load_object("sphere01.kro");
	if(!sphere){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett objekt");
	}
	sphere_copy = copy_object(sphere);

	bjork_texture = load_texture("bjork.jpg", FALSE);
	if(bjork_texture==-1){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett bilde");
	}
	yo_plus = load_texture("yo_plus.jpg", FALSE);
	if(yo_plus==-1){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett bilde");
	}
	carlb = load_texture("carlb.jpg", FALSE);
	if(carlb==-1){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett bilde");
	}
	veldig_kule = load_texture("veldig_kule.jpg", FALSE);
	if(veldig_kule==-1){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett bilde");
	}
	greets = load_texture("greets.jpg", FALSE);
	if(greets==-1){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett bilde");
	}
	mothafuckas = load_texture("mothefuckas.jpg", FALSE);
	if(mothafuckas==-1){
		BASS_StreamFree(stream);
		BASS_Free();
		mumps_close();
		error("kunne ikke åpne fett bilde");
	}

	rendertarget = init_rtt(512,256,(float)WIDTH/(float)HEIGHT, FALSE, FALSE);
	fucking_shit = init_rtt(512,256,(float)WIDTH/(float)HEIGHT, FALSE, TRUE);
	init_blur(256,256);

	glEnable(GL_NORMALIZE);
	
	BASS_Start();
	BASS_ChannelPlay(stream, FALSE);

	do {
		QWORD pos = BASS_ChannelGetPosition(stream, BASS_POS_BYTE);
		double time = BASS_ChannelBytes2Seconds(stream, pos);

		glViewport(0,0,mumps_width,mumps_height);

		if(time<25.55f){
			glClearColor(1,1,1,0);
			glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
			glMatrixMode(GL_TEXTURE);
			glLoadIdentity();
			glMatrixMode(GL_PROJECTION);
			glLoadIdentity();

			gluPerspective(120, ASPECT, 1.f, 500);

			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();

			glFogi(GL_FOG_MODE, GL_EXP2);
			glFogfv(GL_FOG_COLOR,black_color);
			glFogf(GL_FOG_DENSITY, 0.02f);
			glEnable(GL_FOG);

			set_camera(
				vector_make( // pos
					(float)sin(time*0.1f)*50,
					(float)sin(time*1.2f*0.1f+1)*50,
					(float)cos(sin(time*0.1f)-time*0.1f)*50
				),
				vector_make( // look_at
					0, 0, 0
				),
				0
			);

			draw_particles(particles,PARTICLE_COUNT,yo_plus, (float)15);

			if(time<2){
				float alpha = 1.f-time*0.5f;
				glPushAttrib(GL_ALL_ATTRIB_BITS);
				glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

				glColor4f(1,1,1, alpha );
				glEnable(GL_BLEND);
				fullscreen_image(loading);
				glPopAttrib();

			}

			if(time>17.5f){
				float alpha = (time-17.5);

				glPushAttrib(GL_ALL_ATTRIB_BITS);
				glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT);
				glBlendFunc( GL_SRC_ALPHA, GL_ONE );

				glColor4f(1,1,1, alpha );
				glEnable(GL_BLEND);
				fullscreen_image(carlb);
				glPopAttrib();
			}
		}else if(time<51.0f){
			float flash = 1.f-(time-25.55f);
			glClearColor(1,1,1,0);
			glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
			glMatrixMode(GL_TEXTURE);
			glLoadIdentity();
			glMatrixMode(GL_PROJECTION);
			glLoadIdentity();
			gluPerspective(90, ASPECT, 1.f, 500);
			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();

			glDisable(GL_FOG);


			gluLookAt(
				sin(time*0.1f)*90,-50,cos(time*0.1f)*90,
				0,-30,0,

				0,1,0
				);

			start_rtt(rendertarget);

			set_light(0, (float)sin(time)*50,0,(float)cos(time)*50,TRUE);
			set_light(1, (float)sin(time+1)*50,0,(float)cos(time+1)*50,TRUE);

			glEnable(GL_LIGHTING);
			glEnable(GL_DEPTH_TEST);

			glPushMatrix();
			glTranslatef(100,0,-100);
			draw_object(room);
			glPopMatrix();

			glPushMatrix();
			glTranslatef(0,-30,0);
			glScalef(0.7f,0.7f,0.7f);
			glRotatef(time*15,1,0,1);
			glRotatef(time*15,1,0,0);
			glRotatef(time*15.2f,0,1,0);

			glRotatef(time*15,0,0,1);
			glRotatef(time*25,1,0,0);
			glRotatef(time*15.2f,0,1,0);

			blob_distort(sphere, sphere_copy, vector_make((float)sin(time),time,-time), vector_make(
				(float)(1+sin(time))*0.1f,
				(float)(1+sin(time))*0.1f,
				(float)(1+sin(time))*0.1f
				),vector_make(0.3f,0.3f,0.3f) );
			draw_object(sphere_copy);
			glPopMatrix();

			end_rtt(rendertarget);

			i = blur((float)sin(time*0.3f)*0.3f, 0.1f+(1+(float)sin(time*0.1f))*0.2f, 0.2f, FALSE, rendertarget->texture);

			fullscreen_image(i);

			glEnable(GL_COLOR_MATERIAL);
			glColor4f(1,1,1, (1+(float)sin(time*0.5f))*0.3f );
			glBlendFunc( GL_SRC_ALPHA, GL_ONE );
			glEnable(GL_BLEND);
			fullscreen_image(bjork_texture);
			glDisable(GL_BLEND);


			if(time>38.35f){
				flash = 1.f-(time-38.4f);
				if(time>44.75f){
					flash = 1.f-(time-44.75f);
				}
			}

			if(flash<0) flash = 0;
			superflash(flash);

			if(time>38.35f){
				overlay(veldig_kule, 1);
			}
		}else if(time<(60+16.8f)){
			float flash = (1.f-(time-51.f));
			float flash2 = sin(-(3.1415f/2)+(time-51.f)*(117.5f/60.f)*8);
			if(flash<0) flash = 0;

			flash *= flash;


			flash2 *= (1+flash2)*0.5f;
			flash2 *= 20;

			start_rtt(fucking_shit);
			draw_dilldallscene(room, sphere, sphere_copy,time,flash,flash2);
			end_rtt(fucking_shit);

			glClearColor(0,0,0,0);
			glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

			draw_dilldallscene(room, sphere, sphere_copy,time,flash,flash2);

			glLoadIdentity();

			glEnable(GL_COLOR_MATERIAL);
			glColor4f(1,1,1, 0.5+(1+(float)sin(time*0.5f))*0.5f );
			glBlendFunc( GL_SRC_ALPHA, GL_ONE );
			glEnable(GL_BLEND);
			fullscreen_image_flip(fucking_shit->texture,1);
			fullscreen_image_flip(fucking_shit->texture,2);
			fullscreen_image_flip(fucking_shit->texture,3);
			glDisable(GL_BLEND);

			fuss(50,time, 1, 1, 0.1f);
			if(time>(60+3.9f)){
				flash=(1.f-(time-(60+3.9f)));
				overlay(greets, 1);
			}
			superflash(flash);
		}else{
			float flash = (1.f-(time-(60+16.8f)));
			fullscreen_image(mothafuckas);
			superflash(flash);
			if(time>(60+23.f)){
				float flash = (time-(60+23.f));
				superflash2(flash*0.5f);
			}
		}
		glFlush();
		mumps_update();

		if(time>60+30) PostQuitMessage(0);

		while(PeekMessage(&message,NULL,0,0,PM_REMOVE)){
			TranslateMessage(&message);
			DispatchMessage(&message);
		    if(message.message == WM_QUIT) break;
		}
	}while(message.message!=WM_QUIT && !GetAsyncKeyState(VK_ESCAPE));
	BASS_StreamFree(stream);
	BASS_Free();
	mumps_close();
	MessageBox(NULL,"Frigi minnet ditt sjøl, taper","In your face",MB_OK);
	return 0;
}
Ejemplo n.º 17
0
/*
	WM_COMMAND
*/
VOID Application::Cls_OnCommand(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
{
	static BOOL IsStop = FALSE;				//был ли нажат Stop
	switch (id)
	{
		case IDC_BTNPLAY:						//Play
		{
			if (hStream == NULL && playlist.songs.size() == 0)
			{
				BOOL isOpen = openFile_LoadMusic(hwnd);	
				if (isOpen == TRUE)
				{
					play(hStream);
					SetTimer(hwnd, id_timer, 1000, 0);
					SetTimer(hwnd, idTimerBySpectr, 100, 0);
				}
			}
			else if (hStream == NULL && playlist.songs.size() > 0)
			{
				hStream = playlist.songs[0].hStream;
				play(hStream);
				SetTimer(hwnd, id_timer, 1000, 0);
				SetTimer(hwnd, idTimerBySpectr, 100, 0);
			}
			else if (IsStop == FALSE)
			{
				BASS_Start();
				BASS_ChannelPlay(hStream, 0);
				SetTimer(hwnd, id_timer, 1000, 0);
				SetTimer(hwnd, idTimerBySpectr, 100 , 0);
			}
			else
			{
				play(hStream);
				SetTimer(hwnd, id_timer, 1000, 0);
				SetTimer(hwnd, idTimerBySpectr, 100, 0);
			}
			IsStop = FALSE;
			break;
		}
		case IDC_BTNSTOP:									//Stop
		{
			stop(hStream);
			IsStop = TRUE;
			secPlaying = 0;
			KillTimer(hwnd, id_timer);
			KillTimer(hwnd, idTimerBySpectr);
			id_timer = !id_timer;
			idTimerBySpectr = !idTimerBySpectr;
			break;
		}
		case IDC_BTNPAUSE:									//Pause
		{
			pause();
			KillTimer(hwnd, id_timer);
			KillTimer(hwnd, idTimerBySpectr);
			break;
		}
		/*
			Checkbox плейлист
		*/
		case IDC_CHECKPLAYLIST:
		{
			static HWND hCheckPlayList = GetDlgItem(hwnd, IDC_CHECKPLAYLIST);
			BOOL isShow = Button_GetCheck(hCheckPlayList);
			if (isShow)
			{
				SendMessage(hCheckPlayList, BM_SETCHECK, BST_CHECKED, 0);
				playlist.showPlayList(SW_SHOW);
			}
			else
			{
				SendMessage(hCheckPlayList, BM_SETCHECK, BST_UNCHECKED, 0);
				playlist.showPlayList(SW_HIDE);
			}

			break;
		}
		/*
			Checkbox эквалайзер
		*/
		case IDC_CHECKEQUALIZER:
		{
			static HWND hCheckEqualizer = GetDlgItem(hwnd, IDC_CHECKEQUALIZER);
			BOOL isShow = Button_GetCheck(hCheckEqualizer);
			if (isShow)
			{
				isShow = TRUE;
				SendMessage(hCheckEqualizer, BM_SETCHECK, BST_CHECKED, 0);
				equalizer.ShowEqualizer(SW_SHOW);
			}
			else
			{
				isShow = FALSE;
				SendMessage(hCheckEqualizer, BM_SETCHECK, BST_UNCHECKED, 0);
				equalizer.ShowEqualizer(SW_HIDE);
			}
			break;
		}
		case IDC_ADDSONG:									//Добавление песни
		{
			openFile_LoadMusic(hwnd);
			break;
		}
		case IDC_PREVSONG:									//Предыдущая песня
		{
			prev();
			break;
		}
		case IDC_NEXTSONG:									//Следующая песня
		{
			next();
			break;
		}
		case IDC_BTNCLOSE:									//Закрытие программы
		{
			EndDialog(hwnd, 0);
			break;
		}
		case IDC_REPEATSONG:								//Повтор песни
		{
			if (IsRepeatSong == FALSE)
			{
				SendDlgItemMessage(hwnd, IDC_REPEATSONG, WM_SETTEXT, 0, (LPARAM)TEXT("Yes"));
				HBITMAP bmp = LoadBitmap(GetModuleHandle(0), MAKEINTRESOURCE(IDB_BITMAPREPEAT));
				SendMessage(GetDlgItem(hwnd, IDC_REPEATSONG), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)bmp);
				IsRepeatSong = TRUE;
			}
			else
			{
				SendDlgItemMessage(hwnd, IDC_REPEATSONG, WM_SETTEXT, 0, (LPARAM)TEXT("No"));
				HBITMAP bmp = LoadBitmap(GetModuleHandle(0), MAKEINTRESOURCE(IDB_BITMAPNOREPEAT));
				SendMessage(GetDlgItem(hwnd, IDC_REPEATSONG), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)bmp);
				IsRepeatSong = FALSE;
			}
			break;
		}
		/*
			Цвета контура
		*/
		case COLOR_CONTOUR_RED:
		{
			UncheckedAllMenuItemContour();
			CheckMenuItem(hColorContour, COLOR_CONTOUR_RED, MF_BYCOMMAND | MF_CHECKED);
			ColorContourSpectrum(255, 0, 0);
			break;
		}
		case COLOR_CONTOUR_GREEN:
		{
			UncheckedAllMenuItemContour();
			CheckMenuItem(hColorContour, COLOR_CONTOUR_GREEN, MF_BYCOMMAND | MF_CHECKED);
			ColorContourSpectrum(0, 255, 0);
			break;
		}
		case COLOR_CONTOUR_BLUE:
		{
			UncheckedAllMenuItemContour();
			CheckMenuItem(hColorContour, COLOR_CONTOUR_BLUE, MF_BYCOMMAND | MF_CHECKED);
			ColorContourSpectrum(0, 0, 255);
			break;
		}
		case COLOR_CONTOUR_WHITE:
		{
			UncheckedAllMenuItemContour();
			CheckMenuItem(hColorContour, COLOR_CONTOUR_WHITE, MF_BYCOMMAND | MF_CHECKED);
			ColorContourSpectrum(255, 255, 255);
			break;
		}
		case COLOR_CONTOUR_BLACK:
		{
			UncheckedAllMenuItemContour();
			CheckMenuItem(hColorContour, COLOR_CONTOUR_BLACK, MF_BYCOMMAND | MF_CHECKED);
			ColorContourSpectrum(0, 0, 0);
			break;
		}
		/*
			Цвета заливки
		*/
		case COLOR_FILL_RED:
		{
			UncheckedAllMenuItemFill();
			CheckMenuItem(hColorFill, COLOR_FILL_RED, MF_BYCOMMAND | MF_CHECKED);
			ColorFillSpectrum(255, 0, 0);
			break;
		}
		case COLOR_FILL_GREEN:
		{
			UncheckedAllMenuItemFill();
			CheckMenuItem(hColorFill, COLOR_FILL_GREEN, MF_BYCOMMAND | MF_CHECKED);
			ColorFillSpectrum(0, 255, 0);
			break;
		}
		case COLOR_FILL_BLUE:
		{
			UncheckedAllMenuItemFill();
			CheckMenuItem(hColorFill, COLOR_FILL_BLUE, MF_BYCOMMAND | MF_CHECKED);
			ColorFillSpectrum(0, 0, 255);
			break;
		}
		case COLOR_FILL_WHITE:
		{
			UncheckedAllMenuItemFill();
			CheckMenuItem(hColorFill, COLOR_FILL_WHITE, MF_BYCOMMAND | MF_CHECKED);
			ColorFillSpectrum(255, 255, 255);
			break;
		}
		case COLOR_FILL_BLACK:
		{
			UncheckedAllMenuItemFill();
			CheckMenuItem(hColorFill, COLOR_FILL_BLACK, MF_BYCOMMAND | MF_CHECKED);
			ColorFillSpectrum(0, 0, 0);
			break;
		}
		/*
			Прозрачность окна
		*/
		case TRANSPARENCY_100:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_100, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 100);
			break;
		}
		case TRANSPARENCY_90:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_90, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 90);
			break;
		}
		case TRANSPARENCY_80:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_80, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 80);
			break;
		}
		case TRANSPARENCY_70:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_70, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 70);
			break;
		}
		case TRANSPARENCY_60:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_60, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 60);
			break;
		}
		case TRANSPARENCY_50:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_50, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 50);
			break;
		}
		case TRANSPARENCY_40:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_40, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 40);
			break;
		}
		case TRANSPARENCY_30:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_30, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 30);
			break;
		}
		case TRANSPARENCY_20:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_20, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 20);
			break;
		}
		case TRANSPARENCY_10:
		{
			UncheckedAllMenuItemTransperency();
			CheckMenuItem(hTranperency, TRANSPARENCY_10, MF_BYCOMMAND | MF_CHECKED);
			TransparencyWindow(hwnd, 10);
			break;
		}
		default:
			break;
	}
}
Ejemplo n.º 18
0
int main(){
	BOOL done = FALSE;
	MSG msg;
	IDirect3DDevice9 *device = NULL;
	IDirect3DSurface9 *main_rendertarget = NULL;
	D3DFORMAT format;
	
	float old_time = 0;

	/* render-to-texture-stuff */
	IDirect3DTexture9 *rtt_texture;
	IDirect3DSurface9 *rtt_surface;
	IDirect3DTexture9 *rtt_32_texture;
	IDirect3DSurface9 *rtt_32_surface;

	/* textures used from mainloop */
	int white, black;
	int odd_is_back_again[4];
	int at_the_gathering_2003[4];
	int o_d_d_in_your_face[4];
	int world_domination[4];
	int back_once_again[3];
	int were_back;
	int cred[4];
	int mad_props[4];
	int not_eph[4];
	int piss_the_fuck_off[11];
	int hardcore;

	int refmap, refmap2;
	int eatyrcode;
	int code_0, code_1;
	int overlaytest;
	int circle_particle;

	/* special-textures */
	int rtt_texture_id;
	int rtt_32_texture_id;
	int video_texture_id;
	int dilldall,dilldall2;
	int metaball_text;

	/* videos */
	video *vid;

	/* 3d-scenes */
	scene *fysikkfjall;
	scene *startblob;
	scene *inni_abstrakt;
	scene *korridor;
	scene *skjerm_rom;
	scene *bare_paa_lissom;

	format = D3DFMT_X8R8G8B8;
	device = d3dwin_open(TITLE, WIDTH, HEIGHT, format, FULLSCREEN);
	if(!device){
		format = D3DFMT_A8R8G8B8;
		device = d3dwin_open(TITLE, WIDTH, HEIGHT, format, FULLSCREEN);
		if(!device){
			format = D3DFMT_X1R5G5B5;
			device = d3dwin_open(TITLE, WIDTH, HEIGHT, format, FULLSCREEN);
			if(!device){
				format = D3DFMT_R5G6B5;
				device = d3dwin_open(TITLE, WIDTH, HEIGHT, format, FULLSCREEN);
				if(!device) error("failed to initialize Direct3D9");
			}
		}
	}

#ifdef BIGSCREEN
	set_gamma(device,1.05f);
#endif

	if (!BASS_Init(1, 44100, BASS_DEVICE_LATENCY, win, NULL)) error("failed to initialize BASS");
	fp = file_open("worlddomination.ogg");
	if (!fp) error("music-file not found");
	music_file = BASS_StreamCreateFile(1, fp->data, 0, fp->size, 0);

	/*** music ***/
//	if(!pest_open(win)) error("failed to initialize DirectSond");
//	if(!pest_load("worlddomination.ogg",0)) error("failed to load music-file");


	/*** subsystems ***/
	init_tunnel();
	video_init();
	if(!init_particles(device)) error("failed to initialize");
	if(!init_overlays(device)) error("f**k a duck");
	if(!init_marching_cubes(device)) error("screw a kangaroo");

	make_random_particles(particles, PARTICLES, vector_make(0,-180,0), 500);
	make_random_particles(particles2, PARTICLES2, vector_make(0,-180,0), 500);
	make_random_particles(particles3, PARTICLES3, vector_make(0,0,0), 800);

	/*** rendertextures ***/
	if (IDirect3DDevice9_CreateTexture(device, 512, 256, 0,D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &rtt_texture, NULL)!=D3D_OK) error("failed to create rendertarget-texture");
	if (IDirect3DTexture9_GetSurfaceLevel(rtt_texture,0,&rtt_surface)!=D3D_OK) error("could not get kvasi-backbuffer-surface");
	if ((rtt_texture_id=texture_insert(device, "rendertexture.jpg", rtt_texture))==-1) error("fakk off!");

	if(IDirect3DDevice9_CreateTexture(device,16,16,0,D3DUSAGE_RENDERTARGET|D3DUSAGE_AUTOGENMIPMAP,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT, &rtt_32_texture, NULL)!=D3D_OK) error("failed to create rendertarget-texture");
	if(IDirect3DTexture9_GetSurfaceLevel(rtt_32_texture,0,&rtt_32_surface)!=D3D_OK) error("could not get kvasi-backbuffer-surface");
	if((rtt_32_texture_id=texture_insert(device, "rendertexture2.jpg", rtt_32_texture))==-1) error("fakk off!");


	/*** textures ***/
	/* solid colors for fades etc */
	if((white=texture_load(device,"white.png",FALSE))==-1) error("shjit!");
	if((black=texture_load(device,"black.png",FALSE))==-1) error("shjit!");

	/* textoverlays */
	if((odd_is_back_again[0]=texture_load(device,"odd_is_back_again_0.png",FALSE))==-1) error("failed to load image");
	if((odd_is_back_again[1]=texture_load(device,"odd_is_back_again_1.png",FALSE))==-1) error("failed to load image");
	if((odd_is_back_again[2]=texture_load(device,"odd_is_back_again_2.png",FALSE))==-1) error("failed to load image");
	if((odd_is_back_again[3]=texture_load(device,"odd_is_back_again_3.png",FALSE))==-1) error("failed to load image");
	if((at_the_gathering_2003[0]=texture_load(device,"at_the_gathering_2003_0.png",FALSE))==-1) error("failed to load image");
	if((at_the_gathering_2003[1]=texture_load(device,"at_the_gathering_2003_1.png",FALSE))==-1) error("failed to load image");
	if((at_the_gathering_2003[2]=texture_load(device,"at_the_gathering_2003_2.png",FALSE))==-1) error("failed to load image");
	if((at_the_gathering_2003[3]=texture_load(device,"at_the_gathering_2003_3.png",FALSE))==-1) error("failed to load image");
	if((back_once_again[0]=texture_load(device,"back_once_again_0.png",TRUE))==-1) error("failed to load image");
	if((back_once_again[1]=texture_load(device,"back_once_again_1.png",TRUE))==-1) error("failed to load image");
	if((back_once_again[2]=texture_load(device,"back_once_again_2.png",TRUE))==-1) error("failed to load image");
	if((o_d_d_in_your_face[0]=texture_load(device,"o_d_d_in_your_face_0.png",TRUE))==-1) error("failed to load image");
	if((o_d_d_in_your_face[1]=texture_load(device,"o_d_d_in_your_face_1.png",TRUE))==-1) error("failed to load image");
	if((o_d_d_in_your_face[2]=texture_load(device,"o_d_d_in_your_face_2.png",TRUE))==-1) error("failed to load image");
	if((o_d_d_in_your_face[3]=texture_load(device,"o_d_d_in_your_face_3.png",TRUE))==-1) error("failed to load image");
	if((world_domination[0]=texture_load(device,"world_domination_0.png",TRUE))==-1) error("failed to load image");
	if((world_domination[1]=texture_load(device,"world_domination_1.png",TRUE))==-1) error("failed to load image");
	if((world_domination[2]=texture_load(device,"world_domination_2.png",TRUE))==-1) error("failed to load image");
	if((world_domination[3]=texture_load(device,"world_domination_3.png",TRUE))==-1) error("failed to load image");
	if((were_back=texture_load(device,"were_back.png",TRUE))==-1) error("failed to load image");

	if((cred[0]=texture_load(device,"cred_0.png",TRUE))==-1) error("failed to load image");
	if((cred[1]=texture_load(device,"cred_1.png",TRUE))==-1) error("failed to load image");
	if((cred[2]=texture_load(device,"cred_2.png",TRUE))==-1) error("failed to load image");
	if((cred[3]=texture_load(device,"cred_3.png",TRUE))==-1) error("failed to load image");
	if((mad_props[0]=texture_load(device,"mad_props_0.png",TRUE))==-1) error("failed to load image");
	if((mad_props[1]=texture_load(device,"mad_props_1.png",TRUE))==-1) error("failed to load image");
	if((mad_props[2]=texture_load(device,"mad_props_2.png",TRUE))==-1) error("failed to load image");
	if((mad_props[3]=texture_load(device,"mad_props_3.png",TRUE))==-1) error("failed to load image");
	if((not_eph[0]=texture_load(device,"not_eph_0.png",TRUE))==-1) error("failed to load image");
	if((not_eph[1]=texture_load(device,"not_eph_1.png",TRUE))==-1) error("failed to load image");
	if((not_eph[2]=texture_load(device,"not_eph_2.png",TRUE))==-1) error("failed to load image");
	if((not_eph[3]=texture_load(device,"not_eph_3.png",TRUE))==-1) error("failed to load image");

	if((piss_the_fuck_off[0]=texture_load(device,"piss_the_fuck_off_0.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[1]=texture_load(device,"piss_the_fuck_off_1.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[2]=texture_load(device,"piss_the_fuck_off_2.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[3]=texture_load(device,"piss_the_fuck_off_3.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[4]=texture_load(device,"piss_the_fuck_off_4.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[5]=texture_load(device,"piss_the_fuck_off_5.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[6]=texture_load(device,"piss_the_fuck_off_6.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[7]=texture_load(device,"piss_the_fuck_off_7.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[8]=texture_load(device,"piss_the_fuck_off_8.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[9]=texture_load(device,"piss_the_fuck_off_9.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[10]=texture_load(device,"piss_the_fuck_off_10.png",TRUE))==-1) error("failed to load image");
	if((hardcore=texture_load(device,"hardcore.png",TRUE))==-1) error("failed to load image");

	/* other textures */
	if((circle_particle=texture_load(device,"circle_particle.jpg",FALSE))==-1) error("shjit!");
	if((refmap=texture_load(device,"fysikkfjall/refmap.jpg",FALSE))==-1) error("shjit!");
	if((refmap2=texture_load(device,"refmap2.jpg",FALSE))==-1) error("shjit!");
	if((eatyrcode=texture_load(device,"eatyrcode.jpg",FULLSCREEN_HACK))==-1) error("shjit!");
	if((code_0=texture_load(device,"code-0.jpg",FALSE))==-1) error("shjit!");
	if((code_1=texture_load(device,"code-1.jpg",FALSE))==-1) error("shjit!");
	if((overlaytest=texture_load(device,"overlaytest.jpg",FALSE))==-1) error("shjit!");

	if((dilldall=texture_load(device,"dilldall.png",FALSE))==-1) error("shjit!");
	if((dilldall2=texture_load(device,"dilldall2.png",FALSE))==-1) error("shjit!");

	if((metaball_text=texture_load(device,"metaballs.png",TRUE))==-1) error("shjit!");

	/*** video ***/
	if(!(vid=video_load(device,"test.kpg"))) error("fæck!");
	video_texture_id = texture_insert(device, "skjerm_rom/skjerm_tom.tga", vid->texture);


	/*** misc stuff ***/
	/* main rendertarget */
	IDirect3DDevice9_GetRenderTarget(device,0,&main_rendertarget);

	/* default state */
	IDirect3DDevice9_CreateStateBlock(device, D3DSBT_ALL, &default_state);
	init_defaultstate(device);
	IDirect3DStateBlock9_Capture(default_state);


	/*** 3d scenes ***/
	if(!(fysikkfjall=load_scene(device,"fysikkfjall/fysikkfjall.krs"))) error("failed to load 3d scene");
	if(!(startblob=load_scene(device,"startblob/startblob.krs"))) error("failed to load 3d scene");
	if(!(inni_abstrakt=load_scene(device,"inni_abstrakt/inni_abstrakt.krs"))) error("failed to load 3d scene");
	if(!(korridor=load_scene(device,"korridor/korridor.krs"))) error("failed to load 3d scene");
	if(!(skjerm_rom=load_scene(device,"skjerm_rom/skjerm_rom.krs"))) error("failed to load 3d scene");
	if(!(bare_paa_lissom=load_scene(device,"bare_paa_lissom/bare_paa_lissom.krs"))) error("failed to load 3d scene");

//	pest_play();
	BASS_Start();
	BASS_StreamPlay(music_file, 1, 0);
	do{
		grid g;
		int i;
		matrix m, temp, temp_matrix;
		matrix marching_cubes_matrix;

		long long bytes_played = BASS_ChannelGetPosition(music_file);
		float time =  bytes_played * (1.0 / (44100 * 2 * 2));
//		float time = pest_get_pos()+0.05f;
		float delta_time = time-old_time;

		int beat = (int)(time*((float)BPM/60.f));

		if(time_index<(sizeof(timetable)/4)){
			while(timetable[time_index]<time) time_index++;
		}

#ifdef _DEBUG
		printf("time: %2.2f, delta_time: %2.2f, time_index: %i, beat: %i                    \r",time,delta_time,time_index,beat);
#endif

		IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
		IDirect3DStateBlock9_Apply(default_state);
		IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0, 1.0f, 0);
//		IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
		IDirect3DDevice9_BeginScene(device);
#if 1
		if(time_index<40){
			if(time_index>0&&time_index<5){
				draw_overlay(device,odd_is_back_again[time_index-1],0,0,1,FALSE);
			}else if(time_index>4&&time_index<19){
				float itime = time*10;
				grid_flat(g,0,0);
				for(i=0;i<7;i++){
					int scale = (time_index&1);
					grid_wave(g,(float)sin(itime-i+sin(i-itime))*0.3f*scale,(float)cos(itime*0.69f+i*0.733f)*0.3f*scale,7,(float)sin(itime+i*0.1f)*0.5f*scale);
				}
				draw_grid(device, g, odd_is_back_again[3], FALSE);
			}else if(time_index>=19){
				float itime = (time-timetable[18])*0.5f;
				grid_flat(g,0,0);
				for(i=0;i<7;i++){
					grid_wave(g,(float)sin(time-i+sin(i-time))*0.3f,(float)cos(time*0.69f+i*0.733f)*0.3f,7, itime*itime);
				}
				draw_grid(device, g, odd_is_back_again[3], FALSE);
			}
			if(time_index>20&&time_index<25){
				draw_overlay(device,at_the_gathering_2003[(time_index-21)%4],0,0,1,TRUE);
			}else if(time_index>=25&&time_index<38){
				float itime = time*10;
				grid_flat(g,0,0);
				for(i=0;i<10;i++){
					int scale = (time_index&1);
					grid_wave(g,(float)sin(itime-i+sin(i-itime))*0.3f*scale,(float)cos(itime*0.69f+i*0.733f)*0.3f*scale,7,(float)sin(itime+i*0.1f)*0.5f*scale);
				}
				draw_grid(device,g,at_the_gathering_2003[3],TRUE);
			}else if(time_index>=38){
				float itime = (time-timetable[37])*0.5f;
				grid_flat(g,0,0);
				for(i=0;i<10;i++){
					grid_wave(g,(float)sin(time-i+sin(i-time))*0.3f,(float)cos(time*0.69f+i*0.733f)*0.3f,7, itime*itime);
				}
				draw_grid(device,g,at_the_gathering_2003[3],TRUE);
			}
		}else if(time_index<52){
			animate_scene(inni_abstrakt,(time-timetable[39]));
			draw_scene(device,inni_abstrakt,0,TRUE);

			flash(device,white,time,timetable[39],1);

			if(time_index<43){
				draw_overlay(device, back_once_again[(time_index-40)%3],0,0,1,FALSE);
			}else if(time_index<47){
				draw_overlay(device, o_d_d_in_your_face[(time_index-43)%4],0,0,1,FALSE);
			}else if(time_index<51){
				draw_overlay(device, world_domination[(time_index-47)%4],0,0,1,FALSE);
			}else{
				draw_overlay(device, were_back,0,0,(time-timetable[51]),FALSE);
			}

			draw_overlay(device,dilldall,sin(sin(time)*0.07f+(((beat+1)/2)*0.8f)),sin(time*0.03337f+(((beat+1)/2)*0.14f)),0.5f,TRUE);
			draw_overlay(device,dilldall2,sin(sin(time*0.1f)*0.07f+time*0.1f+(((beat+1)/2)*0.8f)),sin(time*0.01337f+(((beat+1)/2)*0.14f)),0.5f,TRUE);

		}else if(time_index<69){

			animate_scene(startblob,(time-timetable[39]-0.27f+((beat+1)&2))*0.74948f);

			startblob->cameras[0].fog = TRUE;
			startblob->cameras[0].fog_start = 100.f;
			startblob->cameras[0].fog_end = 700.f;

			if(time_index>=53 && time_index<66 && time_index&1 ){
				float f = fade(timetable[time_index-1],1.7f,time,0.5f,0);
				f *= f;
				f *= 2;

				if(f>0.f)
				IDirect3DDevice9_SetRenderTarget(device,0,rtt_surface);

				draw_scene(device,startblob,0,TRUE);
				draw_particles(device, particles3, PARTICLES3, code_0);

				if(f>0.f){
					IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
					draw_radialblur(device,0,0,f,0,rtt_texture_id, FALSE);
				}
				if(time_index<61) draw_overlay(device,cred[((time_index/2)-2)%4],0,0,f*3,FALSE);
			}else{
				draw_scene(device,startblob,0,TRUE);
				draw_particles(device, particles3, PARTICLES3, circle_particle);			
			}
			if(time_index>=54&& !(time_index&1)){

				float f = fade(timetable[time_index-1],1.8f,time,1.f,0)*0.8f;
				IDirect3DDevice9_SetRenderTarget(device,0,rtt_32_surface);
				draw_scene(device,startblob,0,TRUE);
				draw_particles(device, particles3, PARTICLES3, code_0);

				IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
				IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
				draw_overlay(device,rtt_32_texture_id,0,0,f,TRUE);
				draw_overlay(device,rtt_32_texture_id,0,0,f,TRUE);
				IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
			}

			flash(device,were_back,time,timetable[51],2);
			flash(device,white,time,timetable[51],1);
		}else if(time_index<79){

			for(i=0;i<BALLS;i++){
				balls[i].pos.x = (float)sin(time+i-sin((float)i*0.1212111f))*0.35f;
				balls[i].pos.y = (float)cos(time-(float)i*0.29342111f)*0.35f;
				balls[i].pos.z = (float)sin(time*0.31121f+sin(i-time))*0.35f;
				balls[i].r = 0.15f + (float)sin(time+i)*0.01f;
				balls[i].pos = vector_normalize(balls[i].pos);
				balls[i].pos = vector_scale(balls[i].pos, (float)(cos(i*0.11131f-time*0.55311f)+sin(time+(float)sin(time-i+time*0.3f)))*0.2f );
			}

			animate_scene(korridor,(time-timetable[68])*0.65f );
			draw_scene(device,korridor,(beat/4)&1,TRUE);

			memcpy(temp,korridor->objects[korridor->object_count-1]->mat,sizeof(matrix));
			matrix_scale(marching_cubes_matrix,vector_make(120,120,120));
			matrix_multiply(marching_cubes_matrix,temp,marching_cubes_matrix);
	
			matrix_rotate(temp,vector_make(time,-time,time*0.5f+sin(time)));
			matrix_multiply(marching_cubes_matrix,marching_cubes_matrix,temp);

			IDirect3DDevice9_SetTransform( device, D3DTS_WORLD, (D3DMATRIX*)&marching_cubes_matrix );

			fill_metafield_blur(balls, BALLS,0.98f);
			march_my_cubes_opt(balls, BALLS, 0.9f);

			IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);

			set_texture(device,0,refmap2);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_CURRENT);

			draw_marched_cubes(device);

			flash(device,white,time,timetable[68],1);

			if(time_index>69&&time_index<74){
				draw_overlay(device,mad_props[(time_index+2)%4],0,0,1,FALSE);
			}else if(time_index>73&&time_index<77){
				draw_overlay(device,not_eph[(time_index+2)%4],0,0,1,FALSE);
			}else if(time_index==77){
				float f = fade(timetable[76],2.5f,time,1,0);
				draw_overlay(device,not_eph[3],0,0,f,FALSE);
			}
		}
		if(time_index>77&&time_index<92){
			float f = fade(timetable[77],timetable[78]-timetable[77],time,0,1);
			draw_overlay(device,eatyrcode,0,0,f,FALSE);

			if(time>109.5f){
				IDirect3DStateBlock9_Apply(default_state);
				animate_particles(particles, PARTICLES, delta_time*30);
				animate_particles(particles2, PARTICLES2, delta_time*28);

				draw_particles(device, particles, PARTICLES, code_0);
				draw_particles(device, particles2, PARTICLES2, code_1);
			}
			if(time_index>79&&time_index<90){
				draw_overlay(device,piss_the_fuck_off[(time_index-80)%11],0,0,1,FALSE);
			}else if(time_index==90){
				float f = fade(timetable[89],2,time,1,0);
				draw_overlay(device,piss_the_fuck_off[10],0,0,f,FALSE);
			}
			if(time_index==91){
				float f = fade(timetable[90],2,time,1,0);
				draw_overlay(device,hardcore,0,0,f,FALSE);
			}
		}else if(time_index>91 && time_index<97){
			animate_scene(skjerm_rom,time);
			video_update(vid, time);
			draw_scene(device,skjerm_rom,((beat/4)&1),TRUE);

			draw_overlay(device,dilldall,sin(sin(time)*0.07f+(((beat+1)/2)*0.8f)),sin(time*0.03337f+(((beat+1)/2)*0.14f)),0.5f,TRUE);
			draw_overlay(device,dilldall2,sin(sin(time*0.1f)*0.07f+time*0.1f+(((beat+1)/2)*0.8f)),sin(time*0.01337f+(((beat+1)/2)*0.14f)),0.5f,TRUE);
			if(time_index>92)
				draw_overlay(device, world_domination[(time_index-93)%4],0,0,1,FALSE);

		}else if(time_index>96&&time_index<104){
			grid_zero(g);

			matrix_translate(m, vector_make(cos(time)*1.5f, sin(time)*1.5f,time*10));
			matrix_rotate(temp_matrix, vector_make(sin(time*0.8111f)*0.2f,sin(time*1.2f)*0.2f,time));
			matrix_multiply(m,m,temp_matrix);

			render_tunnel(g,m);

			matrix_rotate(temp_matrix, vector_make(0,M_PI,0));
			matrix_multiply(m,m,temp_matrix);
			render_tunnel(g,m);
			matrix_rotate(temp_matrix, vector_make(M_PI,0,0));
			matrix_multiply(m,m,temp_matrix);
			render_tunnel(g,m);

			grid_add_noice(g,sin(time)*0.1f);

			draw_grid(device, g, circle_particle, FALSE);

			if(time_index>97&&time_index<102){
				float f = 1;
				if(time_index==101) f = fade(timetable[100],3,time,1,0);
				draw_overlay(device, o_d_d_in_your_face[(time_index-42)%4],0,0,f,FALSE);
			}
		}
		if(time_index>101 && time_index<104){
			float f = fade(timetable[101],8,time,0,1);
			float f2 = fade(timetable[101],4,time,0,1);

			draw_overlay(device,black,0,0,f2,FALSE);

			IDirect3DDevice9_SetRenderTarget(device,0,rtt_surface);
			IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0, 1.0f, 0);

			IDirect3DStateBlock9_Apply(default_state);

			animate_scene(bare_paa_lissom,time-timetable[101]);
			draw_scene(device,bare_paa_lissom,0,TRUE);

			time *=0.5f;

			for(i=0;i<BALLS2;i++){
				balls2[i].pos.x = (float)sin(time+i-sin((float)i*0.1212111f))*0.35f;
				balls2[i].pos.y = (float)cos(time-(float)i*0.29342111f)*0.35f;
				balls2[i].pos.z = (float)sin(time*0.31121f+sin(i-time))*0.35f;
				balls2[i].r = 0.15f + (float)sin(time+i)*0.01f;
				balls2[i].pos = vector_normalize(balls2[i].pos);
				balls2[i].pos = vector_scale(balls2[i].pos, (float)(cos(i*0.11131f-time*0.55311f)+sin(time+(float)sin(time-i+time*0.3f)))*0.2f );
			}

			memcpy(temp,bare_paa_lissom->objects[bare_paa_lissom->object_count-1]->mat,sizeof(matrix));
			matrix_scale(marching_cubes_matrix,vector_make(120,120,120));
			matrix_multiply(marching_cubes_matrix,temp,marching_cubes_matrix);

			IDirect3DDevice9_SetTransform( device, D3DTS_WORLD, (D3DMATRIX*)&marching_cubes_matrix );
			fill_metafield(balls2, BALLS2);
			march_my_cubes_opt(balls2, BALLS2, 0.9f);

			IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);

			set_texture(device,0,refmap);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_CURRENT);

			draw_marched_cubes(device);

			IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
			draw_overlay(device,rtt_texture_id,0,0,f,TRUE);

			if(time_index==103){
				float f;
				time *= 2;
				f = fade(timetable[time_index-1],3,time,1,0);
				draw_overlay(device,metaball_text,0,0,f,FALSE);

				flash(device,white,time,timetable[time_index-1],1);
			}
		}
		if(time_index==104){
			float f = fade(timetable[103],timetable[104]-timetable[103],time,0,1);

			animate_scene(korridor,180-(time-timetable[time_index-1])*0.8f );
			draw_scene(device,korridor,(beat/4)&1,TRUE);
			draw_overlay(device,black,0,0,f,FALSE);
		}
		if(time_index==105){
			float f = fade(timetable[104],timetable[105]-timetable[104],time,0,1);
			float t = (time-timetable[time_index-1])*0.6f+2.2f;
			animate_scene(fysikkfjall,t);
			draw_scene(device,fysikkfjall,0,TRUE);
			draw_overlay(device,black,0,0,f,FALSE);
		}
#endif
/*
*/
/*
		draw_overlay(device, were_back, (1+sin(time))*0.5f, TRUE);
*/
//		animate_scene(risterom,time);
//		draw_scene(device,risterom,0,TRUE);

#if 0 //helvete_har_frosset
		draw_overlay(device, eatyrcode, 1,FALSE);

		IDirect3DStateBlock9_Apply(default_state);

		animate_particles(particles, PARTICLES, delta_time*30);
		animate_particles(particles2, PARTICLES2, delta_time*28);

		draw_particles(device, particles, PARTICLES, code_0);
		draw_particles(device, particles2, PARTICLES2, code_1);
#endif

#ifdef pikk

//				IDirect3DDevice9_SetRenderTarget(device,0,rtt_surface);
				IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0, 1.0f, 0);

				draw_overlay(device, eatyrcode, TRUE);

				animate_scene(startblob,(time-timetable[39]-0.27f)*0.7453f);
				draw_scene(device,startblob,0,FALSE);
				draw_particles(device, particles, PARTICLES, code_0);
				draw_particles(device, particles2, PARTICLES2, code_1);
//				IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
/*
				draw_radialblur(device,
					(float)sin(time)*0.2f,
					(float)sin(-time*0.331f)*0.13f,
					(float)(2+(float)sin(time*0.5f))*0.2f,
					0,//sin(time)*0.25f,
					rtt_texture_id, TRUE);

				animate_scene(fysikkfjall,time);
				draw_scene(device,fysikkfjall,0,FALSE);
*/
//				draw_overlay(device, rtt_texture_id, TRUE);
#endif

//		draw_overlay(device, eatyrcode, FALSE);

//		video_update(vid, time);
#if 0
//		IDirect3DDevice9_SetRenderTarget(device,0,rtt_surface);

		animate_scene(testscene,time);

//		morph_object(testscene->objects[0], time );
		draw_scene(device,testscene,0,TRUE);
//		draw_particles(device, particles, PARTICLES, particle);

//		IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
#endif
#if 0
		time *=0.5f;

		for(i=0;i<BALLS2;i++){
			balls2[i].pos.x = (float)sin(time+i-sin((float)i*0.1212111f))*0.35f;
			balls2[i].pos.y = (float)cos(time-(float)i*0.29342111f)*0.35f;
			balls2[i].pos.z = (float)sin(time*0.31121f+sin(i-time))*0.35f;
			balls2[i].r = 0.15f + (float)sin(time+i)*0.01f;
			balls2[i].pos = vector_normalize(balls2[i].pos);
			balls2[i].pos = vector_scale(balls2[i].pos, (float)(cos(i*0.11131f-time*0.55311f)+sin(time+(float)sin(time-i+time*0.3f)))*0.2f );
//			balls2[i].pos.x *= 2.8f;
		}

		matrix_translate(temp,vector_make(0,0,87));
		matrix_scale(marching_cubes_matrix,vector_make(50,50,50));
		matrix_multiply(marching_cubes_matrix,temp,marching_cubes_matrix);

		IDirect3DDevice9_SetTransform( device, D3DTS_WORLD, (D3DMATRIX*)&marching_cubes_matrix );
		fill_metafield(balls2, BALLS2);
//		fill_metafield_blur(balls, BALLS,0.98f);
		march_my_cubes_opt(balls2, BALLS2, 0.9f);
//		march_my_cubes(0.9f);

		IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_CW);

		set_texture(device,0,refmap);
		IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
		IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
		IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
		IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_CURRENT);

		draw_marched_cubes(device);
#endif

#if 0
//		time *= 0.5f;
		grid_zero(g);
//		for(i=0;i<10;i++)
//			grid_wave(g,sin(time-i+sin(i-time))*0.3f,cos(time*0.69f+i*0.733f)*0.3f,7,sin(time+i*0.1f)*0.5f);

		matrix_translate(m, vector_make(cos(time)*1.5f, sin(time)*1.5f,time*10));
		matrix_rotate(temp_matrix, vector_make(sin(time*0.8111f)*0.2f,sin(time*1.2f)*0.2f,time));
		matrix_multiply(m,m,temp_matrix);

//		empty_grid( grid );
		render_tunnel(g,m);

		matrix_rotate(temp_matrix, vector_make(0,M_PI,0));
		matrix_multiply(m,m,temp_matrix);
		render_tunnel(g,m);
		matrix_rotate(temp_matrix, vector_make(M_PI,0,0));
		matrix_multiply(m,m,temp_matrix);
		render_tunnel(g,m);
//		tyfuus_expand_grid( screen, grid, texture );

		grid_add_noice(g,sin(time)*0.1f);

		draw_grid(device, g, circle_particle, FALSE);
#endif
//		IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);

//		video_update(vid,time);
/*
		draw_radialblur(device,
			(float)sin(time)*0.2f,
			(float)sin(-time*0.331f)*0.13f,
			(float)(1+(float)sin(time*0.5f))*0.2f,
			0,//sin(time)*0.25f,
			rtt_texture_id, FALSE);
*/
//		IDirect3DStateBlock9_Apply(default_state);

//		draw_overlay(device,rtt_texture_id,FALSE);
//		draw_overlay(device,fullscreen,FALSE);

//		draw_radialblur(device,0,sin(time*0.2f)*2.f, rtt_texture_id);

//		IDirect3DDevice9_StretchRect(device,main_rendertarget,NULL,rtt_surface,NULL,D3DTEXF_NONE);
//		IDirect3DBaseTexture9_GenerateMipSubLevels(rtt_texture);

		IDirect3DDevice9_EndScene(device);
		if(IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL)==D3DERR_DEVICELOST)
			error("fakkin lost device. keep your hands off alt-tab, looser.");

		old_time = time;

		while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)){ 
			TranslateMessage(&msg);
			DispatchMessage(&msg);
			if (msg.message == WM_QUIT ||
			    msg.message == WM_KEYDOWN && LOWORD(msg.wParam) == VK_ESCAPE)
				done = TRUE;
		}
	}while(!done);

	deinit_marching_cubes();
	deinit_overlays();
	deinit_particles();

	free_scene(fysikkfjall);
	free_scene(startblob);
	free_scene(inni_abstrakt);
	free_scene(korridor);
	free_scene(skjerm_rom);
	free_scene(bare_paa_lissom);

	free_materials();
	free_textures();
	free_video(vid);

	rtt_surface->lpVtbl->Release(rtt_surface);
	rtt_32_surface->lpVtbl->Release(rtt_32_surface);

	main_rendertarget->lpVtbl->Release(main_rendertarget);
	IDirect3DStateBlock9_Release(default_state);


	d3dwin_close();

	if (music_file) BASS_StreamFree( music_file );
	if (fp) file_close( fp );
	BASS_Free();

//	pest_close();

	return 0;
}
/*************************************************
 * Windows callback
 *************************************************/
static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    int time = timeGetTime() - start_time_;
    float ftime = 0.001f * time;

	// salvapantallas
	if( uMsg==WM_SYSCOMMAND && (wParam==SC_SCREENSAVE || wParam==SC_MONITORPOWER) )
		return( 0 );

	// boton x o pulsacion de escape
	//if( uMsg==WM_CLOSE || uMsg==WM_DESTROY || (uMsg==WM_KEYDOWN && wParam==VK_ESCAPE) )
	if( uMsg==WM_CLOSE || uMsg==WM_DESTROY )
		{
		PostQuitMessage(0);
        return( 0 );
		}

	// Reaction to command keys
    if( uMsg==WM_KEYDOWN )
    {
		switch (wParam)
		{
#if 0
		case VK_ESCAPE:
			PostQuitMessage(0);
			return 0;
#endif

		case VK_LEFT:
		case VK_RIGHT:
		case VK_UP:
		case VK_DOWN:
		case VK_PRIOR:
		case VK_NEXT:
		case VK_END:
		case VK_HOME:
			break;

		case VK_RETURN:
		case VK_DELETE:
		case VK_BACK:
			break;

#if 0
            BASS_Init(-1, 44100, 0, hWnd, NULL);
            mp3Str = BASS_StreamCreateFile(FALSE, "Goethe_music_quick.mp3", 0, 0, 0);
            BASS_ChannelPlay(mp3Str, TRUE);
            BASS_Start();
            BASS_Stop();
            BASS_ChannelStop(mp3Str);
            BASS_StreamFree(mp3Str);
            BASS_Free();
#endif

		default:
			break;
		}
    }

    if (uMsg == WM_KEYUP) {
        switch(wParam) {
        default:
            break;
        }
    }

    return( DefWindowProc(hWnd,uMsg,wParam,lParam) );
}