Prevent crash on exit.
[supertux.git] / src / video / gl_lightmap.cpp
index f37b540..9287bec 100644 (file)
@@ -98,11 +98,11 @@ inline void intern_draw(float left, float top, float right, float bottom,
     bottom -= center_y;
 
     float vertices[] = {
-               left*ca - top*sa + center_x, left*sa + top*ca + center_y,
-               right*ca - top*sa + center_x, right*sa + top*ca + center_y,
-               right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
-               left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
-       };
+        left*ca - top*sa + center_x, left*sa + top*ca + center_y,
+        right*ca - top*sa + center_x, right*sa + top*ca + center_y,
+        right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
+        left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
+    };
     glVertexPointer(2, GL_FLOAT, 0, vertices);
 
     float uvs[] = {
@@ -152,7 +152,9 @@ namespace GL
 
   Lightmap::~Lightmap()
   {
-    texture_manager->remove_texture(lightmap);
+    if(texture_manager){
+      texture_manager->remove_texture(lightmap);
+    }
     delete lightmap;
   }
 
@@ -162,7 +164,11 @@ namespace GL
     glViewport(0, screen->h - lightmap_height, lightmap_width, lightmap_height);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
+#ifdef GL_VERSION_ES_CM_1_0
+    glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+#else
     glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+#endif
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
 
@@ -180,7 +186,11 @@ namespace GL
     glViewport(0, 0, screen->w, screen->h);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
+#ifdef GL_VERSION_ES_CM_1_0
+    glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+#else
     glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+#endif
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     glEnable(GL_BLEND);