Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Anonymous
unregistriert
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
#include "RBWRenderDevice.h" #include "RBWRenderer.h" bool bDone = false; bool g_bIsActive = false; HWND hwnd; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASSEX wndclass; TCHAR szAppClass[] = TEXT("FrameWorktest"); MSG msg; // Set up window attributes wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = szAppClass; wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(RegisterClassEx(&wndclass) == 0) return 0; // create window hwnd = CreateWindowEx(NULL, szAppClass, "ZFX Graphics Tutorial - Demo Application", WS_OVERLAPPEDWINDOW | WS_VISIBLE, GetSystemMetrics(SM_CXSCREEN)/2 -1280 / 2, GetSystemMetrics(SM_CYSCREEN)/2 - 1024 / 2, 1280, 1024, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, SW_HIDE); ShowWindow(hwnd, SW_SHOW); LPRBWRENDERER g_pRenderer = NULL; LPRBWRENDERDEVICE g_pDevice = NULL; g_pRenderer = new RBWRenderer(hInstance); g_pRenderer->CreateDevice("Direct3D"); g_pDevice = g_pRenderer->GetDevice(); g_pDevice->Init(hwnd); while(!bDone) { while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); }; if(g_bIsActive) { g_pDevice->BeginRendering(true, true, true); g_pDevice->Clear(true, true, true); g_pDevice->EndRendering(); } }; g_pRenderer->Release(); g_pDevice->Release(); return (int)msg.wParam; }; LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { // our app has the focus case WM_ACTIVATE: { g_bIsActive = bool(wParam); } break; // key was pressed case WM_KEYDOWN: { switch (wParam) { case VK_ESCAPE: { bDone = true; PostMessage(hwnd, WM_CLOSE, 0, 0); return 0; } break; } } break; // we are ordered to suicide case WM_DESTROY: { bDone = true; PostQuitMessage(0); return 1; } break; default: break; } return DefWindowProc(hwnd, message, wParam, lParam); } |
Administrator
Werbeanzeige