modified: CMakeLists.txt
[supertux.git] / src / video / gl / gl_renderer.cpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //      Updated by GiBy 2013 for SDL2 <giby_the_kid@yahoo.fr>
4 //
5 //  This program is free software: you can redistribute it and/or modify
6 //  it under the terms of the GNU General Public License as published by
7 //  the Free Software Foundation, either version 3 of the License, or
8 //  (at your option) any later version.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 #include "video/gl/gl_renderer.hpp"
19
20 #include <iomanip>
21 #include <iostream>
22 #include <physfs.h>
23 #include "SDL2/SDL.h"
24 //#include "SDL/SDL.h"
25 //#include "SDL/SDL_opengl.h"
26
27 #include "supertux/gameconfig.hpp"
28 #include "supertux/globals.hpp"
29 #include "video/drawing_request.hpp"
30 #include "video/gl/gl_surface_data.hpp"
31 #include "video/gl/gl_texture.hpp"
32 #define LIGHTMAP_DIV 5
33
34 #ifdef GL_VERSION_ES_CM_1_0
35 #  define glOrtho glOrthof
36 #endif
37
38 GLRenderer::GLRenderer() :
39   desktop_size(-1, -1),
40   screen_size(-1, -1),
41   fullscreen_active(false),
42   last_texture(static_cast<GLuint> (-1))
43 {
44   Renderer::instance_ = this;
45
46 #if SDL_MAJOR_VERSION > 1 || SDL_MINOR_VERSION > 2 || (SDL_MINOR_VERSION == 2 && SDL_PATCHLEVEL >= 10)
47   // unfortunately only newer SDLs have these infos.
48   // This must be called before SDL_SetVideoMode() or it will return
49   // the window size instead of the desktop size.
50   const SDL_VideoInfo *info = SDL_GetVideoInfo();
51   if (info)
52   {
53     desktop_size = Size(info->current_w, info->current_h);
54   }
55 #endif
56
57   if(texture_manager != 0)
58     texture_manager->save_textures();
59
60 #ifdef SDL_GL_SWAP_CONTROL
61   if(config->try_vsync) {
62     /* we want vsync for smooth scrolling */
63      SDL_GL_SetSwapInterval(1);
64   }
65 #endif
66
67    SDL_GL_SetSwapInterval(SDL_GL_DOUBLEBUFFER, 1);
68
69   // FIXME: Hu? 16bit rendering?
70    SDL_GL_SetSwapInterval(5);
71    SDL_GL_SetSwapInterval(5);
72    SDL_GL_SetSwapInterval(5);
73
74   if(g_config->use_fullscreen)
75   {
76     apply_video_mode(g_config->fullscreen_size, true);
77   }
78   else
79   {
80     apply_video_mode(g_config->window_size, false);
81   }
82
83   // setup opengl state and transform
84   glDisable(GL_DEPTH_TEST);
85   glDisable(GL_CULL_FACE);
86   glEnable(GL_TEXTURE_2D);
87   glEnable(GL_BLEND);
88   glEnableClientState(GL_VERTEX_ARRAY);
89   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
90   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
91
92   // Init the projection matrix, viewport and stuff
93   apply_config();
94   
95   if(texture_manager == 0)
96     texture_manager = new TextureManager();
97   else
98     texture_manager->reload_textures();
99   
100 #ifndef GL_VERSION_ES_CM_1_0
101   GLenum err = glewInit();
102   if (GLEW_OK != err)
103   {
104     std::ostringstream out;
105     out << "GLRenderer: " << glewGetErrorString(err);
106     throw std::runtime_error(out.str());
107   }
108   log_info << "Using GLEW " << glewGetString(GLEW_VERSION) << std::endl;
109   log_info << "GLEW_ARB_texture_non_power_of_two: " << static_cast<int>(GLEW_ARB_texture_non_power_of_two) << std::endl;
110 #endif
111 }
112
113 GLRenderer::~GLRenderer()
114 {
115 }
116
117 void
118 GLRenderer::draw_surface(const DrawingRequest& request)
119 {
120   const Surface* surface = (const Surface*) request.request_data;
121   GLTexture* gltexture = static_cast<GLTexture*>(surface->get_texture().get());
122   GLSurfaceData *surface_data = static_cast<GLSurfaceData*>(surface->get_surface_data());
123
124   GLuint th = gltexture->get_handle();
125   if (th != last_texture) {
126     last_texture = th;
127     glBindTexture(GL_TEXTURE_2D, th);
128   }
129   intern_draw(request.pos.x, request.pos.y,
130               request.pos.x + surface->get_width(),
131               request.pos.y + surface->get_height(),
132               surface_data->get_uv_left(),
133               surface_data->get_uv_top(),
134               surface_data->get_uv_right(),
135               surface_data->get_uv_bottom(),
136               request.angle,
137               request.alpha,
138               request.color,
139               request.blend,
140               request.drawing_effect);
141 }
142
143 void
144 GLRenderer::draw_surface_part(const DrawingRequest& request)
145 {
146   const SurfacePartRequest* surfacepartrequest
147     = (SurfacePartRequest*) request.request_data;
148   const Surface* surface = surfacepartrequest->surface;
149   boost::shared_ptr<GLTexture> gltexture = boost::dynamic_pointer_cast<GLTexture>(surface->get_texture());
150   GLSurfaceData *surface_data = reinterpret_cast<GLSurfaceData *>(surface->get_surface_data());
151
152   float uv_width = surface_data->get_uv_right() - surface_data->get_uv_left();
153   float uv_height = surface_data->get_uv_bottom() - surface_data->get_uv_top();
154
155   float uv_left = surface_data->get_uv_left() + (uv_width * surfacepartrequest->source.x) / surface->get_width();
156   float uv_top = surface_data->get_uv_top() + (uv_height * surfacepartrequest->source.y) / surface->get_height();
157   float uv_right = surface_data->get_uv_left() + (uv_width * (surfacepartrequest->source.x + surfacepartrequest->size.x)) / surface->get_width();
158   float uv_bottom = surface_data->get_uv_top() + (uv_height * (surfacepartrequest->source.y + surfacepartrequest->size.y)) / surface->get_height();
159
160   GLuint th = gltexture->get_handle();
161   if (th != last_texture) {
162     last_texture = th;
163     glBindTexture(GL_TEXTURE_2D, th);
164   }
165   intern_draw(request.pos.x, request.pos.y,
166               request.pos.x + surfacepartrequest->size.x,
167               request.pos.y + surfacepartrequest->size.y,
168               uv_left,
169               uv_top,
170               uv_right,
171               uv_bottom,
172               0.0,
173               request.alpha,
174               request.color,
175               Blend(),
176               request.drawing_effect);
177 }
178
179 void
180 GLRenderer::draw_gradient(const DrawingRequest& request)
181 {
182   const GradientRequest* gradientrequest 
183     = (GradientRequest*) request.request_data;
184   const Color& top = gradientrequest->top;
185   const Color& bottom = gradientrequest->bottom;
186
187   glDisable(GL_TEXTURE_2D);
188   glDisableClientState(GL_TEXTURE_COORD_ARRAY);
189   glEnableClientState(GL_COLOR_ARRAY);
190
191   float vertices[] = {
192     0, 0,
193     float(SCREEN_WIDTH), 0,
194     float(SCREEN_WIDTH), float(SCREEN_HEIGHT),
195     0, float(SCREEN_HEIGHT)
196   };
197   glVertexPointer(2, GL_FLOAT, 0, vertices);
198
199   float colors[] = {
200     top.red, top.green, top.blue, top.alpha,
201     top.red, top.green, top.blue, top.alpha,
202     bottom.red, bottom.green, bottom.blue, bottom.alpha,
203     bottom.red, bottom.green, bottom.blue, bottom.alpha,
204   };
205   glColorPointer(4, GL_FLOAT, 0, colors);
206
207   glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
208
209   glDisableClientState(GL_COLOR_ARRAY);
210   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
211
212   glEnable(GL_TEXTURE_2D);
213   glColor4f(1, 1, 1, 1);
214 }
215
216 void
217 GLRenderer::draw_filled_rect(const DrawingRequest& request)
218 {
219   const FillRectRequest* fillrectrequest
220     = (FillRectRequest*) request.request_data;
221
222   glDisable(GL_TEXTURE_2D);
223   glColor4f(fillrectrequest->color.red, fillrectrequest->color.green,
224             fillrectrequest->color.blue, fillrectrequest->color.alpha);
225   glDisableClientState(GL_TEXTURE_COORD_ARRAY);
226   
227   if (fillrectrequest->radius != 0.0f)
228   {
229     // draw round rect
230     // Keep radius in the limits, so that we get a circle instead of
231     // just graphic junk
232     float radius = std::min(fillrectrequest->radius,
233                             std::min(fillrectrequest->size.x/2,
234                                      fillrectrequest->size.y/2));
235
236     // inner rectangle
237     Rectf irect(request.pos.x    + radius,
238                request.pos.y    + radius,
239                request.pos.x + fillrectrequest->size.x - radius,
240                request.pos.y + fillrectrequest->size.y - radius);
241
242     int n = 8;
243     int p = 0;
244     std::vector<float> vertices((n+1) * 4 * 2);
245
246     for(int i = 0; i <= n; ++i)
247     {
248       float x = sinf(i * (M_PI/2) / n) * radius;
249       float y = cosf(i * (M_PI/2) / n) * radius;
250
251       vertices[p++] = irect.get_left() - x;
252       vertices[p++] = irect.get_top()  - y;
253
254       vertices[p++] = irect.get_right() + x;
255       vertices[p++] = irect.get_top()   - y;
256     }
257
258     for(int i = 0; i <= n; ++i)
259     {
260       float x = cosf(i * (M_PI/2) / n) * radius;
261       float y = sinf(i * (M_PI/2) / n) * radius;
262
263       vertices[p++] = irect.get_left()   - x;
264       vertices[p++] = irect.get_bottom() + y;
265
266       vertices[p++] = irect.get_right()  + x;
267       vertices[p++] = irect.get_bottom() + y;
268     }
269
270     glVertexPointer(2, GL_FLOAT, 0, &*vertices.begin());
271     glDrawArrays(GL_TRIANGLE_STRIP, 0,  vertices.size()/2);
272   }
273   else
274   {
275     float x = request.pos.x;
276     float y = request.pos.y;
277     float w = fillrectrequest->size.x;
278     float h = fillrectrequest->size.y;
279
280     float vertices[] = {
281       x,   y,
282       x+w, y,
283       x+w, y+h,
284       x,   y+h
285     };
286     glVertexPointer(2, GL_FLOAT, 0, vertices);
287
288     glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
289   }
290
291   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
292   glEnable(GL_TEXTURE_2D);
293   glColor4f(1, 1, 1, 1);
294 }
295
296 void
297 GLRenderer::draw_inverse_ellipse(const DrawingRequest& request)
298 {
299   const InverseEllipseRequest* ellipse = (InverseEllipseRequest*)request.request_data;
300
301   glDisable(GL_TEXTURE_2D);
302   glColor4f(ellipse->color.red,  ellipse->color.green,
303             ellipse->color.blue, ellipse->color.alpha);
304     
305   float x = request.pos.x;
306   float y = request.pos.y;
307   float w = ellipse->size.x/2.0f;
308   float h = ellipse->size.y/2.0f;
309
310   static const int slices = 16;
311   static const int points = (slices+1) * 12;
312
313   float vertices[points * 2];
314   int   p = 0;
315
316   // Bottom
317   vertices[p++] = SCREEN_WIDTH; vertices[p++] = SCREEN_HEIGHT;
318   vertices[p++] = 0;            vertices[p++] = SCREEN_HEIGHT;
319   vertices[p++] = x;            vertices[p++] = y+h;
320
321   // Top
322   vertices[p++] = SCREEN_WIDTH; vertices[p++] = 0;
323   vertices[p++] = 0;            vertices[p++] = 0;
324   vertices[p++] = x;            vertices[p++] = y-h;
325
326   // Left
327   vertices[p++] = SCREEN_WIDTH; vertices[p++] = 0;
328   vertices[p++] = SCREEN_WIDTH; vertices[p++] = SCREEN_HEIGHT;
329   vertices[p++] = x+w;          vertices[p++] = y;
330
331   // Right
332   vertices[p++] = 0;            vertices[p++] = 0;
333   vertices[p++] = 0;            vertices[p++] = SCREEN_HEIGHT;
334   vertices[p++] = x-w;          vertices[p++] = y;
335
336   for(int i = 0; i < slices; ++i)
337   {
338     float ex1 = sinf(M_PI/2 / slices * i) * w;
339     float ey1 = cosf(M_PI/2 / slices * i) * h;
340
341     float ex2 = sinf(M_PI/2 / slices * (i+1)) * w;
342     float ey2 = cosf(M_PI/2 / slices * (i+1)) * h;
343
344     // Bottom/Right
345     vertices[p++] = SCREEN_WIDTH; vertices[p++] = SCREEN_HEIGHT;
346     vertices[p++] = x + ex1;      vertices[p++] = y + ey1;
347     vertices[p++] = x + ex2;      vertices[p++] = y + ey2;
348
349     // Top/Left
350     vertices[p++] = 0;            vertices[p++] = 0;
351     vertices[p++] = x - ex1;      vertices[p++] = y - ey1;
352     vertices[p++] = x - ex2;      vertices[p++] = y - ey2;
353
354     // Top/Right
355     vertices[p++] = SCREEN_WIDTH; vertices[p++] = 0;
356     vertices[p++] = x + ex1;      vertices[p++] = y - ey1;
357     vertices[p++] = x + ex2;      vertices[p++] = y - ey2;
358
359     // Bottom/Left
360     vertices[p++] = 0;            vertices[p++] = SCREEN_HEIGHT;
361     vertices[p++] = x - ex1;      vertices[p++] = y + ey1;
362     vertices[p++] = x - ex2;      vertices[p++] = y + ey2;
363   }
364
365   glDisableClientState(GL_TEXTURE_COORD_ARRAY);
366   glVertexPointer(2, GL_FLOAT, 0, vertices);
367
368   glDrawArrays(GL_TRIANGLES, 0, points);
369
370   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
371
372   glEnable(GL_TEXTURE_2D);
373   glColor4f(1, 1, 1, 1);    
374 }
375
376 void 
377 GLRenderer::do_take_screenshot()
378 {
379   // [Christoph] TODO: Yes, this method also takes care of the actual disk I/O. Split it?
380
381   SDL_Surface *shot_surf;
382   // create surface to hold screenshot
383 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
384   shot_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 24, 0x00FF0000, 0x0000FF00, 0x000000FF, 0);
385 #else
386   shot_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 24, 0x000000FF, 0x0000FF00, 0x00FF0000, 0);
387 #endif
388   if (!shot_surf) {
389     log_warning << "Could not create RGB Surface to contain screenshot" << std::endl;
390     return;
391   }
392
393   // read pixels into array
394   char* pixels = new char[3 * SCREEN_WIDTH * SCREEN_HEIGHT];
395   if (!pixels) {
396     log_warning << "Could not allocate memory to store screenshot" << std::endl;
397     SDL_FreeSurface(shot_surf);
398     return;
399   }
400   glPixelStorei(GL_PACK_ALIGNMENT, 1);
401   glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
402
403   // copy array line-by-line
404   for (int i = 0; i < SCREEN_HEIGHT; i++) {
405     char* src = pixels + (3 * SCREEN_WIDTH * (SCREEN_HEIGHT - i - 1));
406     if(SDL_MUSTLOCK(shot_surf))
407     {
408       SDL_LockSurface(shot_surf);
409     }
410     char* dst = ((char*)shot_surf->pixels) + i * shot_surf->pitch;
411     memcpy(dst, src, 3 * SCREEN_WIDTH);
412     if(SDL_MUSTLOCK(shot_surf))
413     {
414       SDL_UnlockSurface(shot_surf);
415     }
416   }
417
418   // free array
419   delete[](pixels);
420
421   // save screenshot
422   static const std::string writeDir = PHYSFS_getWriteDir();
423   static const std::string dirSep = PHYSFS_getDirSeparator();
424   static const std::string baseName = "screenshot";
425   static const std::string fileExt = ".bmp";
426   std::string fullFilename;
427   for (int num = 0; num < 1000; num++) {
428     std::ostringstream oss;
429     oss << baseName;
430     oss << std::setw(3) << std::setfill('0') << num;
431     oss << fileExt;
432     std::string fileName = oss.str();
433     fullFilename = writeDir + dirSep + fileName;
434     if (!PHYSFS_exists(fileName.c_str())) {
435       SDL_SaveBMP(shot_surf, fullFilename.c_str());
436       log_debug << "Wrote screenshot to \"" << fullFilename << "\"" << std::endl;
437       SDL_FreeSurface(shot_surf);
438       return;
439     }
440   }
441   log_warning << "Did not save screenshot, because all files up to \"" << fullFilename << "\" already existed" << std::endl;
442   SDL_FreeSurface(shot_surf);
443 }
444
445 void
446 GLRenderer::flip()
447 {
448   assert_gl("drawing");
449   SDL_GL_SwapWindow(screen)();
450 }
451
452 void
453 GLRenderer::resize(int w, int h)
454 {
455   // This causes the screen to go black, which is annoying, but seems
456   // unavoidable with SDL at the moment
457   SDL_CreateWindow(SDL_GL_CreateContext(w, h, 0, SDL_OPENGL | SDL_RESIZABLE));
458
459   g_config->window_size = Size(w, h);
460
461   apply_config();
462 }
463
464 void
465 GLRenderer::apply_config()
466 {    
467   if (false)
468   {
469     log_info << "Applying Config:" 
470              << "\n  Desktop: " << desktop_size.width << "x" << desktop_size.height
471              << "\n  Window:  " << g_config->window_size
472              << "\n  FullRes: " << g_config->fullscreen_size
473              << "\n  Aspect:  " << g_config->aspect_size
474              << "\n  Magnif:  " << g_config->magnification
475              << std::endl;
476   }
477
478   float target_aspect = static_cast<float>(desktop_size.width) / static_cast<float>(desktop_size.height);
479   if (g_config->aspect_size != Size(0, 0))
480   {
481     target_aspect = float(g_config->aspect_size.width) / float(g_config->aspect_size.height);
482   }
483
484   float desktop_aspect = 4.0f / 3.0f; // random default fallback guess
485   if (desktop_size.width != -1 && desktop_size.height != -1)
486   {
487     desktop_aspect = float(desktop_size.width) / float(desktop_size.height);
488   }
489
490   Size screen_size;
491
492   // Get the screen width
493   if (g_config->use_fullscreen)
494   {
495     screen_size = g_config->fullscreen_size;
496     desktop_aspect = float(screen_size.width) / float(screen_size.height);
497   }
498   else
499   {
500     screen_size = g_config->window_size;
501   }
502
503   apply_video_mode(screen_size, g_config->use_fullscreen);
504
505   if (target_aspect > 1.0f)
506   {
507     SCREEN_WIDTH  = static_cast<int>(screen_size.width * (target_aspect / desktop_aspect));
508     SCREEN_HEIGHT = static_cast<int>(screen_size.height);
509   }
510   else
511   {
512     SCREEN_WIDTH  = static_cast<int>(screen_size.width);
513     SCREEN_HEIGHT = static_cast<int>(screen_size.height  * (target_aspect / desktop_aspect));
514   }
515
516   Size max_size(1280, 800);
517   Size min_size(640, 480);
518
519   if (g_config->magnification == 0.0f) // Magic value that means 'minfill'
520   {
521     // This scales SCREEN_WIDTH/SCREEN_HEIGHT so that they never excede
522     // max_size.width/max_size.height resp. min_size.width/min_size.height
523     if (SCREEN_WIDTH > max_size.width || SCREEN_HEIGHT > max_size.height)
524     {
525       float scale1  = float(max_size.width)/SCREEN_WIDTH;
526       float scale2  = float(max_size.height)/SCREEN_HEIGHT;
527       float scale   = (scale1 < scale2) ? scale1 : scale2;
528       SCREEN_WIDTH  = static_cast<int>(SCREEN_WIDTH  * scale);
529       SCREEN_HEIGHT = static_cast<int>(SCREEN_HEIGHT * scale);
530     } 
531     else if (SCREEN_WIDTH < min_size.width || SCREEN_HEIGHT < min_size.height)
532     {
533       float scale1  = float(min_size.width)/SCREEN_WIDTH;
534       float scale2  = float(min_size.height)/SCREEN_HEIGHT;
535       float scale   = (scale1 < scale2) ? scale1 : scale2;
536       SCREEN_WIDTH  = static_cast<int>(SCREEN_WIDTH  * scale);
537       SCREEN_HEIGHT = static_cast<int>(SCREEN_HEIGHT * scale);
538     }
539    
540
541     glViewport(0, 0, screen_size.width, screen_size.height);
542   }
543   else
544   {
545     SCREEN_WIDTH  = static_cast<int>(SCREEN_WIDTH  / g_config->magnification);
546     SCREEN_HEIGHT = static_cast<int>(SCREEN_HEIGHT / g_config->magnification);
547
548     // This works by adding black borders around the screen to limit
549     // SCREEN_WIDTH/SCREEN_HEIGHT to max_size.width/max_size.height
550     Size new_size = screen_size;
551
552     if (SCREEN_WIDTH > max_size.width)
553     {
554       new_size.width = static_cast<int>((float) new_size.width * float(max_size.width)/SCREEN_WIDTH);
555       SCREEN_WIDTH = static_cast<int>(max_size.width);
556     }
557
558     if (SCREEN_HEIGHT > max_size.height)
559     {
560       new_size.height = static_cast<int>((float) new_size.height * float(max_size.height)/SCREEN_HEIGHT);
561       SCREEN_HEIGHT = static_cast<int>(max_size.height);
562     }
563
564     // Clear both buffers so that we get a clean black border without junk
565     glClear(GL_COLOR_BUFFER_BIT);
566     SDL_GL_SwapWindow(screen);
567     glClear(GL_COLOR_BUFFER_BIT);
568     SDL_GL_SwapWindow(screen);
569
570     glViewport(std::max(0, (screen_size.width  - new_size.width)  / 2),
571                std::max(0, (screen_size.height - new_size.height) / 2),
572                std::min(new_size.width,  screen_size.width),
573                std::min(new_size.height, screen_size.height));
574   }
575
576   glMatrixMode(GL_PROJECTION);
577   glLoadIdentity();
578
579   glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1, 1);
580
581   glMatrixMode(GL_MODELVIEW);
582   glLoadIdentity();
583   glTranslatef(0, 0, 0);
584   check_gl_error("Setting up view matrices");
585 }
586
587 void
588 GLRenderer::apply_video_mode(const Size& size, bool fullscreen)
589 {
590   // Only change video mode when its different from the current one
591   if (screen_size != size || fullscreen_active != fullscreen)
592   {
593     int flags = SDL_OPENGL;
594
595     if (fullscreen)
596     {
597       flags |= SDL_FULLSCREEN;
598     }
599     else
600     {
601       flags |= SDL_RESIZABLE;
602     }
603
604     if (SDL_Surface *screen = SDL_CreateWindow(SDL_GL_CreateContext( size.width, size.height, 0, flags)))
605     {
606       screen_size = Size(screen->w, screen->h);
607       fullscreen_active = fullscreen; 
608     }
609     else
610     {
611       std::ostringstream msg;
612       msg << "Couldn't set video mode " << size.width << "x" << size.height << ": " << SDL_GetError();
613       throw std::runtime_error(msg.str());
614     }
615   }
616 }
617
618 /* EOF */