@@ -8,46 +8,47 @@ DrawContext::DrawContext(App* _app)
88
99SDL_Surface* DrawContext::makeTextSurface (char * text, SDL_Color color)
1010{
11- if (!app->font ) {
12- throw " No font for make text surface." ;
13- }
14- if (!text) {
15- throw " No text for make text surface." ;
16- }
17- SDL_Surface* surfaceMessage = TTF_RenderText_Blended (app->font , text, color);
18- if (!surfaceMessage) {
19- throw " Surface message creation failed" ;
20- }
21- return surfaceMessage;
11+ if (!app->font ) {
12+ throw " No font for make text surface." ;
13+ }
14+ if (!text) {
15+ throw " No text for make text surface." ;
16+ }
17+ SDL_Surface* surfaceMessage = TTF_RenderText_Blended (app->font , text, color);
18+ if (!surfaceMessage) {
19+ throw " Surface message creation failed" ;
20+ }
21+ return surfaceMessage;
2222}
2323
2424SDL_Texture* DrawContext::createTextureFromSurface (SDL_Surface* surface)
2525{
26- if (!surface) {
27- throw " No surface for making texture" ;
28- }
29- SDL_Texture* texture = SDL_CreateTextureFromSurface (app->renderer , surface);
30- if (!texture) {
31- throw " Texture creation failed" ;
32- }
33- return texture;
26+ if (!surface) {
27+ throw " No surface for making texture" ;
28+ }
29+ SDL_Texture* texture = SDL_CreateTextureFromSurface (app->renderer , surface);
30+ if (!texture) {
31+ throw " Texture creation failed" ;
32+ }
33+ return texture;
3434}
3535
3636SDL_Rect DrawContext::drawText (char * text, SDL_Color color, int x, int y)
3737{
38- SDL_Surface* surfaceMessage = makeTextSurface (text, color);
39- SDL_Texture* Message = createTextureFromSurface (surfaceMessage);
38+ SDL_Surface* surfaceMessage = makeTextSurface (text, color);
39+ SDL_Texture* Message = createTextureFromSurface (surfaceMessage);
4040
41- SDL_Rect Message_rect;
42- Message_rect.x = x;
43- Message_rect.y = y;
44- Message_rect.w = surfaceMessage->w ;
45- Message_rect.h = surfaceMessage->h ;
41+ SDL_Rect Message_rect;
42+ Message_rect.x = x;
43+ Message_rect.y = y;
44+ Message_rect.w = surfaceMessage->w ;
45+ Message_rect.h = surfaceMessage->h ;
4646
47- SDL_RenderCopy (renderer, Message, NULL , &Message_rect);
4847
49- SDL_FreeSurface (surfaceMessage);
50- SDL_DestroyTexture (Message);
48+ SDL_RenderCopy (app->renderer , Message, NULL , &Message_rect);
5149
52- return Message_rect;
50+ SDL_FreeSurface (surfaceMessage);
51+ SDL_DestroyTexture (Message);
52+
53+ return Message_rect;
5354}
0 commit comments