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 ); } intro_init(); #ifdef USEDSOUND mzk_init( myMuzik+22 ); memcpy( myMuzik, wavHeader, 44 ); if( !sndPlaySound( (const char*)&myMuzik, SND_ASYNC|SND_MEMORY ) ) { window_end( info ); MessageBox( 0, "mzk???", "error", MB_OK|MB_ICONEXCLAMATION ); return( 0 ); } #endif 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 ); } intro_do( t ); if( t>(MZK_DURATION*1000) ) { done = 1; } SwapBuffers( info->hDC ); } sndPlaySound( 0, 0 ); window_end( info ); return( 0 ); }
void entrypoint( void ) { // full screen #ifdef SETRESOLUTION if( ChangeDisplaySettings(&screenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) return; ShowCursor( 0 ); #endif // create window HWND hWnd = CreateWindow("static",0,WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,0,0); HDC hDC = GetDC(hWnd); // initalize opengl if( !SetPixelFormat(hDC,ChoosePixelFormat(hDC,&pfd),&pfd) ) return; HGLRC hRC = wglCreateContext(hDC); wglMakeCurrent(hDC,hRC); // init intro intro_init(); // open audio device waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfx, 0, 0, CALLBACK_NULL); // create music block mzk_init(); // prepare and play music block for (int i = 0; i < NUM_PLAY_BLOCKS; i++) { header[i].lpData = (char *)myMuzikBlock[i]; header[i].dwBufferLength = AUDIO_BUFFER_SIZE * MZK_NUMCHANNELS * 2; waveOutPrepareHeader(hWaveOut, &(header[i]), sizeof(WAVEHDR)); waveOutWrite(hWaveOut, &(header[i]), sizeof(WAVEHDR)); } HANDLE thread = CreateThread(NULL, 0, thread_func, NULL, 0, 0); long t; long to = timeGetTime(); do { MSG msg; PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); ShowCursor(0); t = timeGetTime(); //if( !to ) to=t; t = t-to;//-150; intro_do( t ); //SwapBuffers ( hDC ); wglSwapLayerBuffers( hDC, WGL_SWAP_MAIN_PLANE ); }while ( !GetAsyncKeyState(VK_ESCAPE) && t<(MZK_DURATION*MZK_BLOCK_SIZE/MZK_RATE*1000) ); waveOutClose(hWaveOut); ExitProcess(0); }
void entrypoint( void ) { // full screen #ifdef SETRESOLUTION if( ChangeDisplaySettings(&screenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) return; ShowCursor( 0 ); #endif // create window HWND hWnd = CreateWindow( "static",0,WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,0,0); HDC hDC = GetDC(hWnd); // initalize opengl if( !SetPixelFormat(hDC,ChoosePixelFormat(hDC,&pfd),&pfd) ) return; HGLRC hRC = wglCreateContext(hDC); wglMakeCurrent(hDC,hRC); // init intro intro_init(); #ifdef USEDSOUND // calculate music mzk_init( myMuzik+22 ); // and play it memcpy( myMuzik, wavHeader, 44 ); sndPlaySound( (const char*)&myMuzik, SND_ASYNC|SND_MEMORY ); #endif long t; long to = timeGetTime(); do { //ShowCursor(false); t = timeGetTime(); //if( !to ) to=t; t = t-to;//-150; intro_do( t ); //SwapBuffers ( hDC ); wglSwapLayerBuffers( hDC, WGL_SWAP_MAIN_PLANE ); }while ( !GetAsyncKeyState(VK_ESCAPE) && t<(MZK_DURATION*1000) ); sndPlaySound(0,0); intro_end(); ExitProcess(0); }
void entrypoint( void ) { // full screen if( ChangeDisplaySettings(&screenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) return; ShowCursor( 0 ); // create window HWND hWnd = CreateWindow( "static",0,WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,0,0); if( !hWnd ) return; HDC hDC = GetDC(hWnd); // initalize opengl if( !SetPixelFormat(hDC,ChoosePixelFormat(hDC,&pfd),&pfd) ) return; wglMakeCurrent(hDC,wglCreateContext(hDC)); // init intro if( !intro_init() ) return; // init mzk mzk_init( myMuzik+22 ); memcpy( myMuzik, wavHeader, 44 ); // play mzk sndPlaySound( (const char*)&myMuzik, SND_ASYNC|SND_MEMORY ); // play intro long t; long to = timeGetTime(); do { t = timeGetTime() - to; intro_do( t ); wglSwapLayerBuffers( hDC, WGL_SWAP_MAIN_PLANE ); //SwapBuffers( hDC ); }while ( !GetAsyncKeyState(VK_ESCAPE) && t<(MZK_DURATION*1000) ); #ifdef CLEANDESTROY sndPlaySound(0,0); ChangeDisplaySettings( 0, 0 ); ShowCursor(1); #endif ExitProcess(0); }
void entrypoint( void ) { // full screen #ifdef SETRESOLUTION if( ChangeDisplaySettings(&screenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) return; #endif // create window HWND hWnd = CreateWindow( "static",0,WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,0,0); HDC hDC = GetDC(hWnd); // initalize opengl if( !SetPixelFormat(hDC,ChoosePixelFormat(hDC,&pfd),&pfd) ) return; HGLRC tempOpenGLContext; tempOpenGLContext = wglCreateContext(hDC); wglMakeCurrent(hDC, tempOpenGLContext); // create openGL functions for (int i=0; i<NUM_GL_NAMES; i++) glFP[i] = (GenFP)wglGetProcAddress(glnames[i]); HGLRC hRC = wglCreateContextAttribsARB(hDC, NULL, glAttribs); // Remove temporary context and set new one wglMakeCurrent(NULL, NULL); wglDeleteContext(tempOpenGLContext); wglMakeCurrent(hDC, hRC); // init intro intro_init(); // open audio device waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfx, 0, 0, CALLBACK_NULL); // create music block mzk_init(); // prepare and play music block header[0].lpData = (char *)myMuzikBlock[0]; header[1].lpData = (char *)myMuzikBlock[1]; header[0].dwBufferLength = AUDIO_BUFFER_SIZE * MZK_NUMCHANNELS * 2; header[1].dwBufferLength = AUDIO_BUFFER_SIZE * MZK_NUMCHANNELS * 2; waveOutPrepareHeader(hWaveOut, &(header[0]), sizeof(WAVEHDR)); waveOutWrite(hWaveOut, &(header[0]), sizeof(WAVEHDR)); waveOutPrepareHeader(hWaveOut, &(header[1]), sizeof(WAVEHDR)); waveOutWrite(hWaveOut, &(header[1]), sizeof(WAVEHDR)); timer.wType = TIME_SAMPLES; do { MSG msg; PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); ShowCursor(0); waveOutGetPosition(hWaveOut, &timer, sizeof(timer)); DWORD t = timer.u.sample; intro_do(t); //SwapBuffers ( hDC ); wglSwapLayerBuffers( hDC, WGL_SWAP_MAIN_PLANE ); // Try to unprepare header if (waveOutUnprepareHeader(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR)) != WAVERR_STILLPLAYING) { mzk_prepare_block(myMuzikBlock[nextPlayBlock]); waveOutPrepareHeader(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR)); waveOutWrite(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR)); nextPlayBlock = 1 - nextPlayBlock; } } while ( !(GetAsyncKeyState(VK_ESCAPE) || GetAsyncKeyState(VK_F4))); sndPlaySound(0,0); ExitProcess(0); }
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(); // 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 ); // Un-initialize COM CoUninitialize(); return( 0 ); }
void entrypoint( void ) { IDirect3DDevice9 *d3dDevice; IDirect3D9 *d3d = Direct3DCreate9( D3D_SDK_VERSION ); if( !d3d ) return; devParams.hDeviceWindow = CreateWindow( "static",0,WS_POPUP|WS_VISIBLE,0,0,XRES,YRES,0,0,0,0); if( d3d->CreateDevice( D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,devParams.hDeviceWindow,D3DCREATE_HARDWARE_VERTEXPROCESSING,&devParams,&d3dDevice) < 0 ) return; ShowCursor( 0 ); intro_init( d3dDevice ); #ifdef USEDSOUND short *myMuzik; unsigned long length; LPDIRECTSOUNDBUFFER m_pSecondary; LPDIRECTSOUND m_pDS; LPDIRECTSOUNDBUFFER m_pPrimary; DirectSoundCreate(0, &m_pDS, 0); m_pDS->SetCooperativeLevel(devParams.hDeviceWindow,DSSCL_PRIORITY); m_pDS->CreateSoundBuffer(&bufferDesc1,&m_pPrimary, NULL); m_pDS->CreateSoundBuffer(&bufferDesc2,&m_pSecondary,NULL); m_pPrimary->SetFormat(&format); m_pSecondary->Lock(0,MZK_NUMSAMPLESC*sizeof(short),(void**)&myMuzik,&length,NULL,NULL,NULL); #endif // calculate music mzk_init(myMuzik); // and play it #ifdef USEDSOUND m_pSecondary->Unlock(myMuzik,length,NULL,NULL); m_pSecondary->Play(0,0,0); #else memcpy( myMuzik, wavHeader, 44 ); sndPlaySound( (const char*)&myMuzik, SND_ASYNC|SND_MEMORY ); long to = timeGetTime(); long t = 65535; #endif // main loop do { #ifdef USEDSOUND unsigned long t; m_pSecondary->GetCurrentPosition(&t,NULL); t = 10*t/882; #else t = timeGetTime()-to; #endif intro_do( d3dDevice, t ); }while ( !GetAsyncKeyState(VK_ESCAPE) ); #ifndef USEDSOUND sndPlaySound(0,0); #endif #ifdef CLEANEXIT d3dDevice->Release(); d3d->Release(); DestroyWindow( devParams.hDeviceWindow ); #endif ExitProcess(0); }
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 ); } #ifdef USEDGRAPHICS intro_init(); #endif // open audio device if (waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfx, 0, 0, CALLBACK_NULL) != MMSYSERR_NOERROR) { MessageBox(0, "unable to open WAVE_MAPPER device", "error", MB_OK|MB_ICONEXCLAMATION); return 0; } // create music block mzk_init(); // prepare and play music block header[0].lpData = (char *)myMuzikBlock[0]; header[1].lpData = (char *)myMuzikBlock[1]; header[0].dwBufferLength = AUDIO_BUFFER_SIZE * MZK_NUMCHANNELS * 2; header[1].dwBufferLength = AUDIO_BUFFER_SIZE * MZK_NUMCHANNELS * 2; waveOutPrepareHeader(hWaveOut, &(header[0]), sizeof(WAVEHDR)); waveOutWrite(hWaveOut, &(header[0]), sizeof(WAVEHDR)); waveOutPrepareHeader(hWaveOut, &(header[1]), sizeof(WAVEHDR)); waveOutWrite(hWaveOut, &(header[1]), sizeof(WAVEHDR)); timer.wType = TIME_SAMPLES; while (!done) { waveOutGetPosition(hWaveOut, &timer, sizeof(timer)); DWORD t = timer.u.sample; while (PeekMessage(&msg,0,0,0,PM_REMOVE)) { if (msg.message==WM_QUIT) done=1; TranslateMessage(&msg); DispatchMessage(&msg); } #ifdef USEDGRAPHICS intro_do(t); #endif #if 0 if( t > (MZK_DURATION*1000) ) { done = 1; } #endif SwapBuffers(info->hDC); // Try to unprepare header if (waveOutUnprepareHeader(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR)) != WAVERR_STILLPLAYING) { #ifdef USEDSOUND mzk_prepare_block(myMuzikBlock[nextPlayBlock]); #endif waveOutPrepareHeader(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR)); waveOutWrite(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR)); nextPlayBlock = 1 - nextPlayBlock; } } // Close the wave output (for savety?) waveOutClose(hWaveOut); window_end( info ); return( 0 ); }
//void entrypoint( void ) int main( void ) { XEvent event; int done=0; WININFO *info = &wininfo; if( !smalloc_init() ) { #ifdef ERRORMSG printf( "window_init()!" ); #endif return( 1 ); } /* if( MessageBox( 0, "fullscreen?", info->wndclass, MB_YESNO|MB_ICONQUESTION)==IDYES ) info->full++; */ if( !window_init(info) ) { window_end( info ); #ifdef ERRORMSG printf( "window_init()!" ); #endif return( 2 ); } FONT_Init( (long)info->hDisplay ); if( !intro_init( XRES, YRES, 0, (int)info->hWnd ) ) { window_end( info ); #ifdef ERRORMSG printf( msg_error ); #endif return( 3 ); } while( !done ) { done = intro_do(); while( XPending(info->hDisplay) ) { XNextEvent( info->hDisplay, &event ); switch( event.type ) { case KeyPress: switch( XKeycodeToKeysym( info->hDisplay, event.xkey.keycode, 0 ) ) { case XK_Escape: done = 1; break; } break; case DestroyNotify: done = 1; break; } } glXSwapBuffers( info->hDisplay, info->hWnd ); } intro_end(); window_end( info ); smalloc_end(); return( 0 ); }