pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3782 - in trunk/pingus/src: display screen


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3782 - in trunk/pingus/src: display screen
Date: Fri, 11 Jul 2008 12:43:31 +0200

Author: grumbel
Date: 2008-07-11 12:43:21 +0200 (Fri, 11 Jul 2008)
New Revision: 3782

Modified:
   trunk/pingus/src/display/display.cpp
   trunk/pingus/src/display/display.hpp
   trunk/pingus/src/display/drawing_context.cpp
   trunk/pingus/src/display/drawing_context.hpp
   trunk/pingus/src/display/drawing_request.hpp
   trunk/pingus/src/display/scene_context.cpp
   trunk/pingus/src/display/scene_context.hpp
   trunk/pingus/src/screen/screen_manager.cpp
Log:
changed render() calls to use Framebuffer instead of SDL_Surface

Modified: trunk/pingus/src/display/display.cpp
===================================================================
--- trunk/pingus/src/display/display.cpp        2008-07-11 10:07:43 UTC (rev 
3781)
+++ trunk/pingus/src/display/display.cpp        2008-07-11 10:43:21 UTC (rev 
3782)
@@ -90,6 +90,12 @@
   return framebuffer->get_screen(); 
 }
 
+Framebuffer&
+Display::get_framebuffer()
+{
+  return *framebuffer.get(); 
+}
+
 void
 Display::push_cliprect(const Rect& rect)
 {

Modified: trunk/pingus/src/display/display.hpp
===================================================================
--- trunk/pingus/src/display/display.hpp        2008-07-11 10:07:43 UTC (rev 
3781)
+++ trunk/pingus/src/display/display.hpp        2008-07-11 10:43:21 UTC (rev 
3782)
@@ -50,6 +50,7 @@
   static void clear();
 
   static SDL_Surface* get_screen();
+  static Framebuffer& get_framebuffer();
 
   static void push_cliprect(const Rect&);
   static void pop_cliprect();

Modified: trunk/pingus/src/display/drawing_context.cpp
===================================================================
--- trunk/pingus/src/display/drawing_context.cpp        2008-07-11 10:07:43 UTC 
(rev 3781)
+++ trunk/pingus/src/display/drawing_context.cpp        2008-07-11 10:43:21 UTC 
(rev 3782)
@@ -19,11 +19,11 @@
 #include <algorithm>
 #include "drawing_context.hpp"
 #include "math.hpp"
+#include "framebuffer.hpp"
 #include "display/display.hpp"
 #include "../sprite.hpp"
 #include "../font.hpp"
 #include "../math/origin.hpp"
-
 
 struct DrawingRequestsSorter
 {
@@ -52,8 +52,8 @@
 
   virtual ~FontDrawingRequest() {}
 
-  void render(SDL_Surface* target, const Rect& rect) {
-    font.draw(origin, static_cast<int>(pos.x + rect.left), 
static_cast<int>(pos.y + rect.top), text, target);
+  void render(Framebuffer& fb, const Rect& rect) {
+    font.draw(origin, static_cast<int>(pos.x + rect.left), 
static_cast<int>(pos.y + rect.top), text, fb.get_screen());
   }
 };
 
@@ -71,8 +71,8 @@
 
   virtual ~SpriteDrawingRequest() {}
 
-  void render(SDL_Surface* target, const Rect& rect) {
-    sprite.render(pos.x + rect.left, pos.y + rect.top, target);
+  void render(Framebuffer& fb, const Rect& rect) {
+    sprite.render(pos.x + rect.left, pos.y + rect.top, fb.get_screen());
   }
 };
 
@@ -87,13 +87,13 @@
   }
   virtual ~FillScreenDrawingRequest() {}
 
-  void render(SDL_Surface* target, const Rect& rect) {
+  void render(Framebuffer& fb, const Rect& rect) {
     SDL_Rect r;
     r.x = rect.left;
     r.y = rect.top;
     r.w = rect.get_width();
     r.h = rect.get_height();
-    SDL_FillRect(target, &r, SDL_MapRGB(target->format, color.r, color.g, 
color.b));
+    SDL_FillRect(fb.get_screen(), &r, SDL_MapRGB(fb.get_screen()->format, 
color.r, color.g, color.b));
   }
 };
 
@@ -116,7 +116,7 @@
   {
   }
 
-  void render(SDL_Surface* target, const Rect& rect)
+  void render(Framebuffer& fb, const Rect& rect)
   {
     Display::draw_line(pos1 + Vector2i(rect.left, rect.top),
                        pos2 + Vector2i(rect.left, rect.top), color);
@@ -136,7 +136,7 @@
       d_rect(rect_), color(color_), filled(filled_)
   {}
   
-  void render(SDL_Surface* target, const Rect& rect)
+  void render(Framebuffer& fb, const Rect& rect)
   {
     if (filled)
       {
@@ -170,8 +170,8 @@
   {
   }
 
-  void render(SDL_Surface* target, const Rect& rect) {
-    dc.render(target, rect);
+  void render(Framebuffer& fb, const Rect& rect) {
+    dc.render(fb, rect);
   }
 };
 
@@ -196,7 +196,7 @@
 }
 
 void
-DrawingContext::render(SDL_Surface* target, const Rect& parent_rect)
+DrawingContext::render(Framebuffer& fb, const Rect& parent_rect)
 {
   Rect this_rect(Math::max(rect.left   + parent_rect.left, parent_rect.left),
                  Math::max(rect.top    + parent_rect.top,  parent_rect.top),
@@ -218,7 +218,7 @@
   for(DrawingRequests::iterator i = drawingrequests.begin(); i != 
drawingrequests.end(); ++i)
     {
       //std::cout << this << ": " << (*i)->get_z_pos() << std::endl;
-      (*i)->render(target, this_rect); // FIXME: Should we clip size against 
parent rect?
+      (*i)->render(fb, this_rect); // FIXME: Should we clip size against 
parent rect?
     }
 
   if (do_clipping) 

Modified: trunk/pingus/src/display/drawing_context.hpp
===================================================================
--- trunk/pingus/src/display/drawing_context.hpp        2008-07-11 10:07:43 UTC 
(rev 3781)
+++ trunk/pingus/src/display/drawing_context.hpp        2008-07-11 10:43:21 UTC 
(rev 3782)
@@ -26,9 +26,10 @@
 #include "../math/rect.hpp"
 #include "../math/color.hpp"
 
+class Framebuffer;
 class Font;
 class Sprite;
-
+
 /** The DrawingContext collects all DrawingRequests and allows you to
     flush them all down to the graphics card in one run, this has the
     advantage that it is possible to z-sort, texture-id sort or
@@ -54,7 +55,7 @@
   virtual ~DrawingContext();
 
   /** Draws everything in the drawing context to the target */
-  void render(SDL_Surface* target, const Rect& rect);
+  void render(Framebuffer& fb, const Rect& rect);
 
   /** Empties the drawing context */
   void clear();
@@ -138,11 +139,12 @@
   Vector2i world_to_screen(const Vector2i pos);
 
   void update_layout() {}
+
 private:
   DrawingContext (const DrawingContext&);
   DrawingContext& operator= (const DrawingContext&);
 };
-
+
 #endif
 
 /* EOF */

Modified: trunk/pingus/src/display/drawing_request.hpp
===================================================================
--- trunk/pingus/src/display/drawing_request.hpp        2008-07-11 10:07:43 UTC 
(rev 3781)
+++ trunk/pingus/src/display/drawing_request.hpp        2008-07-11 10:43:21 UTC 
(rev 3782)
@@ -21,8 +21,8 @@
 #include "math/vector3f.hpp"
 #include "math/rect.hpp"
 
-/** 
- */
+class Framebuffer;
+
 class DrawingRequest
 {
 protected:
@@ -35,7 +35,10 @@
   DrawingRequest(const Vector3f& pos_) : pos(pos_), valid(true) {}
   virtual ~DrawingRequest() {};
   
-  virtual void render(SDL_Surface* gc, const Rect& rect) = 0;
+  /** \a rect is the rectangle that is managed by the parent
+      DrawingContext, all calls to fb have to be offset with
+      (rect.left,rect.top)  */
+  virtual void render(Framebuffer& fb, const Rect& rect) = 0;
 
   virtual void mark(const Rect& r) { dirty_rects.push_back(r); }
   
@@ -52,7 +55,7 @@
   DrawingRequest (const DrawingRequest&);
   DrawingRequest& operator= (const DrawingRequest&);
 };
-
+
 #endif
 
 /* EOF */

Modified: trunk/pingus/src/display/scene_context.cpp
===================================================================
--- trunk/pingus/src/display/scene_context.cpp  2008-07-11 10:07:43 UTC (rev 
3781)
+++ trunk/pingus/src/display/scene_context.cpp  2008-07-11 10:43:21 UTC (rev 
3782)
@@ -18,8 +18,7 @@
 #include "scene_context.hpp"
 
 #define SCALE_FACTOR 8.0f
-
-
+
 class SceneContextImpl
 {
 public:
@@ -43,7 +42,7 @@
   {
   }
 };
-
+
 SceneContext::SceneContext()
 {
   impl = new SceneContextImpl();
@@ -151,19 +150,19 @@
 }
 
 void
-SceneContext::render(SDL_Surface* target, const Rect& rect)
+SceneContext::render(Framebuffer& fb, const Rect& rect)
 {
   // Render all buffers
   // FIXME: Render all to pbuffer for later combining of them
   if (impl->use_cliprect)
     {
       Display::push_cliprect(impl->cliprect);
-      impl->color.render(target, rect);
+      impl->color.render(fb, rect);
       Display::pop_cliprect();
     }
   else
     {
-      impl->color.render(target, rect);
+      impl->color.render(fb, rect);
     }
   
 #if 0
@@ -180,7 +179,7 @@
     }
 #endif
 
-    impl->highlight.render(target, rect);
+    impl->highlight.render(fb, rect);
 }
 
 void
@@ -203,10 +202,9 @@
 }
 
 void
-SceneContextDrawingRequest::render(SDL_Surface* gc, const Rect& rect) 
+SceneContextDrawingRequest::render(Framebuffer& fb, const Rect& rect) 
 {
-  sc->render(gc, rect);
+  sc->render(fb, rect);
 }
-
-
+
 /* EOF */

Modified: trunk/pingus/src/display/scene_context.hpp
===================================================================
--- trunk/pingus/src/display/scene_context.hpp  2008-07-11 10:07:43 UTC (rev 
3781)
+++ trunk/pingus/src/display/scene_context.hpp  2008-07-11 10:43:21 UTC (rev 
3782)
@@ -21,7 +21,7 @@
 #include "drawing_context.hpp"
 
 class SceneContextImpl;
-
+
 /** The SceneContext maintains all the different drawing layers to
     which a game object can draw. Each drawing layer serves a
     different purporse and all are combined in the end to form the
@@ -72,7 +72,7 @@
 
   /** Takes all the buffers and combines them to form the final image
       that will be shown on the screen */
-  void render(SDL_Surface* gc, const Rect& rect);
+  void render(Framebuffer& fb, const Rect& rect);
 
   void clear();
 private:
@@ -90,10 +90,9 @@
 public:
   SceneContextDrawingRequest(SceneContext* sc, const Vector3f& pos_ = 
Vector3f(0,0,0));
   virtual ~SceneContextDrawingRequest();
-  void render(SDL_Surface* gc, const Rect& render);
+  void render(Framebuffer& fb, const Rect& render);
 };
-
-
+
 #endif
 
 /* EOF */

Modified: trunk/pingus/src/screen/screen_manager.cpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.cpp  2008-07-11 10:07:43 UTC (rev 
3781)
+++ trunk/pingus/src/screen/screen_manager.cpp  2008-07-11 10:43:21 UTC (rev 
3782)
@@ -258,8 +258,8 @@
   get_current_screen()->draw(*display_gc);
   
   // Render the DrawingContext to the screen
-  display_gc->render(Display::get_screen(), Rect(Vector2i(0,0), 
Size(Display::get_width(),
-                                                                     
Display::get_height())));
+  display_gc->render(Display::get_framebuffer(), Rect(Vector2i(0,0), 
Size(Display::get_width(),
+                                                                          
Display::get_height())));
   display_gc->clear();
   
   // Draw the mouse pointer
@@ -348,8 +348,8 @@
       int border_y = int((Display::get_height()/2) * (1.0f - progress));
 
       old_screen->draw(*display_gc);
-      display_gc->render(Display::get_screen(), Rect(Vector2i(0,0), 
Size(Display::get_width(),
-                                                                         
Display::get_height())));
+      display_gc->render(Display::get_framebuffer(), Rect(Vector2i(0,0), 
Size(Display::get_width(),
+                                                                              
Display::get_height())));
       display_gc->clear();
       
       Display::push_cliprect(Rect(Vector2i(0 + border_x, 0 + border_y),
@@ -357,8 +357,8 @@
                                        Display::get_height() - 2*border_y)));
 
       new_screen->draw(*display_gc);
-      display_gc->render(Display::get_screen(), Rect(Vector2i(0,0), 
Size(Display::get_width(),
-                                                                         
Display::get_height())));
+      display_gc->render(Display::get_framebuffer(), Rect(Vector2i(0,0), 
Size(Display::get_width(),
+                                                                              
Display::get_height())));
       display_gc->clear();
       
       Display::pop_cliprect();





reply via email to

[Prev in Thread] Current Thread [Next in Thread]