bool SINMOVIE::PrepareMovie(IDirectDraw* pDD, IDirectDrawSurface *pDDSurface, char* FName)
{
if (!Open(pDD,FName,&pMMStream)) return false;
if (FAILED(pMMStream->GetMediaStream(MSPID_PrimaryVideo, &pPrimaryVidStream)))
{
  ShutDown();
  return false;
};     
if (FAILED(pPrimaryVidStream->QueryInterface(IID_IDirectDrawMediaStream, (void **)&pDDStream)))
{
  ShutDown();      
  return false;
}
if (FAILED(pDDStream->CreateSample(NULL, NULL, 0, &pSample)))
{
  ShutDown();
  return false;     
}
if (FAILED(pSample->GetSurface(&pSurface, &SRect)))
{
  ShutDown();          
  return false;
}
if (FAILED(pMMStream->SetState(STREAMSTATE_RUN)))
{
  ShutDown();
  return false;    
}
pMovieSurface=pDDSurface;
MovieState=1;
  
return true;
}
Example #2
0
static _Noreturn void mainLoop()
{
	uint32_t pad;

	while (true) {
		pad = InputWait();
		if (pad & (BUTTON_DOWN | BUTTON_RIGHT | BUTTON_R1))
			MenuNextSelection();

		if (pad & (BUTTON_UP | BUTTON_LEFT | BUTTON_L1))
			MenuPrevSelection();

		if (pad & BUTTON_A) {
			OpenAnimation();
			MenuSelect();
		}

		if (pad & BUTTON_SELECT) {
			fadeOut();
			ShutDown(1); //shutdown
		}
		if (pad & BUTTON_START) {
			fadeOut();
			ShutDown(0); //reboot
		}

		MenuShow();
	}
}
bool SINMOVIE::RenderStreamToSurface()
{
if (KeyState(VK_RETURN)) {  MovieState=2; ShutDown();return false; } 
if (pSample->Update(0, NULL, NULL, 0) != S_OK) {  MovieState=2; ShutDown(); return 
false; } 
pMovieSurface->Blt(&DRect, pSurface, &SRect, DDBLT_WAIT, NULL); 
return true;
}
void SINMOVIE::RenderStreamToSurfaceAll()
{
while (1)
{
  if (KeyState(VK_RETURN)) {  MovieState=2; ShutDown(); return; } 
  if (pSample->Update(0, NULL, NULL, 0) != S_OK) {  MovieState=2; ShutDown(); return; } 
  pMovieSurface->Blt(&DRect, pSurface, &SRect, DDBLT_WAIT, NULL); 
}
}
int CConnection::InitMulticast(const std::string& strRemoteSendStreamIp,
                               unsigned int uRemoteSendStreamPort,
                               const std::string& strLocalRecvStreamIp)
{

    //增加组播端口复用,复用选项必须在绑定之前设置
    //TODO为降低圈复杂度,此处未记录设置端口复用是否成功
    int isReusable = TRUE;
    if (::setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&isReusable, sizeof(isReusable)) == SOCKET_ERROR)
    {
        IVS_LOG(IVS_LOG_ERR, "Init Multicast",
            "Set Multicast Port Reusable error, error code:%d", WSAGetLastError());
        ShutDown();
        return IVS_FAIL;
    }

    // 初始化多播地址;
    struct ip_mreq mreq;
    memset(&mreq, 0, sizeof(mreq));

    //多播地址;
    mreq.imr_multiaddr.s_addr = inet_addr(strRemoteSendStreamIp.c_str());
    mreq.imr_interface.s_addr = inet_addr(strLocalRecvStreamIp.c_str());

    if (::setsockopt(m_socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&mreq, sizeof(mreq)) == SOCKET_ERROR)
    {
        IVS_LOG(IVS_LOG_ERR, "Init Multicast",
            "Get Multicast Port error, add multicast group failed, error code:%d", WSAGetLastError());
        ShutDown();
        return IVS_FAIL;
    }

    //将视频Socket缓存设置为1MByte 满足高清视频
    int iRecvBuf = IVS_PLAYER_RTP_MAX_SOCKET_BUFFER;
    int iOptLen = sizeof(iRecvBuf);

    if (::setsockopt(m_socket, SOL_SOCKET, SO_RCVBUF, (char*)&iRecvBuf, iOptLen) == SOCKET_ERROR)
    {
        IVS_LOG(IVS_LOG_ERR, "Init Multicast",
            "Get Multicast Port error, set receive buffer size=%d failed, error code:%d", iRecvBuf, errno);
    }
    else
    {
        iRecvBuf = 0;
        (void)getsockopt(m_socket, SOL_SOCKET, SO_RCVBUF, (char*)&iRecvBuf, &iOptLen);
        IVS_LOG(IVS_LOG_DEBUG, "Init Multicast",
            "Get Multicast Port success, set receive buffer size=%d", iRecvBuf);
    }

    return IVS_SUCCEED;
}//lint !e715
bool eae6320::Graphics::Initialize( const HWND i_renderingWindow )
{
	if (!Context::Initialize(i_renderingWindow))
		goto OnError;

	s_FrameRate.Create(eae6320::Time::GetFrameRate(), "Frame Rate");
	s_PlayerScore.Create(teamScore, "Score");
	s_EnemyScore.Create(enemyScore, "Score");
	eae6320::Graphics::DebugMenu::CreateDebugMenuFont();

	m_StaminaSprite.CreateTexture("data/Stamina.material", 0.9f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f);

	// Create the renderables
	if (!CreateRenderables())
		goto OnError;

	if (!CreateCamera())
		goto OnError;

	return true;

OnError:

	ShutDown();
	return false;
}
Example #7
0
Worker::~Worker()
{
	ShutDown();

	if (fWorkerThread >= 0)
		wait_for_thread(fWorkerThread, NULL);
}
Example #8
0
int main(int argc, char *argv[])
{
    ESContext esContext;
    UserData  userData;



    //==========================================================
    // Init GLES Context
    //==========================================================
    esInitContext ( &esContext );
    esContext.userData = &userData;

    esCreateWindow ( &esContext, "Model 3D Render", 640, 480, ES_WINDOW_ALPHA | ES_WINDOW_DEPTH);

    if ( !Init ( &esContext ) )
        return 0;

    esRegisterDrawFunc ( &esContext, Draw );
    esRegisterUpdateFunc ( &esContext, Update );


    esMainLoop ( &esContext );

    ShutDown ( &esContext );
    return 1;
}
void InputMonitor::Init(VideoOutputDevice* videoout, AudioOutputDevice* audioout) {
    ShutDown(); // Shut down devices and set them to NULL
    InnerSetVideoIn(m_Data->m_VID);
    InnerSetVideoOut(videoout);
    InnerSetAudioOut(audioout);
    AVController::Init();
}
Example #10
0
bool eae6320::Graphics::Initialize( const HWND i_renderingWindow )
{
	s_renderingWindow = i_renderingWindow;

	// Create an OpenGL rendering context
	if ( !CreateRenderingContext() )
	{
		goto OnError;
	}

	// Load any required OpenGL extensions
	{
		std::string errorMessage;
		if ( !OpenGlExtensions::Load( &errorMessage ) )
		{
			UserOutput::Print( errorMessage );
			goto OnError;
		}
	}

	if (!LoadObjects())
	{
		goto OnError;
	}

	return true;

OnError:

	ShutDown();
	return false;
}
Example #11
0
LRESULT CALLBACK ProcessCommand( WPARAM wParam )
{
	switch ( wParam )
	{
	case IDM_FILE_OPEN:
		OnFileOpen( );
		break;
	case  IDM_FILE_SAVE:
		break;
	case IDM_FILE_EXIT:
		ShutDown();
		break;
	case IDM_TOOLS_MOVE:
		//g_pDisplayWidget->SetState( DWS_MOVE );
		break;
	case  IDM_TOOLS_ZOOM:
		//g_pDisplayWidget->SetState( DWS_ZOOM );
		break;
	case ID_GEODESICMATTING_FORE:
		break;
	case ID_GEODESICMATTING_BACK:
		break;
	case ID_GEODESICMATTING_DONE:
		break;
	default:
		break;
	}
	return 0;
}
Example #12
0
void doRpcCall()
{
    char buff[1024];

    RpcTryExcept
    {
        while (1)
        {
            printf("Please input a string param for RPC call:\n");
            gets(buff);

            if ( strcmp(buff, "exit") == 0 || strcmp(buff, "quit") == 0 )
            {
                ShutDown();
                break;
            }
            else
            {
                HelloProc( (unsigned char *)buff );
                printf("RPC call <HelloProc> succeed!\n");
            }
        }
    }
    RpcExcept(1)
    {
        /*
        unsigned long ulCode = RpcExceptionCode();
        printf("RPC exception occured! code:  %ld\n", ulCode);
        */
    }
    RpcEndExcept
}
Example #13
0
CClientWizard::~CClientWizard()
{
	ShutDown();

	DeleteCriticalSection(&m_csHostList);
	DeleteCriticalSection(&m_csDecomposer);
}
Example #14
0
int _tmain(int argc, char* argv[])
{
    screenHeight = 600;
    screenWidth = 800;
    isFullScreen = false;
    isAnimated = true;

    gltSetWorkingDirectory(argv[0]);

    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
    glutInitWindowSize(screenWidth,screenHeight);

    glutCreateWindow("FBO Mirror");

    glutReshapeFunc(Reshape);
    glutDisplayFunc(Display);
    glutSpecialFunc(SpecialKeys);
    glutSpecialUpFunc(SpecialKeysUp);

    Init();
    glutMainLoop();
    ShutDown();

    return 0;
}
Example #15
0
int ExitProc(int  ccode,
             char *str)
{
  xcode code=(xcode)ccode;

  printf("\n Exit -- %d : ",ccode);
  
  switch (code) {
    case OptFound:
      printf("optimal solution found");
      return code;
    case OutOfSpc:
      printf("out of memory space");
      break;
    default:
      break;
  }
  if (str) printf(", %s",str);

  ShutDown();

  printf("\n Exiting --  ");

  return 1;
} /* ExitProc */
Example #16
0
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	switch(nIDEvent)
	{
	case AUTOSHUTDOWN:
		CTime currTime = CTime::GetCurrentTime();
		if(theApp.m_logicVariables.IsAutoCloseComputer)
		{
			CString strCurrtime;
			strCurrtime.Format(_T("%d:%d:%d"),currTime.GetHour(),currTime.GetMinute(),
				currTime.GetSecond());
			CString strCloseComputerTime;
			strCloseComputerTime.Format(_T("%d:%d:%d"),theApp.m_logicVariables.CloseComputerTime.GetHour(),
				theApp.m_logicVariables.CloseComputerTime.GetMinute(),
				theApp.m_logicVariables.CloseComputerTime.GetSecond());
			if(strCurrtime==strCloseComputerTime)
			{
				ShutDown();
			}
		}
		break;
	}
	CFrameWnd::OnTimer(nIDEvent);
}
Example #17
0
static _Noreturn void mainLoop()
{
	uint32_t pad;

	while (true) {
		drawBottom();
		pad = InputWait();

		if (pad & BUTTON_A) rxMode(1);		//EMUNAND
		if (pad & BUTTON_X) rxMode(0);		//SYSNAND
		if (pad & BUTTON_Y) PastaMode();	//PASTAMODE
		if (pad & BUTTON_B) ShutDown(1);	//SHUTDOWN
		if (pad & BUTTON_LEFT)
		{
			if(cfgs[CFG_DEFAULT].val.i == 0) cfgs[CFG_DEFAULT].val.i = 3;
			else cfgs[CFG_DEFAULT].val.i--;
			writeCfg();

		}
		if(pad & BUTTON_RIGHT)
		{
			if(cfgs[CFG_DEFAULT].val.i == 3) cfgs[CFG_DEFAULT].val.i = 0;
			else cfgs[CFG_DEFAULT].val.i++;
			writeCfg();
		}
	}
}
Example #18
0
int CamuleDaemonApp::OnExit()
{
#ifdef AMULED28
	/*
	 * Stop all socket threads before entering
	 * shutdown sequence.
	 */
	delete listensocket;
	listensocket = 0;
	if (clientudp) {
		delete clientudp;
		clientudp = NULL;
	}
#endif

	ShutDown();

#ifndef __WXMSW__
	int ret = sigaction(SIGCHLD, &m_oldSignalChildAction, NULL);
	if (ret == -1) {
		AddDebugLogLineC(logStandard, CFormat(wxT("CamuleDaemonApp::OnRun(): second sigaction() failed: %m.")));
	} else {
		AddDebugLogLineN(logGeneral, wxT("CamuleDaemonApp::OnRun(): Uninstallation of SIGCHLD callback with sigaction() succeeded."));
	}
#endif // __WXMSW__
	
	// lfroen: delete socket threads
	if (ECServerHandler) {
		ECServerHandler = 0;
	}

	delete core_timer;
	
	return CamuleApp::OnExit();
}
SkeletalTracker::~SkeletalTracker(void)
{
    if (m_pNuiImageDevice)
    {
        ShutDown();
    }
}
Example #20
0
void RunApplication()
{
   // create some qa objects
   QA *top = new QA("topping",
      "What topping would you like?",
      "topping.net",
      "I have a variety of toppings\n - try your favourite combination");
   QA *qty = new QA("quantity",
      "How many pizzas would you like?",
      "howmany.net",
      "I need to know how many pizzas to deliver");

   // Start recogniser running
   StartRecogniser();

   do{
      top->GetSlot();
      if (!terminated && top->status == grounded) qty->GetSlot();
      if (top->status == grounded && qty->status == grounded) {
         Talk("Your order is: \n   "+top->value+"  "+qty->value, "completed");
      }
      top->Reset(); qty->Reset();
      printf("\n\n=====================================\n\n");
   }while(!terminated);

   ShutDown();
}
Example #21
0
int main()
{
		
		Initialize(1024,720,false,"Game");

		////////takes in 1-9,A,B,C,D,E,F
		Sprite Player = Sprite("./rescources/Diva_Saya.jpg",640,480,"1.0f","1.0f","1.0f","1.0f");
		std::vector<Sprite> ex;
		ex.push_back(Player);
		ex.reserve(ex.size() +1);

		
		while (update()){ 
			_update_fps_counter (window);
			ClearScreen();

			ex[0].Input();
			ex[0].Draw();
			//Player.Input();
			//Player.Draw();
			double Delta = GetDeltaTime();
		}

		ShutDown();
		return 0; 
}
void DataSocket::OnClose(int nErrorCode) 
{
	TRACE0("CDataSocket() OnClose()\n");
	if (m_pConnectSocket)
	{
		// shutdown sends
		ShutDown(1);

		if (m_nStatus == XFERMODE_RECEIVE)
		{
			while(Receive() != 0)
			{
				// receive remaining data				
			}
		}
		else
		{
			/*m_pConnectSocket->SendResponse("426 Connection closed; transfer aborted.");
			// destroy this socket
			AfxGetThread()->PostThreadMessage(WM_THREADMSG, 0, 0);
			// upload failed
			((ConnectThread *)AfxGetThread())->UpdateStatistic(FTPSTAT_UPLOADFAILED);*/
		}
	}
	m_nStatus = XFERMODE_IDLE;	
	m_bConnected = FALSE;
	CAsyncSocket::OnClose(nErrorCode);
}
Example #23
0
void Clock::Initialize()
{
	DEBUGPRINTF( "Initializing Clock\n" );

	ShutDown();

#if BUILD_WINDOWS_NO_SDL
	LARGE_INTEGER Frequency;
	LARGE_INTEGER Counter;

	QueryPerformanceFrequency( &Frequency );
	QueryPerformanceCounter( &Counter );

	m_Resolution			= 1.0 / (double)Frequency.QuadPart;
	m_PhysicalBaseTime		= Counter.QuadPart;
#endif

#if BUILD_SDL
	Uint64 Frequency	= SDL_GetPerformanceFrequency();
	Uint64 Counter		= SDL_GetPerformanceCounter();

	m_Resolution			= 1.0 / static_cast<double>( Frequency );
	m_PhysicalBaseTime		= Counter;
#endif

	m_PhysicalDeltaTime		= 0;
	m_MachineDeltaTime		= 0.0f;
	m_GameDeltaTime			= 0.0f;

	m_PhysicalCurrentTime	= 0;
	m_MachineCurrentTime	= 0.0f;
	m_GameCurrentTime		= 0.0f;

	m_TickCount				= 0;
}
Example #24
0
/**
 * Executes the application
 * (contains main game loop)
 */
int SpringApp::Run()
{
	try {
		if (!Initialize())
			return -1;
	}
	CATCH_SPRING_ERRORS

	while (!gu->globalQuit) {
		Watchdog::ClearTimer(WDT_MAIN);
		input.PushEvents();

		if (gu->globalReload) {
			Reload(gameSetup->setupText);
		} else {
			if (!Update()) {
				break;
			}
		}
	}

	SaveWindowPosition();
	ShutDown();

	LOG("[SpringApp::%s] exitCode=%d", __FUNCTION__, GetExitCode());
	return (GetExitCode());
}
Example #25
0
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{	
	static bool init = false;
	// Handle some specific messages:
	switch( msg )
	{

	case WM_PAINT:
		init = true;
		break;

	case WM_CREATE:	
		g_widget[0] = new SceneRender( hWnd );		
		g_widget[1] = new SceneRender( hWnd );
		if ( NULL == g_widget[0] || NULL == g_widget[1] ) 
		{
			::PostMessage( hWnd, WM_CLOSE, 0, 0 );
		}
		else
		{
			g_widget[0]->Initialize();
			g_widget[0]->SetPosition( 10, 10, 600, 600 );
			g_widget[1]->Initialize();
			g_widget[1]->SetPosition( 620, 10, 600, 600 );
		}
		return 0;

	case WM_KEYDOWN:
		//g_pDisplayWidget->KeyDownProc( wParam, lParam );
		return 0;

	case WM_KEYUP:
		//g_pDisplayWidget->KeyUpProc( wParam, lParam );
		return 0;

	case WM_DESTROY: 		
		::PostQuitMessage(0); 
		return 0;

	case WM_SIZE:		
		UpdateLayout( hWnd );
		break;

	case WM_CLOSE:	
		ShutDown();
		return 0;

	case  WM_COMMAND:
		ProcessCommand( wParam );
		return 0;

	default:
		break;
	}

	// Forward any other messages we didn't handle
	// above to the default window procedure.
	return ::DefWindowProc(hWnd, msg, wParam, lParam);
}
Example #26
0
void Framework3D::Main()
{
	XTRACE_FUNCTION;

	Initialize();
	while( Tick() );
	ShutDown();
}
Example #27
0
	//=============================================================================================================
	CGame10::~CGame10()
	{
		// ...
		posteffects.clear();
		effects.clear();

		ShutDown();
	}
Example #28
0
void Main( int argc, char* argv[] )
{
	SaveCommandLineArguments( argc, argv );

	Initialize();
	while( Tick() );
	ShutDown();
}
Example #29
0
//-----------------------------------------------------------------------------
// Name : InitInstance ()
// Desc : Initialises the entire Engine here.
//-----------------------------------------------------------------------------
bool CDDGameApp::InitInstance( HANDLE hInstance, LPCTSTR lpCmdLine, int iCmdShow )
{
    // Create the primary display device
    if (!CreateDisplay()) { ShutDown(); return false; }

    // Build Objects
    if (!BuildSprites()) { ShutDown(); return false; }

    // Set up all required game states
    SetupGameState();

    // Setup our rendering environment
    //SetupRenderStates();

    // Success!
	return true;
}
Example #30
0
///
// kdMain()
//
//    Main function for OpenKODE application
//
KDint KD_APIENTRY kdMain(KDint argc, const KDchar *const *argv)
{
    Example *example = exampleInit();

    UserData userdata;
    example->userptr = &userdata;
    Init(example);

    KDust t1 = kdGetTimeUST();
    KDfloat32 deltatime;
    KDfloat32 totaltime = 0.0f;
    KDuint frames = 0;

    // Main Loop
    while(example->run)
    {
        const KDEvent *event = kdWaitEvent(-1);
        if(event)
        {
            switch(event->type)
            {
                case(KD_EVENT_QUIT):
                case(KD_EVENT_WINDOW_CLOSE):
                {
                    example->run = KD_FALSE;
                    break;
                }
                default:
                {
                    kdDefaultEvent(event);
                    break;
                }
            }
        }
        // Update
        KDust t2 = kdGetTimeUST();
        deltatime = (KDfloat32)((t2 - t1) * 1e-9);
        t1 = t2;
        Update(example, deltatime);

        // Draw frame
        Draw(example);
        exampleRun(example);

        // Benchmark
        totaltime += deltatime;
        frames++;
        if(totaltime > 5.0f)
        {
            kdLogMessagefKHR("%d frames in %3.1f seconds = %6.3f FPS\n", frames, totaltime, frames / totaltime);
            totaltime -= 5.0f;
            frames = 0;
        }
    }

    ShutDown(example);
    return exampleDestroy(example);
}