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
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 |
{ LPVOID lpMsgBuf; int errorcode = GetLastError(); if(!errorcode) return; if (!FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL )) return; int i = (int)strlen((LPCTSTR)lpMsgBuf) + 1; delete[] LastError; LastError = new(char[i + 10]); memcpy(LastError, lpMsgBuf, i); char ecode[10]; sprintf(ecode, "%i", errorcode); memcpy(LastError + i - 1, ecode, 10); LocalFree( lpMsgBuf ); } |
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 |
#include "Headerpool.hpp" LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); Player tplayer; void init (GfxDevice gfxDC) { gfxDC.loadBitmap(tplayer.Bitmaps(0).path, tplayer.phDC(0), tplayer.phBitmap(0), tplayer.pBitmapInfo(0)); gfxDC.loadBitmap(tplayer.Bitmaps(1).path, tplayer.phDC(1), tplayer.phBitmap(1), tplayer.pBitmapInfo(1)); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrecInstancen, LPSTR lpCmdLine, int iCmdShow) { // initialisierung vom fenster... MSG msg; GfxDevice tgfx(hwnd); init(tgfx); unsigned long ulRenderTime = 0; while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); ulRenderTime = GetTickCount(); tgfx.renderFrame(); ulRenderTime = GetTickCount() - ulRenderTime; if(ulRenderTime < 60) Sleep(60 - ulRenderTime); } return static_cast<int>(msg.wParam); } // WinMain() LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { // ... return DefWindowProc(hwnd, msg, wParam, lParam); } // WndProc() |
Zitat von »"$nooc"«
meine frage ist jetzt eigentlich nur:
wieso wird da auf einmal der destructor aufgerufen?
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 |
LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wPar, LPARAM lPar); Player tplayer; void init (GfxDevice gfxDC) { gfxDC.loadBitmap(...); gfxDC.loadBitmap(...); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrecInstancen, LPSTR lpCmdLine, int iCmdShow) { // initialisierung vom fenster... MSG msg; GfxDevice tgfx(hwnd); init(tgfx); // ab hier ist tgfx nicht mehr gültig // der destruktor wird aufgerufen.. unsigned long ulRenderTime = 0; while(GetMessage(&msg, NULL, 0, 0)) { // irgendwas... } return static_cast<int>(msg.wParam); } // WinMain() |
Werbeanzeige