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 |
if (SDL_BlitSurface (text, NULL, display, NULL) != o){ cout << "SDL_BlitSurface () Failed: " << SDL_GetError () << endl; break;} |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Gamesjustforfun99« (07.10.2013, 06:37)
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Zudem steht in dem Code da "!= o" (ungleich Oh) und nicht "!= 0" (ungleich Null).
Wenn das so im Programm steht, wundert mich nichts.
Zitat
Erstmal danke für die schnellen antworten
Leider war das mit dem !=o nur ein Tippfehler
und schließlich kommt hier der ganze code
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 86 87 88 89 90 91 92 93 |
#include <iostream> #include <SDL.h> #include <SDL_ttf.h> using std::cerr; using std::endl; int main(int argc, char* args[]) { if (SDL_Init(SDL_INIT_VIDEO) != 0) { cerr << "SDL_Init() Failed: " << SDL_GetError() << endl; system ("pause"); exit(1); } SDL_Surface* display; display = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); if (display == NULL) { cerr << "SDL_SetVideoMode() Failed: " << SDL_GetError() << endl; system ("pause"); exit(1); } SDL_WM_SetCaption("SDL Tutorial", "SDL Tutorial"); if (TTF_Init() != 0) { cerr << "TTF_Init() Failed: " << TTF_GetError() << endl; SDL_Quit(); system ("pause"); exit(1); } TTF_Font *font; font = TTF_OpenFont("Data/arial.ttf", 24); if (font == NULL) { cerr << "TTF_OpenFont() Failed: " << TTF_GetError() << endl; TTF_Quit(); SDL_Quit(); system ("pause"); exit(1); } SDL_Surface *text; SDL_Color text_color = {255, 255, 255}; text = TTF_RenderText_Solid(font, "A journey of a thousand miles begins with a single step.", text_color); if (text == NULL) { cerr << "TTF_RenderText_Solid() Failed: " << TTF_GetError() << endl; TTF_Quit(); SDL_Quit(); system ("pause"); exit(1); } SDL_Event event; while(1) { if (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { break; } } if (SDL_FillRect(display, NULL, SDL_MapRGB( display->format, 0,0,0)) != 0) { cerr << "SDL_FillRect() Failed: " << SDL_GetError() << endl; system ("pause"); break; } if (SDL_BlitSurface(text, NULL, display, NULL) != 0) { cerr << "SDL_BlitSurface() Failed: " << SDL_GetError() << endl; //Diese Fehlermeldung wird immer ausgegeben system ("pause"); break; } SDL_Flip(display); SDL_FreeSurface (display); } TTF_Quit(); SDL_Quit(); return 0; } |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
In der SDL-Doku steht nicht, dass der vierte Parameter NULL sein darf. Vielleicht darf er's, aber drin steht's nicht.
Zitat
If srcrect is NULL, the entire surface is copied. If dstrect is NULL, then the destination position (upper left corner) is (0, 0).
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Werbeanzeige