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
TheTribalK
unregistriert
C-/C++-Quelltext |
|
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 |
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int ) { HRESULT hr; if(SUCCEEDED(CoInitialize(NULL))) { MyApp NewApp; MSG message; hr = NewApp.Initialize(hInstance); if(SUCCEEDED(hr)) hr= NewApp.BitmapLoadFromFile(); bool x = true; if(SUCCEEDED(hr)) while (x == true) { NewApp.Draw(); if (GetMessage (&message, NULL, 0, 0)) { TranslateMessage (&message); DispatchMessage (&message); }; }; return (int)(message.wParam); }; CoUninitialize(); }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
LRESULT CALLBACK MyApp::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DISPLAYCHANGE: { InvalidateRect(hwnd, NULL, FALSE); return 0; } case WM_DESTROY: { PostQuitMessage(0); return 0; } } return DefWindowProc(hwnd, message, wParam, lParam); } |
C-/C++-Quelltext |
|
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 |
HRESULT MyApp::Initialize(HINSTANCE hInstance) { HRESULT hr; WNDCLASSEX classex = {sizeof(classex)}; classex.style = CS_HREDRAW | CS_VREDRAW; classex.lpfnWndProc = WndProc; classex.cbWndExtra = 0; classex.cbClsExtra = 0; classex.hInstance = hInstance; classex.hCursor = LoadCursor(NULL, IDC_ARROW); classex.lpszClassName = L"D2DBitmapFromFileDemoApp"; RegisterClassEx(&classex); hwnd = CreateWindow( L"D2DBitmapFromFileDemoApp", L"D2DBitmapFromFileDemoApp", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1024, 768, NULL, NULL, hInstance, this ); if(hwnd == NULL) return E_FAIL; ShowWindow(hwnd, SW_SHOWNORMAL); UpdateWindow(hwnd); hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pD2DFactory); if(!SUCCEEDED(hr)) return hr; hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pWICFactory)); if(!SUCCEEDED(hr)) return hr; XPos = 0; return S_OK; }; |
C-/C++-Quelltext |
|
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 |
void MyApp::Draw() { XPos += Timer.GetElapsed() * 0.1; if (XPos > 1024) XPos -= 1024; pRenderTarget->BeginDraw(); pRenderTarget->DrawBitmap( pBitmap, D2D1::RectF(XPos, 0, 1024, 768), 1, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, D2D1::RectF(0, 0, 1024 - XPos, 768)); if (XPos != 0) pRenderTarget->DrawBitmap( pBitmap, D2D1::RectF(0, 0, XPos - 1, 768), 1, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, D2D1::RectF(1024 - XPos, 0, 1024, 768)); pRenderTarget->EndDraw(); }; |
TheTribalK
unregistriert
TheTribalK
unregistriert
Werbeanzeige