예제 #1
0
파일: main.cpp 프로젝트: nlguillemot/spooky
void InitApp(UINT dpi)
{
	StartXAudio2();
	CHECK_HR(LoadSoundFiles());

	CHECK_HR(gpXAudio2->CreateSourceVoice(&gpSourceThunder, &gWfxThunder));
	CHECK_HR(gpXAudio2->CreateSourceVoice(&gpSourceCollectible, &gWfxCollectible));

    LARGE_INTEGER performanceFrequency, firstFrameTicks;
    CHECK_WIN32(QueryPerformanceFrequency(&performanceFrequency));
    CHECK_WIN32(QueryPerformanceCounter(&firstFrameTicks));
    gPerformanceFrequency = performanceFrequency.QuadPart;
    gLastFrameTicks = firstFrameTicks.QuadPart;
    gAccumulatedFrameTicks = 0;

    gpRenderer = std::make_unique<Renderer>(gpDevice.Get(), gpDeviceContext.Get(), gpDxgiDevice.Get(), dpi);
    gpRenderer->Init();

#define SIM_ORBIT_RADIUS 50.f
#define SIM_DISC_RADIUS  12.f
    auto center = DirectX::XMVectorSet(0.0f, 0.4f*SIM_DISC_RADIUS, 0.0f, 0.0f);
    auto radius = 35.0f;
    auto minRadius = SIM_ORBIT_RADIUS - 3.25f * SIM_DISC_RADIUS;
    auto maxRadius = SIM_ORBIT_RADIUS + 3.0f * SIM_DISC_RADIUS;
    auto longAngle = 1.50f;
    auto latAngle = 0.75f;
    gCamera.View(center, radius, minRadius, maxRadius, longAngle, latAngle);
}
예제 #2
0
// Initialize a file descriptor from a 
void VssFileDescriptor::Initialize(
        IVssWMFiledesc * pFileDesc, 
        VSS_DESCRIPTOR_TYPE typeParam
        )
{
    FunctionTracer ft(DBG_INFO);

    // Set the type
    type = typeParam;

    CComBSTR bstrPath;
    CHECK_COM(pFileDesc->GetPath(&bstrPath));

    CComBSTR bstrFilespec;
    CHECK_COM(pFileDesc->GetFilespec (&bstrFilespec));

    bool bRecursive = false;
    CHECK_COM(pFileDesc->GetRecursive(&bRecursive));

    CComBSTR bstrAlternate;
    CHECK_COM(pFileDesc->GetAlternateLocation(&bstrAlternate));

    // Initialize local data members
    path = BSTR2WString(bstrPath);
    filespec = BSTR2WString(bstrFilespec);
    expandedPath = bRecursive;
    path = BSTR2WString(bstrPath);

    // Get the expanded path
    expandedPath.resize(MAX_PATH, L'\0');
    _ASSERTE(bstrPath && bstrPath[0]);
    CHECK_WIN32(ExpandEnvironmentStringsW(bstrPath, (PWCHAR)expandedPath.c_str(), (DWORD)expandedPath.length()));
    expandedPath = AppendBackslash(expandedPath);

    // Get the affected volume 
    if (!GetUniqueVolumeNameForPathNoThrow(expandedPath, affectedVolume))
    {
        affectedVolume = expandedPath;
    }

}
예제 #3
0
파일: main.cpp 프로젝트: nlguillemot/spooky
void UpdateApp()
{
    gCamera.ProcessInertia();

    LARGE_INTEGER currFrameTicks;
    CHECK_WIN32(QueryPerformanceCounter(&currFrameTicks));

    UINT64 deltaTicks = currFrameTicks.QuadPart - gLastFrameTicks;
    gAccumulatedFrameTicks += deltaTicks;

    const UINT64 kMillisecondsPerUpdate = 1000 / kUpdateFrequency;
    const UINT64 kTicksPerMillisecond = gPerformanceFrequency / 1000;
    const UINT64 kTicksPerUpdate = kMillisecondsPerUpdate * kTicksPerMillisecond;
    
    while (gAccumulatedFrameTicks >= kTicksPerUpdate)
    {
        gpRenderer->Update(kMillisecondsPerUpdate);
        gAccumulatedFrameTicks -= kTicksPerUpdate;
    }

    gLastFrameTicks = currFrameTicks.QuadPart;
}
예제 #4
0
파일: main.cpp 프로젝트: nlguillemot/spooky
int main()
{
    UINT dpi = SetupDPI();

    gRenderScale = 96.0 / double(dpi);

    // Scale default window size based on dpi
    gWindowWidth *= dpi / 96;
    gWindowHeight *= dpi / 96;

    // Create window
    {
        WNDCLASSEX wc;
        ZeroMemory(&wc, sizeof(wc));
        wc.cbSize = sizeof(wc);
        wc.style = CS_HREDRAW | CS_VREDRAW;
        wc.lpfnWndProc = MyWndProc;
        wc.hInstance = GetModuleHandle(NULL);
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
        wc.lpszClassName = TEXT("WindowClass");
        CHECK_WIN32(RegisterClassEx(&wc));

        RECT wr = { 0, 0, gWindowWidth, gWindowHeight };
        CHECK_WIN32(AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE));
        ghWnd = CHECK_WIN32(CreateWindowEx(
            0, TEXT("WindowClass"),
            TEXT("Spooky"), WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, wr.right - wr.left, wr.bottom - wr.top,
            0, 0, GetModuleHandle(NULL), 0));
    }

    // Create D3D11 device and swap chain
    {
        ComPtr<IDXGIFactory> pFactory;
        CHECK_HR(CreateDXGIFactory(IID_PPV_ARGS(&pFactory)));

        UINT deviceFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifdef _DEBUG
        deviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

        RECT clientRect;
        GetClientRect(ghWnd, &clientRect);

        DXGI_SWAP_CHAIN_DESC scd{};
        scd.BufferCount = kSwapChainBufferCount;
        scd.BufferDesc.Format = kSwapChainFormat;
        scd.BufferDesc.Width = clientRect.right - clientRect.left;
        scd.BufferDesc.Height = clientRect.bottom - clientRect.top;
        scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
        scd.OutputWindow = ghWnd;
        scd.Windowed = TRUE;
        scd.SampleDesc.Count = 1;
        scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;

        CHECK_HR(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, deviceFlags, NULL, 0, D3D11_SDK_VERSION, &scd, &gpSwapChain, &gpDevice, NULL, &gpDeviceContext));
		CHECK_HR(gpDevice.As(&gpDxgiDevice));


	}

    InitApp(dpi);

    ShowWindow(ghWnd, SW_SHOWNORMAL);

    EnableMouseInPointer(TRUE);

    while (!gShouldClose)
    {
        // Handle all events
        MSG msg;
        while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0)
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        UpdateApp();

        RenderApp();

        // Swap buffers
        CHECK_HR(gpSwapChain->Present(0, 0));
    }
	CoUninitialize(); // <- this currently creates problems with the WIC Factory.
    CHECK_HR(gpSwapChain->SetFullscreenState(FALSE, NULL));
}