コード例 #1
0
ファイル: cutscene.cpp プロジェクト: grakidov/Render3D
HRESULT PlayCutscene(LPTSTR szMovie, HINSTANCE hInstance)
{
    HRESULT hr;

    // Create the main hidden window to field keyboard input
    if (!CreateHiddenWindow(hInstance, szMovie))
        return E_FAIL;

    // Initialize COM
    if (FAILED(hr = CoInitialize(NULL)))
        return hr;

    // Get DirectShow interfaces
    if (FAILED(hr = GetInterfaces()))
    {
        CoUninitialize();
        return hr;
    }

    // Play the movie / cutscene
    hr = PlayMedia(szMovie, hInstance);

    // If the user interrupted playback and there was no other error,
    // return S_FALSE.
    if ((hr == S_OK) && g_bUserInterruptedPlayback)
        hr = S_FALSE;

    // Release DirectShow interfaces
    CleanupInterfaces();
    CoUninitialize();

    return hr;
}
コード例 #2
0
bool WindowsHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
	hWnd = CreateHiddenWindow();

	if (WINDOW_VISIBLE) {
		ShowWindow(hWnd, TRUE);
		SetFocus(hWnd);
	}

	WindowsGraphicsContext *graphicsContext = nullptr;
	switch (gpuCore_) {
	case GPU_NULL:
	case GPU_GLES:
	case GPU_SOFTWARE:
		graphicsContext = new WindowsGLContext();
		break;

	case GPU_DIRECTX9:
		graphicsContext = new D3D9Context();
		break;

	case GPU_DIRECTX11:
		return false;

	case GPU_VULKAN:
		graphicsContext = new WindowsVulkanContext();
		break;
	}

	if (graphicsContext->Init(NULL, hWnd, error_message)) {
		*ctx = graphicsContext;
		gfx_ = graphicsContext;
	} else {
		delete graphicsContext;
		*ctx = nullptr;
		gfx_ = nullptr;
		return false;
	}

	if (gpuCore_ == GPU_GLES) {
		// TODO: Do we need to do this here?
		CheckGLExtensions();
	}

	LoadNativeAssets();

	return true;
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: Init_TrackIR
//-----------------------------------------------------------------------------
void CInput::Init_TrackIR( void ) 
{ 
#if !defined( _X360 )
	if ( !IsHeadTrackingEnabled() )
		return;

	ZeroMemory(&g_angleCenter, sizeof(g_angleCenter));

	HWND hWnd = CreateHiddenWindow();
	NPRESULT  result = NPS_Init(hWnd);

	// Mark the TrackIR as available and advanced initialization not completed
	// this is needed as correctly set cvars are not available this early during initialization
	// FIXME:  Is this still the case?
	Msg( "TrackIR initialized [%d]\n", result ); 
	m_fTrackIRAvailable = true; 
#endif
}
コード例 #4
0
void WindowsHeadlessHost::InitGL()
{
	glOkay = false;
	hWnd = CreateHiddenWindow();

	if (WINDOW_VISIBLE)
	{
		ShowWindow(hWnd, TRUE);
		SetFocus(hWnd);
	}

	int pixelFormat;

	static PIXELFORMATDESCRIPTOR pfd = {0};
	pfd.nSize = sizeof(pfd);
	pfd.nVersion = 1;
	pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 32;
	pfd.cDepthBits = 16;
	pfd.iLayerType = PFD_MAIN_PLANE;

#define ENFORCE(x, msg) { if (!(x)) { fprintf(stderr, msg); return; } }

	ENFORCE(hDC = GetDC(hWnd), "Unable to create DC.");
	ENFORCE(pixelFormat = ChoosePixelFormat(hDC, &pfd), "Unable to match pixel format.");
	ENFORCE(SetPixelFormat(hDC, pixelFormat, &pfd), "Unable to set pixel format.");
	ENFORCE(hRC = wglCreateContext(hDC), "Unable to create GL context.");
	ENFORCE(wglMakeCurrent(hDC, hRC), "Unable to activate GL context.");

	SetVSync(0);

	glewInit();
	glstate.Initialize();

	LoadNativeAssets();

	if (ResizeGL())
		glOkay = true;
}
コード例 #5
0
ファイル: TSVNCache.cpp プロジェクト: webtronix1/tortoisesvn
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*cmdShow*/)
{
    SetDllDirectory(L"");
    CAutoGeneralHandle hReloadProtection = ::CreateMutex(NULL, FALSE, GetCacheMutexName());

    if ((!hReloadProtection) || (GetLastError() == ERROR_ALREADY_EXISTS))
    {
        // An instance of TSVNCache is already running
        CTraceToOutputDebugString::Instance()(__FUNCTION__ ": TSVNCache ignoring restart\n");
        return 0;
    }

    // set the current directory to the users temp dir
    TCHAR pathbuf[MAX_PATH] = { 0 };
    GetTempPath(_countof(pathbuf), pathbuf);
    SetCurrentDirectory(pathbuf);

    apr_initialize();
    svn_dso_initialize2();
    svn_error_set_malfunction_handler(svn_error_handle_malfunction);
    g_SVNAdminDir.Init();
    CSVNStatusCache::Create();
    CSVNStatusCache::Instance().Init();

    SecureZeroMemory(szCurrentCrawledPath, sizeof(szCurrentCrawledPath));

    // create a hidden window to receive window messages.
    hWndHidden = CreateHiddenWindow(hInstance);
    hTrayWnd = hWndHidden;
    if (hWndHidden == NULL)
    {
        return 0;
    }
    if (CRegStdDWORD(L"Software\\TortoiseSVN\\CacheTrayIcon", FALSE)==TRUE)
    {
        SecureZeroMemory(&niData,sizeof(NOTIFYICONDATA));

        DWORD dwMajor = 0;
        DWORD dwMinor = 0;
        GetShellVersion(&dwMajor, &dwMinor);
        DWORD dwVersion = PACKVERSION(dwMajor, dwMinor);

        if (dwVersion >= PACKVERSION(6,0))
            niData.cbSize = sizeof(NOTIFYICONDATA);
        else if (dwVersion >= PACKVERSION(5,0))
            niData.cbSize = NOTIFYICONDATA_V2_SIZE;
        else
            niData.cbSize = NOTIFYICONDATA_V1_SIZE;

        niData.uID = TRAY_ID;       // own tray icon ID
        niData.hWnd  = hWndHidden;
        niData.uFlags = NIF_ICON|NIF_MESSAGE;

        // load the icon
        niData.hIcon =
            (HICON)LoadImage(hInstance,
            MAKEINTRESOURCE(IDI_TSVNCACHE),
            IMAGE_ICON,
            GetSystemMetrics(SM_CXSMICON),
            GetSystemMetrics(SM_CYSMICON),
            LR_DEFAULTCOLOR);

        // set the message to send
        // note: the message value should be in the
        // range of WM_APP through 0xBFFF
        niData.uCallbackMessage = TRAY_CALLBACK;
        Shell_NotifyIcon(NIM_ADD,&niData);
        // free icon handle
        if(niData.hIcon && DestroyIcon(niData.hIcon))
            niData.hIcon = NULL;
    }

    // Create a thread which waits for incoming pipe connections
    unsigned int threadId = 0;

    CAutoGeneralHandle hPipeThread = (HANDLE)_beginthreadex(NULL, 0, PipeThread, &bRun, 0, &threadId);
    if (!hPipeThread)
        return 0;

    // Create a thread which waits for incoming pipe connections
    CAutoGeneralHandle hCommandWaitThread =
        (HANDLE)_beginthreadex(NULL, 0, CommandWaitThread, &bRun, 0, &threadId);
    if (hCommandWaitThread)
    {
        // loop to handle window messages.
        MSG msg;
        while (bRun)
        {
            const BOOL bLoopRet = GetMessage(&msg, NULL, 0, 0);
            if ((bLoopRet != -1)&&(bLoopRet != 0))
            {
                DispatchMessage(&msg);
            }
        }
    }

    bRun = false;

    Shell_NotifyIcon(NIM_DELETE,&niData);
    CSVNStatusCache::Destroy();
    g_SVNAdminDir.Close();
    apr_terminate();

    return 0;
}