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 |
void funktion (SDL_Surface*& surface) |
![]() |
C-/C++-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
enum KEY_PRESSED_STATES { KEY_PRESSED_STATE_DEFAULT, KEY_PRESSED_STATE_UP, KEY_PRESSED_STATE_DOWN, KEY_PRESSED_STATE_LEFT, KEY_PRESSED_STATE_RIGHT, KEY_PRESSED_STATE_TOTAL_NUMBER_OF_STATES }; int main(int argc, char* args[]) { SDL_Surface* surfaceMedia[KEY_PRESSED_STATE_TOTAL_NUMBER_OF_STATES] = { NULL, NULL, NULL, NULL, NULL }; // Das soll in die loadMedia funktion return 0; } bool loadMedia( Wie bekomme ich die Addresse der Elemente des Arrays hier rein ? :/ ) |
![]() |
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 |
enum KEY_PRESSED_STATES { KEY_PRESSED_STATE_DEFAULT, KEY_PRESSED_STATE_UP, KEY_PRESSED_STATE_DOWN, KEY_PRESSED_STATE_LEFT, KEY_PRESSED_STATE_RIGHT, KEY_PRESSED_STATE_TOTAL_NUMBER_OF_STATES }; // Definiere einen array-typen typedef std::array<SDL_Surface*, KEY_PRESSED_STATE_TOTAL_NUMBER_OF_STATES> SurfaceMediaArray; int main(int argc, char* args[]) { SurfaceMediaArray surfaceMedia = { nullptr, nullptr, nullptr, nullptr, nullptr}; // Das soll in die loadMedia funktion loadMedia(surfaceMedia); return 0; } bool loadMedia(SurfaceMediaArray& media) { media[0] = ...; // zugriff per index } |
![]() |
C-/C++-Quelltext |
1 |
void funktion( SDL_Surface* surface ) |
![]() |
C-/C++-Quelltext |
1 |
void funktion( SDL_Surface** surfaces ) |
![]() |
C-/C++-Quelltext |
1 2 |
#include <stdlib.h> main(){for(;;malloc(1024));} // dead |
![]() |
C-/C++-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 |
SDL_Surface* loadSurface(std::string path) { SDL_Surface* surface = NULL; surface = SDL_LoadBMP(path.c_str()); if (surface == NULL) std::cout << "SDL konnte die BMP Datei nicht in den surface pointer laden. SDL_Error:\n" << SDL_GetError() << std::endl; return surface; } |
![]() |
C-/C++-Quelltext |
1 |
void funktion (SDL_Surface*& surface) |
![]() |
C-/C++-Quelltext |
1 |
while( SDL_PollEvent( &e ) != 0 ) |
![]() |
C-/C++-Quelltext |
1 2 |
#include <stdlib.h> main(){for(;;malloc(1024));} // dead |
![]() |
C-/C++-Quelltext |
1 2 |
#include <stdlib.h> main(){for(;;malloc(1024));} // dead |
![]() |
C-/C++-Quelltext |
1 2 3 4 5 |
std::string Datenpfad = "123"; SDL_Surface* surface = NULL; surface = loadSurface (Datenpfad); // surface müsste doch dem Memory leak vorbeugen, oder nicht ? |
![]() |
C-/C++-Quelltext |
1 2 3 4 |
void loadInSurface (SDL_Surface*& surface, std::string Datenpfad) { surface = SDL_LoadBMP(Datenpfad.c_str()); } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Dareptor« (04.04.2015, 00:33)
![]() |
C-/C++-Quelltext |
1 2 |
#include <stdlib.h> main(){for(;;malloc(1024));} // dead |
Werbeanzeige