void MyConsole::Run() { Init(); // Disable auto render on format SetAutoRender(0); while (1) { RenderApp(); Update(); P1.update(); P2.update(); P1.Collision(&P2); P2.Collision(&P1); P1.Finalize(); P2.Finalize(); if (P1.score >= 5) { Alert("Player 1 Wins"); P1.setTexture(bg); P2.setTexture(bg); } else if (P2.score >= 5) { Alert("Player 2 Wins"); P1.setTexture(bg); P2.setTexture(bg); } mdelay(30); } }
void Browser::Run(const char *pRessourcePath) { Init(pRessourcePath); // Disable auto render on format SetAutoRender(0); #ifdef WIN32 strcpy(currentPath, "c:/"); #else // strcpy(currentPath, "uda0:/"); handle = -1; char * s = NULL; int next_device_n = 0; next_device_n = get_devices(next_device_n, s); strcpy(currentPath, s); ScanDir(); #endif while (1) { RenderApp(); Update(); } }
void Browser::SetProgressValue(float pct) { if (pct > 0.0f) { panelSelected = PANEL_PROGRESS; progressPct = pct; RenderApp(); } else { panelSelected = PANEL_FILE_LIST; } }
void Browser::Run(const char *pRessourcePath) { Init(pRessourcePath); // Disable auto render on format SetAutoRender(0); #ifdef WIN32 strcpy(currentPath, "c:/"); #else handle = 0; char path[2048]; handle = get_devices(handle, path); strcpy(currentPath, path); ScanDir(); #endif while (1) { RenderApp(); Update(); } }
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)); }
//-------------------------------------------------------------------------------------- // Entry point to the program. Initializes everything and goes into a message processing // loop. Idle time is used to render the scene. //-------------------------------------------------------------------------------------- int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); #ifdef USE_CONSOLE_BACKEND AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); #endif // init if (FAILED(InitWindow(hInstance, nCmdShow))) return 0; if (FAILED(InitBackend(g_hWnd))) { CleanupBackend(g_hWnd); return 0; } ShowWindow(g_hWnd, SW_SHOW); SetForegroundWindow(g_hWnd); SetFocus(g_hWnd); #ifdef USE_ANTTWBAR_BACKEND TwInit(TW_OPENGL, NULL); #endif #ifdef ANIMATE_BACKEND InitApp(); #else mainApp(); #endif // main loop static bool quit = false; MSG msg = { 0 }; while (!quit) { if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (msg.message == WM_QUIT) { quit = true; } #ifdef ANIMATE_BACKEND else { RenderApp(); #ifdef USE_ANTTWBAR_BACKEND TwDraw(); #endif SwapBuffersBackend(); } #endif } // cleanup #ifdef ANIMATE_BACKEND CleanupApp(); #endif #ifdef USE_ANTTWBAR_BACKEND TwTerminate(); #endif CleanupBackend(g_hWnd); CleanupWindow(); return (int)msg.wParam; }