[Supertux-Commit] r5412 - in trunk/supertux/src: . video worldmap

grumbel at millhouse.dreamhost.com grumbel at millhouse.dreamhost.com
Mon May 5 08:05:58 PDT 2008


Author: grumbel
Date: 2008-05-05 08:05:57 -0700 (Mon, 05 May 2008)
New Revision: 5412

Modified:
   trunk/supertux/src/shrinkfade.cpp
   trunk/supertux/src/video/drawing_context.cpp
   trunk/supertux/src/video/drawing_context.hpp
   trunk/supertux/src/video/drawing_request.hpp
   trunk/supertux/src/video/gl_renderer.cpp
   trunk/supertux/src/video/gl_renderer.hpp
   trunk/supertux/src/video/renderer.hpp
   trunk/supertux/src/video/sdl_renderer.cpp
   trunk/supertux/src/video/sdl_renderer.hpp
   trunk/supertux/src/worldmap/worldmap.cpp
Log:
Replaced rectangular shrinkfade with a circular one

Modified: trunk/supertux/src/shrinkfade.cpp
===================================================================
--- trunk/supertux/src/shrinkfade.cpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/shrinkfade.cpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -46,24 +46,11 @@
 void
 ShrinkFade::draw(DrawingContext& context)
 {
-  Color black(0, 0, 0);
-  float left = speedleft * accum_time;
-  float top = speedtop * accum_time;
-  float right = SCREEN_WIDTH - speedright * accum_time;
-  float bottom = SCREEN_HEIGHT - speedbottom * accum_time;
-
-  context.draw_filled_rect(Vector(0, 0),
-                           Vector(left, SCREEN_HEIGHT),
-                           black, LAYER_GUI+1);
-  context.draw_filled_rect(Vector(0, 0),
-                           Vector(SCREEN_WIDTH, top),
-                           black, LAYER_GUI+1);
-  context.draw_filled_rect(Vector(right, 0),
-                           Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
-                           black, LAYER_GUI+1);
-  context.draw_filled_rect(Vector(0, bottom),
-                           Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
-                           black, LAYER_GUI+1);
+  float progress = accum_time / fade_time;
+  context.draw_inverse_ellipse(dest,
+                               Vector(2*SCREEN_WIDTH  * (1.0f - progress), 
+                                      2*SCREEN_HEIGHT * (1.0f - progress)),
+                               Color(0, 0, 0), LAYER_GUI+1);
 }
 
 bool

Modified: trunk/supertux/src/video/drawing_context.cpp
===================================================================
--- trunk/supertux/src/video/drawing_context.cpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/video/drawing_context.cpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -256,6 +256,29 @@
 }
 
 void
+DrawingContext::draw_inverse_ellipse(const Vector& pos, const Vector& size, const Color& color, int layer)
+{
+  DrawingRequest* request = new(obst) DrawingRequest();
+
+  request->target = target;
+  request->type   = INVERSEELLIPSE;
+  request->pos    = transform.apply(pos);
+  request->layer  = layer;
+
+  request->drawing_effect = transform.drawing_effect;
+  request->alpha = transform.alpha;
+
+  InverseEllipseRequest* ellipse = new(obst)InverseEllipseRequest;
+  
+  ellipse->color        = color;
+  ellipse->color.alpha  = color.alpha * transform.alpha;
+  ellipse->size         = size;
+  request->request_data = ellipse;
+
+  requests->push_back(request);     
+}
+
+void
 DrawingContext::get_light(const Vector& position, Color* color)
 {
   if( ambient_color.red == 1.0f && ambient_color.green == 1.0f
@@ -365,6 +388,9 @@
           case FILLRECT:
             renderer->draw_filled_rect(request);
             break;
+          case INVERSEELLIPSE:
+            renderer->draw_inverse_ellipse(request);
+            break;
           case GETLIGHT:
             lightmap->get_light(request);
             break;
@@ -391,6 +417,9 @@
           case FILLRECT:
             lightmap->draw_filled_rect(request);
             break;
+          case INVERSEELLIPSE:
+            assert(!"InverseEllipse doesn't make sense on the lightmap");
+            break;
           case GETLIGHT:
             lightmap->get_light(request);
             break;

Modified: trunk/supertux/src/video/drawing_context.hpp
===================================================================
--- trunk/supertux/src/video/drawing_context.hpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/video/drawing_context.hpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -80,6 +80,8 @@
   void draw_filled_rect(const Rect& rect, const Color& color, int layer);
   void draw_filled_rect(const Rect& rect, const Color& color, float radius, int layer);
 
+  void draw_inverse_ellipse(const Vector& pos, const Vector& size, const Color& color, int layer);
+
   /// Processes all pending drawing requests and flushes the list.
   void do_drawing();
 

Modified: trunk/supertux/src/video/drawing_request.hpp
===================================================================
--- trunk/supertux/src/video/drawing_request.hpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/video/drawing_request.hpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -70,7 +70,7 @@
 
 enum RequestType
 {
-  SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT, GETLIGHT
+  SURFACE, SURFACE_PART, TEXT, GRADIENT, FILLRECT, INVERSEELLIPSE, GETLIGHT
 };
 
 struct SurfacePartRequest
@@ -99,6 +99,12 @@
   float  radius;
 };
 
+struct InverseEllipseRequest
+{
+  Color  color;
+  Vector size;
+};
+
 struct DrawingRequest
 {
   Target target;

Modified: trunk/supertux/src/video/gl_renderer.cpp
===================================================================
--- trunk/supertux/src/video/gl_renderer.cpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/video/gl_renderer.cpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -326,6 +326,81 @@
       }
   }
 
+  void
+  Renderer::draw_inverse_ellipse(const DrawingRequest& request)
+  {
+    const InverseEllipseRequest* ellipse = (InverseEllipseRequest*)request.request_data;
+
+    glDisable(GL_TEXTURE_2D);
+    glColor4f(ellipse->color.red,  ellipse->color.green,
+              ellipse->color.blue, ellipse->color.alpha);
+    
+    float x = request.pos.x;
+    float y = request.pos.y;
+    float w = ellipse->size.x/2.0f;
+    float h = ellipse->size.y/2.0f;
+
+    glBegin(GL_TRIANGLES);
+    
+    // Bottom
+    glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
+    glVertex2f(0, SCREEN_HEIGHT);
+    glVertex2f(x, y+h);
+
+    // Top
+    glVertex2f(SCREEN_WIDTH, 0);
+    glVertex2f(0, 0);
+    glVertex2f(x, y-h);
+
+    // Left
+    glVertex2f(SCREEN_WIDTH, 0);
+    glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
+    glVertex2f(x+w, y);
+
+    // Right
+    glVertex2f(0, 0);
+    glVertex2f(0, SCREEN_HEIGHT);
+    glVertex2f(x-w, y);
+
+    glEnd();
+        
+    int slices = 8;
+    for(int i = 0; i < slices; ++i)
+      {
+        float ex1 = sinf(M_PI/2 / slices * i) * w;
+        float ey1 = cosf(M_PI/2 / slices * i) * h;
+
+        float ex2 = sinf(M_PI/2 / slices * (i+1)) * w;
+        float ey2 = cosf(M_PI/2 / slices * (i+1)) * h;
+
+        glBegin(GL_TRIANGLES);
+
+        // Bottom/Right
+        glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
+        glVertex2f(x + ex1, y + ey1);
+        glVertex2f(x + ex2, y + ey2);
+
+        // Top/Left
+        glVertex2f(0, 0);
+        glVertex2f(x - ex1, y - ey1);
+        glVertex2f(x - ex2, y - ey2);
+
+        // Top/Right
+        glVertex2f(SCREEN_WIDTH, 0);
+        glVertex2f(x + ex1, y - ey1);
+        glVertex2f(x + ex2, y - ey2);
+
+        // Bottom/Left
+        glVertex2f(0, SCREEN_HEIGHT);
+        glVertex2f(x - ex1, y + ey1);
+        glVertex2f(x - ex2, y + ey2);
+
+        glEnd();
+      }
+    glEnable(GL_TEXTURE_2D);
+    glColor4f(1, 1, 1, 1);    
+  }
+
   void 
   Renderer::do_take_screenshot()
   {

Modified: trunk/supertux/src/video/gl_renderer.hpp
===================================================================
--- trunk/supertux/src/video/gl_renderer.hpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/video/gl_renderer.hpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -38,6 +38,7 @@
     void draw_text(const DrawingRequest& request);
     void draw_gradient(const DrawingRequest& request);
     void draw_filled_rect(const DrawingRequest& request);
+    void draw_inverse_ellipse(const DrawingRequest& request);
     void do_take_screenshot();
     void flip();
   };

Modified: trunk/supertux/src/video/renderer.hpp
===================================================================
--- trunk/supertux/src/video/renderer.hpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/video/renderer.hpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -48,6 +48,7 @@
   virtual void draw_surface_part(const DrawingRequest& request) = 0;
   virtual void draw_gradient(const DrawingRequest& request) = 0;
   virtual void draw_filled_rect(const DrawingRequest& request)= 0;
+  virtual void draw_inverse_ellipse(const DrawingRequest& request)= 0;
   virtual void do_take_screenshot() = 0;
   virtual void flip() = 0;
 };

Modified: trunk/supertux/src/video/sdl_renderer.cpp
===================================================================
--- trunk/supertux/src/video/sdl_renderer.cpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/video/sdl_renderer.cpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -396,6 +396,11 @@
     }
   }
 
+  void
+  Renderer::draw_inverse_ellipse(const DrawingRequest&)
+  {
+  }
+
   void 
   Renderer::do_take_screenshot()
   {

Modified: trunk/supertux/src/video/sdl_renderer.hpp
===================================================================
--- trunk/supertux/src/video/sdl_renderer.hpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/video/sdl_renderer.hpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -36,6 +36,7 @@
     void draw_text(const DrawingRequest& request);
     void draw_gradient(const DrawingRequest& request);
     void draw_filled_rect(const DrawingRequest& request);
+    void draw_inverse_ellipse(const DrawingRequest& request);
     void do_take_screenshot();
     void flip();
   private:

Modified: trunk/supertux/src/worldmap/worldmap.cpp
===================================================================
--- trunk/supertux/src/worldmap/worldmap.cpp	2008-05-05 14:04:30 UTC (rev 5411)
+++ trunk/supertux/src/worldmap/worldmap.cpp	2008-05-05 15:05:57 UTC (rev 5412)
@@ -712,7 +712,7 @@
             save_state();
 
             main_loop->push_screen(new GameSession(levelfile, &level->statistics),
-                                   new ShrinkFade(shrinkpos, 0.5));
+                                   new ShrinkFade(shrinkpos, 1.0f));
             in_level = true;
           } catch(std::exception& e) {
             log_fatal << "Couldn't load level: " << e.what() << std::endl;




More information about the Supertux-Commit mailing list