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 |
inline int f (int x) { return x; } namespace core { inline int f (int x) { return x*x; } inline int f2(int x) { return f(x); } } |
Anonymous
unregistriert
Ich könnte mal wieder etwas sagen, was den Begriff Abwärtskompatibilität beinhaltet, aber lassen wir das.Zitat von »"ext"«
Und zu deiner ursprünglichen Frage, verwende HINSTANCE und nicht HINSTANCE__* oder HWND__*
Wieso: Schau dir die WinAPI-Funktionen an und richte dich danach was die benutzen und die verwenden HINSTANCE und HWND
Zitat von »"nix da"«
Ich könnte mal wieder etwas sagen, was den Begriff Abwärtskompatibilität beinhaltet, aber lassen wir das.Zitat von »"ext"«
Und zu deiner ursprünglichen Frage, verwende HINSTANCE und nicht HINSTANCE__* oder HWND__*
Wieso: Schau dir die WinAPI-Funktionen an und richte dich danach was die benutzen und die verwenden HINSTANCE und HWND
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 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 |
//Spielteil: void CEngine::MainGame() { // check of user is trying to exit if (KEY_DOWN(VK_ESCAPE) || KEY_DOWN(VK_SPACE)) { MessageBox(main_window_handle, "Spiel wurde unterbrochen!", "Spiel wird beendet!", MB_OK); PostMessage(main_window_handle, WM_DESTROY,0,0); } // this is the workhorse of your game it will be called // continuously in real-time this is like main() in C // all the calls for you game go here! USHORT *back_buffer = NULL, // used to draw *dest_ptr = NULL, // used in line by line copy *src_ptr = NULL; // " " // erase secondary back buffer memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); // lock the secondary surface lpddsback->Lock(NULL,&ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL); // get video pointer to secondary surface back_buffer = (USHORT *)ddsd.lpSurface; // clear back buffer out, remember in 16bit mode there are // 2 bytes per pixel, so watch out for addressing and multiplying // issues in this code // linear memory if (ddsd.lPitch == SCREEN_WIDTH*2) memset(back_buffer,0,SCREEN_WIDTH*SCREEN_HEIGHT*(SCREEN_BPP/8)); else { // non-linear memory // make copy of video pointer dest_ptr = back_buffer; // clear out memory one line at a time for (int y=0; y < SCREEN_HEIGHT; y++) { // clear next line memset(dest_ptr,0,SCREEN_WIDTH*(SCREEN_BPP/8)); // advance pointer to next line dest_ptr+=(ddsd.lPitch/2); } // end for y } // end else // perform game logic... // draw the next frame into the secondary back buffer // plot 5000 random pixels for (unsigned int index = 0; index < 5000; index++) { int x = rand()%SCREEN_WIDTH; int y = rand()%SCREEN_HEIGHT; UCHAR red = rand()%256; UCHAR green = rand()%256; UCHAR blue = rand()%256; // back_buffer is a short pointer, BUT lpitch is in bytes // so divide by 2, to get number of "pixels" or words back_buffer[x+y*(ddsd.lPitch/2)] = _RGB16BIT565(red, green, blue); } // end for index // unlock secondary buffer lpddsback->Unlock(NULL); // flip pages if(lpddsprimary->Flip(NULL, DDFLIP_WAIT)!=DD_OK) { MessageBox(main_window_handle,"Es gab einen Fehler beim flippen!", "Flipping Fehler!",MB_OK); PostMessage(main_window_handle, WM_DESTROY,0,0); } } |
Werbeanzeige