pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] rev 2315 - in branches/pingus_0_6/src: . gui worldobjs


From: Ingo Ruhnke
Subject: [Pingus-CVS] rev 2315 - in branches/pingus_0_6/src: . gui worldobjs
Date: Fri, 07 May 2004 19:52:34 +0200

Author: grumbel
Date: 2004-05-07 19:52:34 +0200 (Fri, 07 May 2004)
New Revision: 2315

Modified:
   branches/pingus_0_6/src/gui/buffer_graphic_context.cxx
   branches/pingus_0_6/src/gui/buffer_graphic_context.hxx
   branches/pingus_0_6/src/gui/display_graphic_context.cxx
   branches/pingus_0_6/src/gui/display_graphic_context.hxx
   branches/pingus_0_6/src/gui/graphic_context.cxx
   branches/pingus_0_6/src/gui/graphic_context.hxx
   branches/pingus_0_6/src/pingus_main.cxx
   branches/pingus_0_6/src/worldobjs/solid_color_background.cxx
Log:
- added clear to graphic context

Modified: branches/pingus_0_6/src/gui/buffer_graphic_context.cxx
===================================================================
--- branches/pingus_0_6/src/gui/buffer_graphic_context.cxx      2004-05-07 
15:57:21 UTC (rev 2314)
+++ branches/pingus_0_6/src/gui/buffer_graphic_context.cxx      2004-05-07 
17:52:34 UTC (rev 2315)
@@ -20,6 +20,7 @@
 #include <iostream>
 #include "../pingus_error.hxx"
 #include "../blitter.hxx"
+#include "../color.hxx"
 #include "../screenshot.hxx"
 #include "buffer_graphic_context.hxx"
 
@@ -88,4 +89,19 @@
   canvas->unlock();
 }
 
+void
+BufferGraphicContext::clear(const Color& color)
+{
+  canvas->lock();
+  unsigned char* buf = static_cast<unsigned char*>(canvas->get_data());
+  for(unsigned int i = 0; i < canvas->get_height() * canvas->get_width(); ++i)
+    {
+      buf[4*i + 0] = static_cast<unsigned char>(color.alpha*255); // alpha
+      buf[4*i + 1] = static_cast<unsigned char>(color.blue*255); // blue
+      buf[4*i + 2] = static_cast<unsigned char>(color.green*255); // green
+      buf[4*i + 3] = static_cast<unsigned char>(color.red*255); // red
+    }
+  canvas->unlock();  
+}
+
 /* EOF */

Modified: branches/pingus_0_6/src/gui/buffer_graphic_context.hxx
===================================================================
--- branches/pingus_0_6/src/gui/buffer_graphic_context.hxx      2004-05-07 
15:57:21 UTC (rev 2314)
+++ branches/pingus_0_6/src/gui/buffer_graphic_context.hxx      2004-05-07 
17:52:34 UTC (rev 2315)
@@ -86,6 +86,8 @@
   void print_center (FontHandle /*font*/, int /*x_pos*/, int /*y_pos*/, const 
std::string& /*str*/) {}
   void print_right (FontHandle /*font*/, int /*x_pos*/, int /*y_pos*/, const 
std::string& /*str*/) {}
 
+  void clear(const Color& color);
+
   /** Write the current content of the buffer down to a pnm file */
   void write(const std::string& filename);
 };

Modified: branches/pingus_0_6/src/gui/display_graphic_context.cxx
===================================================================
--- branches/pingus_0_6/src/gui/display_graphic_context.cxx     2004-05-07 
15:57:21 UTC (rev 2314)
+++ branches/pingus_0_6/src/gui/display_graphic_context.cxx     2004-05-07 
17:52:34 UTC (rev 2315)
@@ -22,6 +22,7 @@
 #include <ClanLib/Display/Font/font.h>
 #include <config.h>
 #include "display_graphic_context.hxx"
+#include "../color.hxx"
 #include "../math.hxx"
 #include "../sprite.hxx"
 
@@ -276,4 +277,10 @@
   font->print_right(w2s_x(x_pos), w2s_y(y_pos), str.c_str ());
 }
 
+void
+DisplayGraphicContext::clear(const Color& color)
+{
+  CL_Display::clear_display (color.red, color.green, color.blue, color.alpha);
+}
+
 /* EOF */

Modified: branches/pingus_0_6/src/gui/display_graphic_context.hxx
===================================================================
--- branches/pingus_0_6/src/gui/display_graphic_context.hxx     2004-05-07 
15:57:21 UTC (rev 2314)
+++ branches/pingus_0_6/src/gui/display_graphic_context.hxx     2004-05-07 
17:52:34 UTC (rev 2315)
@@ -126,6 +126,7 @@
 
   void print_right (FontHandle font, int x_pos, int y_pos, const std::string& 
str);
 
+  void clear(const Color& color);
 private:
   DisplayGraphicContext (const DisplayGraphicContext&);
   DisplayGraphicContext& operator= (const DisplayGraphicContext&);

Modified: branches/pingus_0_6/src/gui/graphic_context.cxx
===================================================================
--- branches/pingus_0_6/src/gui/graphic_context.cxx     2004-05-07 15:57:21 UTC 
(rev 2314)
+++ branches/pingus_0_6/src/gui/graphic_context.cxx     2004-05-07 17:52:34 UTC 
(rev 2315)
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include "../color.hxx"
 #include "../sprite.hxx"
 #include "graphic_context.hxx"
 
@@ -39,7 +40,6 @@
   draw(sur, int(pos.x), int(pos.y), frame);
 }
 
-
 void
 GraphicContext::draw (CL_Surface& sur, const Vector& pos)
 {

Modified: branches/pingus_0_6/src/gui/graphic_context.hxx
===================================================================
--- branches/pingus_0_6/src/gui/graphic_context.hxx     2004-05-07 15:57:21 UTC 
(rev 2314)
+++ branches/pingus_0_6/src/gui/graphic_context.hxx     2004-05-07 17:52:34 UTC 
(rev 2315)
@@ -24,6 +24,7 @@
 #include "../vector.hxx"
 #include <ClanLib/Core/Math/rect.h>
 
+class Color;
 class Sprite;
 class CL_Surface;
 class CL_Font;
@@ -110,6 +111,9 @@
 
   /** Print a text right aligned */
   virtual void print_right (FontHandle font, int x_pos, int y_pos, const 
std::string& str) =0;
+
+  /** Clear the graphic context */
+  virtual void clear(const Color& color) =0;
 };
 
 #endif

Modified: branches/pingus_0_6/src/pingus_main.cxx
===================================================================
--- branches/pingus_0_6/src/pingus_main.cxx     2004-05-07 15:57:21 UTC (rev 
2314)
+++ branches/pingus_0_6/src/pingus_main.cxx     2004-05-07 17:52:34 UTC (rev 
2315)
@@ -529,6 +529,7 @@
         << "\n   --controller FILE        " << _("Uses the controller given in 
FILE")
 
         << "\n\n" << _("Debugging and experimental stuff:")
+        << "\n   --render-preview " << _("FILE    ") << _("Renders the 
levelfile into FILE in .pnm format")
         << "\n   --maintainer-mode        " << _("Enables some features, only 
interesting programmers")
         << "\n   --debug OPTION           " << _("Enable the output of 
debugging infos, possible")
         << "\n                            " << _("OPTION's are tiles, 
gametime, actions, sound, resources, gui,")

Modified: branches/pingus_0_6/src/worldobjs/solid_color_background.cxx
===================================================================
--- branches/pingus_0_6/src/worldobjs/solid_color_background.cxx        
2004-05-07 15:57:21 UTC (rev 2314)
+++ branches/pingus_0_6/src/worldobjs/solid_color_background.cxx        
2004-05-07 17:52:34 UTC (rev 2315)
@@ -18,6 +18,7 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <ClanLib/Display/Display/display.h>
+#include "../gui/graphic_context.hxx"
 #include "../worldobjsdata/solid_color_background_data.hxx"
 #include "solid_color_background.hxx"
 
@@ -36,9 +37,7 @@
 void
 SolidColorBackground::draw (GraphicContext& gc)
 {
-  // FIXME: should use GraphicContext, not CL_Display
-  CL_Display::clear_display (data->color.red, data->color.green, 
data->color.blue, data->color.alpha);
-  UNUSED_ARG(gc);
+  gc.clear(data->color);
 }
 
 } // namespace WorldObjs





reply via email to

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