pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3147 - in trunk/pingus: . src src/editor src/gui src/parti


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3147 - in trunk/pingus: . src src/editor src/gui src/particles src/worldobjs
Date: Fri, 14 Sep 2007 21:13:19 +0200

Author: grumbel
Date: 2007-09-14 21:13:17 +0200 (Fri, 14 Sep 2007)
New Revision: 3147

Added:
   trunk/pingus/src/surface.cpp
   trunk/pingus/src/surface.hpp
Removed:
   trunk/pingus/src/gui/buffer_graphic_context.cpp
   trunk/pingus/src/gui/buffer_graphic_context.hpp
   trunk/pingus/src/pixel_buffer.cpp
   trunk/pingus/src/pixel_buffer.hpp
Modified:
   trunk/pingus/TODO
   trunk/pingus/src/SConscript
   trunk/pingus/src/blitter.cpp
   trunk/pingus/src/blitter.hpp
   trunk/pingus/src/blitter_impl.hpp
   trunk/pingus/src/blitter_test.cpp
   trunk/pingus/src/col_map.cpp
   trunk/pingus/src/collision_mask.cpp
   trunk/pingus/src/collision_mask.hpp
   trunk/pingus/src/editor/editor_level.cpp
   trunk/pingus/src/editor/level_objs.cpp
   trunk/pingus/src/ground_map.cpp
   trunk/pingus/src/ground_map.hpp
   trunk/pingus/src/particles/snow_particle_holder.cpp
   trunk/pingus/src/pingu_action.hpp
   trunk/pingus/src/pingus_menu_manager.cpp
   trunk/pingus/src/resource.cpp
   trunk/pingus/src/resource.hpp
   trunk/pingus/src/smallmap_image.hpp
   trunk/pingus/src/sprite.cpp
   trunk/pingus/src/sprite.hpp
   trunk/pingus/src/world.cpp
   trunk/pingus/src/worldobjs/solid_color_background.hpp
Log:
- removed BufferGraphicContext (wasn't used)
- renamed PixelBuffer to Surface

Modified: trunk/pingus/TODO
===================================================================
--- trunk/pingus/TODO   2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/TODO   2007-09-14 19:13:17 UTC (rev 3147)
@@ -119,6 +119,7 @@
 
 - exit align looks ok, object flipping/rotation is broken (due to
   change in loading (pb->sprite) I guess)
+  -> Resource::load_sprite() doesn't apply modifier
 
 - make combo box open to the top or bottom depending on variable
 

Modified: trunk/pingus/src/SConscript
===================================================================
--- trunk/pingus/src/SConscript 2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/SConscript 2007-09-14 19:13:17 UTC (rev 3147)
@@ -113,7 +113,7 @@
 'command_line.cpp',
 'command_line_generic.cpp',
 
-'pixel_buffer.cpp',
+'surface.cpp',
 'collision_mask.cpp',
 
 'exit_menu.cpp', 

Modified: trunk/pingus/src/blitter.cpp
===================================================================
--- trunk/pingus/src/blitter.cpp        2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/blitter.cpp        2007-09-14 19:13:17 UTC (rev 3147)
@@ -156,60 +156,60 @@
   return new_surface;
 }
 
-PixelBuffer
-Blitter::scale_surface_to_canvas(PixelBuffer provider, int width, int height)
+Surface
+Blitter::scale_surface_to_canvas(Surface provider, int width, int height)
 {
-    return PixelBuffer(Blitter::scale_surface(provider.get_surface(), width, 
height));
+    return Surface(Blitter::scale_surface(provider.get_surface(), width, 
height));
 }
 
 /** Flip a surface horizontal */
-PixelBuffer
-Blitter::flip_horizontal (PixelBuffer prov)
+Surface
+Blitter::flip_horizontal (Surface prov)
 {
   return BlitterImpl::modify(prov, BlitterImpl::transform_flip());
 }
 
 /** Flip a surface vertical */
-PixelBuffer
-Blitter::flip_vertical (PixelBuffer sur)
+Surface
+Blitter::flip_vertical (Surface sur)
 {
   return BlitterImpl::modify(sur, BlitterImpl::transform_rot180_flip());
 }
 
 /** Rotate a surface 90 degrees */
-PixelBuffer
-Blitter::rotate_90 (PixelBuffer sur)
+Surface
+Blitter::rotate_90 (Surface sur)
 {
   return BlitterImpl::modify(sur, BlitterImpl::transform_rot90());
 }
 
 
-PixelBuffer
-Blitter::rotate_180 (PixelBuffer sur)
+Surface
+Blitter::rotate_180 (Surface sur)
 {
   return BlitterImpl::modify(sur, BlitterImpl::transform_rot180());
 }
 
-PixelBuffer
-Blitter::rotate_270 (PixelBuffer sur)
+Surface
+Blitter::rotate_270 (Surface sur)
 {
   return BlitterImpl::modify(sur, BlitterImpl::transform_rot270());
 }
 
-PixelBuffer
-Blitter::rotate_90_flip (PixelBuffer sur)
+Surface
+Blitter::rotate_90_flip (Surface sur)
 {
   return BlitterImpl::modify(sur, BlitterImpl::transform_rot90_flip());
 }
 
-PixelBuffer
-Blitter::rotate_180_flip (PixelBuffer sur)
+Surface
+Blitter::rotate_180_flip (Surface sur)
 {
   return BlitterImpl::modify(sur, BlitterImpl::transform_rot180_flip());
 }
 
-PixelBuffer
-Blitter::rotate_270_flip (PixelBuffer sur)
+Surface
+Blitter::rotate_270_flip (Surface sur)
 {
   return BlitterImpl::modify(sur, BlitterImpl::transform_rot270_flip());
 }

Modified: trunk/pingus/src/blitter.hpp
===================================================================
--- trunk/pingus/src/blitter.hpp        2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/blitter.hpp        2007-09-14 19:13:17 UTC (rev 3147)
@@ -25,10 +25,10 @@
 #include "math/color.hpp"
 #include "math/rect.hpp"
 
-class PixelBuffer;
+class Surface;
 
 /** A bunch of blitting and creation functions to operate on
-    PixelBuffer.  Some of them a similar to the ones in ClanLib, but
+    Surface.  Some of them a similar to the ones in ClanLib, but
     this are slower and work. */
 class Blitter
 {
@@ -37,27 +37,27 @@
   static SDL_Surface* create_surface_rgb(int w, int h);
 
   /** Flip a surface horizontal */
-  static PixelBuffer flip_horizontal (PixelBuffer sur);
+  static Surface flip_horizontal (Surface sur);
 
   /** Flip a surface vertical */
-  static PixelBuffer flip_vertical (PixelBuffer sur);
+  static Surface flip_vertical (Surface sur);
 
   /** Rotate a surface 90 degrees */
-  static PixelBuffer rotate_90 (PixelBuffer sur);
+  static Surface rotate_90 (Surface sur);
 
-  static PixelBuffer rotate_180 (PixelBuffer sur);
+  static Surface rotate_180 (Surface sur);
 
-  static PixelBuffer rotate_270 (PixelBuffer sur);
+  static Surface rotate_270 (Surface sur);
 
-  static PixelBuffer rotate_90_flip (PixelBuffer sur);
+  static Surface rotate_90_flip (Surface sur);
 
-  static PixelBuffer rotate_180_flip (PixelBuffer sur);
+  static Surface rotate_180_flip (Surface sur);
 
-  static PixelBuffer rotate_270_flip (PixelBuffer sur);
+  static Surface rotate_270_flip (Surface sur);
 
   /** Creates a new surface with the given width and height and
       stretches the source surface onto it, the caller is responsible
-      to delete the returned PixelBuffer.
+      to delete the returned Surface.
 
       @param surface The source surface
       @param width The new width of the surface.
@@ -65,7 +65,7 @@
       @return A newly created surface, the caller is responsible to delete it. 
*/
   static SDL_Surface* scale_surface(SDL_Surface* surface, int width, int 
height);
 
-  static PixelBuffer scale_surface_to_canvas(PixelBuffer provider, int width, 
int height);
+  static Surface scale_surface_to_canvas(Surface provider, int width, int 
height);
 
 private:
   Blitter (const Blitter&);

Modified: trunk/pingus/src/blitter_impl.hpp
===================================================================
--- trunk/pingus/src/blitter_impl.hpp   2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/blitter_impl.hpp   2007-09-14 19:13:17 UTC (rev 3147)
@@ -21,7 +21,7 @@
 #define HEADER_PINGUS_BLITTER_IMPL_HXX
 
 #include <iostream>
-#include "pixel_buffer.hpp"
+#include "surface.hpp"
 #include "pingus.hpp"
 
 /** A collection of helper functions for the blitter class */
@@ -177,17 +177,17 @@
 
 template<class TransF>
 inline
-PixelBuffer modify(PixelBuffer source_buffer, const TransF&)
+Surface modify(Surface source_buffer, const TransF&)
 {
   SDL_Surface* source = source_buffer.get_surface();
   SDL_LockSurface(source);
 
   if (source->format->palette)
     {
-      PixelBuffer target_buffer(TransF::get_width (source_buffer.get_width(), 
source_buffer.get_height()), 
-                                TransF::get_height(source_buffer.get_width(), 
source_buffer.get_height()),
-                                source->format->palette, 
-                                (source->flags & SDL_SRCCOLORKEY) ? 
source->format->colorkey : -1);
+      Surface target_buffer(TransF::get_width (source_buffer.get_width(), 
source_buffer.get_height()), 
+                            TransF::get_height(source_buffer.get_width(), 
source_buffer.get_height()),
+                            source->format->palette, 
+                            (source->flags & SDL_SRCCOLORKEY) ? 
source->format->colorkey : -1);
       SDL_Surface* target = target_buffer.get_surface();
       SDL_LockSurface(target);
 

Modified: trunk/pingus/src/blitter_test.cpp
===================================================================
--- trunk/pingus/src/blitter_test.cpp   2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/blitter_test.cpp   2007-09-14 19:13:17 UTC (rev 3147)
@@ -34,8 +34,8 @@
     //CL_Surface surf = Resource::load_surface("textures/stone", "textures");
     CL_Surface surf = Resource::load_surface("textures/greentex");
 
-    PixelBuffer buf(256, 256, 256*4, CL_PixelFormat::rgba8888);
-    PixelBuffer data = surf.get_pixeldata();
+    Surface buf(256, 256, 256*4, CL_PixelFormat::rgba8888);
+    Surface data = surf.get_pixeldata();
     Timer bench("Blit");
     Blitter::put_surface(buf, data, 0, 0);
     Blitter::fill_rect(buf, CL_Rect(-50, -50, 250, 250), Color(255, 150, 50, 
128));

Modified: trunk/pingus/src/col_map.cpp
===================================================================
--- trunk/pingus/src/col_map.cpp        2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/col_map.cpp        2007-09-14 19:13:17 UTC (rev 3147)
@@ -23,7 +23,6 @@
 #include "globals.hpp"
 #include "col_map.hpp"
 #include "collision_mask.hpp"
-#include "pixel_buffer.hpp"
 #include "pingus_error.hpp"
 #include "math.hpp"
 #include "gettext.h"
@@ -172,7 +171,7 @@
 void
 ColMap::draw(DrawingContext& gc)
 {
-  PixelBuffer canvas(width, height);
+  Surface canvas(width, height);
   unsigned char* buffer;
 
   canvas.lock();

Modified: trunk/pingus/src/collision_mask.cpp
===================================================================
--- trunk/pingus/src/collision_mask.cpp 2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/collision_mask.cpp 2007-09-14 19:13:17 UTC (rev 3147)
@@ -43,27 +43,27 @@
 CollisionMask::init(const ResDescriptor& res_desc)
 {
   //std::cout << "CollisionMask: " << name << std::endl;
-  pixelbuffer = Resource::load_pixelbuffer(res_desc);
-  //PixelBuffer cmap = pixelbuffer; // 
Resource::load_pixelbuffer(System::cut_ext(name) + "_cmap");
+  surface = Resource::load_surface(res_desc);
+  //Surface cmap = surface; // Resource::load_surface(System::cut_ext(name) + 
"_cmap");
 
-  int pitch = pixelbuffer.get_pitch();
-  width  = pixelbuffer.get_width();
-  height = pixelbuffer.get_height();
+  int pitch = surface.get_pitch();
+  width  = surface.get_width();
+  height = surface.get_height();
   
   buffer = new uint8_t[width * height];
 
-  SDL_Surface* surface = pixelbuffer.get_surface();
-  SDL_LockSurface(surface);
+  SDL_Surface* sdl_surface = surface.get_surface();
+  SDL_LockSurface(sdl_surface);
 
-  if (surface->format->palette)
+  if (sdl_surface->format->palette)
     {
-      uint8_t* source = static_cast<uint8_t*>(surface->pixels);
-      if (surface->flags & SDL_SRCCOLORKEY)
+      uint8_t* source = static_cast<uint8_t*>(sdl_surface->pixels);
+      if (sdl_surface->flags & SDL_SRCCOLORKEY)
         { // surface with transparent areas
           for(int y = 0; y < height; ++y)
             for(int x = 0; x < width; ++x)
               {
-                if (source[y*pitch + x] == surface->format->colorkey)
+                if (source[y*pitch + x] == sdl_surface->format->colorkey)
                   buffer[y*width + x] = 0;
                 else
                   buffer[y*width + x] = 1;
@@ -85,15 +85,15 @@
              "  bmask: 0x%08x\n"
              "  amask: 0x%08x\n",
              res_desc.res_name.c_str(),
-             int(surface->format->BitsPerPixel),
-             int(surface->format->BytesPerPixel),
-             (unsigned int)surface->format->Rmask,
-             (unsigned int)surface->format->Gmask,
-             (unsigned int)surface->format->Bmask,
-             (unsigned int)surface->format->Amask);
+             int(sdl_surface->format->BitsPerPixel),
+             int(sdl_surface->format->BytesPerPixel),
+             (unsigned int)sdl_surface->format->Rmask,
+             (unsigned int)sdl_surface->format->Gmask,
+             (unsigned int)sdl_surface->format->Bmask,
+             (unsigned int)sdl_surface->format->Amask);
     }
 
-  SDL_UnlockSurface(surface);
+  SDL_UnlockSurface(sdl_surface);
 }
 
 CollisionMask::~CollisionMask()
@@ -113,10 +113,10 @@
   return height;
 }
 
-PixelBuffer
-CollisionMask::get_pixelbuffer() const
+Surface
+CollisionMask::get_surface() const
 {
-  return pixelbuffer;
+  return surface;
 }
 
 uint8_t*

Modified: trunk/pingus/src/collision_mask.hpp
===================================================================
--- trunk/pingus/src/collision_mask.hpp 2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/collision_mask.hpp 2007-09-14 19:13:17 UTC (rev 3147)
@@ -21,14 +21,14 @@
 #define HEADER_COLLISION_MASK_HPP
 
 #include <string>
-#include "pixel_buffer.hpp"
+#include "surface.hpp"
 #include "res_descriptor.hpp"
 
 /** */
 class CollisionMask
 {
 public:
-  PixelBuffer pixelbuffer;
+  Surface    surface;
   uint8_t*    buffer;
   int         width;
   int         height;
@@ -42,7 +42,7 @@
   int get_width() const;
   int get_height() const;
   
-  PixelBuffer get_pixelbuffer() const;
+  Surface get_surface() const;
   uint8_t* get_data() const;
 
 private:

Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp    2007-09-14 18:21:07 UTC (rev 
3146)
+++ trunk/pingus/src/editor/editor_level.cpp    2007-09-14 19:13:17 UTC (rev 
3147)
@@ -41,7 +41,7 @@
   impl->music   = "none";
 
   impl->ambient_light = Color(255,255,255);
-  impl->size = Size(1000, 1000);
+  impl->size = Size(2000, 1000);
 
   impl->number_of_pingus = 50;
   impl->number_to_save   = 20;

Modified: trunk/pingus/src/editor/level_objs.cpp
===================================================================
--- trunk/pingus/src/editor/level_objs.cpp      2007-09-14 18:21:07 UTC (rev 
3146)
+++ trunk/pingus/src/editor/level_objs.cpp      2007-09-14 19:13:17 UTC (rev 
3147)
@@ -160,7 +160,7 @@
     {
       sprite = Resource::load_sprite(desc);
 #if 0                          
-      PixelBuffer pb;
+      Surface pb;
 
       // Apply modifier, then change the sprite loaded for this object in 
memory.
       if (stretch_x || stretch_y)
@@ -194,7 +194,7 @@
                         
         }
       else             // No stretch involved
-        pb = Resource::load_pixelbuffer(desc);
+        pb = Resource::load_surface(desc);
 
       sprite = Sprite(pb);
 #endif

Modified: trunk/pingus/src/ground_map.cpp
===================================================================
--- trunk/pingus/src/ground_map.cpp     2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/ground_map.cpp     2007-09-14 19:13:17 UTC (rev 3147)
@@ -40,30 +40,30 @@
 void
 MapTile::prepare()
 {
-  if (!pixelbuffer)
+  if (!surface)
     {
-      pixelbuffer = PixelBuffer(tile_size, tile_size);
-      //Blitter::clear_canvas(pixelbuffer);
+      surface = Surface(tile_size, tile_size);
+      //Blitter::clear_canvas(surface);
     }
 }
 
 void
-MapTile::remove(PixelBuffer obj, int x, int y, 
+MapTile::remove(Surface obj, int x, int y, 
                 int real_x, int real_y, GroundMap* parent)
 {
   if (sprite)
     {
-      parent->put_alpha_surface(pixelbuffer, obj, x, y, real_x, real_y);
-      sprite = Sprite(pixelbuffer);
+      parent->put_alpha_surface(surface, obj, x, y, real_x, real_y);
+      sprite = Sprite(surface);
     }
 }
 
 void
-MapTile::put(PixelBuffer obj, int x, int y)
+MapTile::put(Surface obj, int x, int y)
 {
   prepare();
-  pixelbuffer.blit(obj, x, y);
-  sprite = Sprite(pixelbuffer);
+  surface.blit(obj, x, y);
+  sprite = Sprite(surface);
 }
 
 GroundMap::GroundMap(const PingusLevel& plf)
@@ -163,7 +163,7 @@
 }
 
 void
-GroundMap::remove(PixelBuffer sprovider, int x, int y)
+GroundMap::remove(Surface sprovider, int x, int y)
 {
   // Get the start tile and end tile
   int start_x = Math::max(x / tile_size, 0);
@@ -182,7 +182,7 @@
 }
 
 void
-GroundMap::put_alpha_surface(PixelBuffer provider, PixelBuffer sprovider,
+GroundMap::put_alpha_surface(Surface provider, Surface sprovider,
                              int x_pos, int y_pos, int real_x_arg, int 
real_y_arg)
 {
   if (sprovider.get_surface()->format->BitsPerPixel != 8)
@@ -266,7 +266,7 @@
 }
 
 void
-GroundMap::put(PixelBuffer source, int x, int y)
+GroundMap::put(Surface source, int x, int y)
 {
   // Get the start tile and end tile
   int start_x = std::max(0, x / tile_size);

Modified: trunk/pingus/src/ground_map.hpp
===================================================================
--- trunk/pingus/src/ground_map.hpp     2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/ground_map.hpp     2007-09-14 19:13:17 UTC (rev 3147)
@@ -25,7 +25,7 @@
 #include "globals.hpp"
 #include "worldobj.hpp"
 #include "ground_map.hpp"
-#include "pixel_buffer.hpp"
+#include "surface.hpp"
 
 class SceneContext;
 class PingusLevel;
@@ -36,15 +36,15 @@
 {
 private:
   Sprite       sprite;
-  PixelBuffer  pixelbuffer;
+  Surface  surface;
 
   void prepare();
 public:
   MapTile();
   ~MapTile();
 
-  void remove(PixelBuffer, int x, int y, int real_x, int real_y, GroundMap*);  
-  void put(PixelBuffer, int x, int y);  
+  void remove(Surface, int x, int y, int real_x, int real_y, GroundMap*);  
+  void put(Surface, int x, int y);  
 
   Sprite get_sprite() const { return sprite; }
 };
@@ -81,18 +81,18 @@
   int  get_width();
 
   /** Put the gives surface provider onto the given coordinates */
-  void put(PixelBuffer, int x, int y);
+  void put(Surface, int x, int y);
 
   /** Remove the gives surface provider onto the given coordinates
       (everything non-transparent that isn't Groundtype::GP_Solid 
                        is removed from the map) */
-  void remove(PixelBuffer, int x, int y);
+  void remove(Surface, int x, int y);
 
   float get_z_pos () const { return 0; }
 
        /** Low level version of the remove() call, acts on a single tile
       instead of the complete map-tiles */
-  void put_alpha_surface(PixelBuffer provider, PixelBuffer sprovider,
+  void put_alpha_surface(Surface provider, Surface sprovider,
                         int x, int y, int real_x, int real_y);
 
 private:

Deleted: trunk/pingus/src/gui/buffer_graphic_context.cpp
===================================================================
--- trunk/pingus/src/gui/buffer_graphic_context.cpp     2007-09-14 18:21:07 UTC 
(rev 3146)
+++ trunk/pingus/src/gui/buffer_graphic_context.cpp     2007-09-14 19:13:17 UTC 
(rev 3147)
@@ -1,107 +0,0 @@
-//  $Id$
-//
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#include <iostream>
-#include "../pingus_error.hpp"
-#include "../blitter.hpp"
-#include "../screenshot.hpp"
-#include "buffer_graphic_context.hpp"
-
-
-BufferGraphicContext::BufferGraphicContext(int width, int height)
-  : canvas(width, height, width*4, CL_PixelFormat::rgba8888)
-{
-}
-
-BufferGraphicContext::~BufferGraphicContext()
-{
-}
-
-CL_Rect
-BufferGraphicContext::get_clip_rect()
-{
-  return CL_Rect(0,0, get_width(), get_height());
-}
-
-void
-BufferGraphicContext::clear (float r, float g, float b)
-{
-  UNUSED_ARG(r);
-  UNUSED_ARG(g);
-  UNUSED_ARG(b);
-  std::cout << "BufferGraphicContext: clear" << std::endl;
-}
-
-void 
-BufferGraphicContext::draw(CL_Sprite, const Vector3f&)
-{
-}
-
-void
-BufferGraphicContext::draw(CL_Sprite, const Vector3f&, int)
-{
-}
-
-void
-BufferGraphicContext::draw (CL_Surface sur, int x_pos, int y_pos)
-{
-  //std::cout << "BufferGraphicContext: " << x_pos << ", " << y_pos  << 
std::endl;
-  try {
-    Blitter::put_surface(canvas, sur.get_pixeldata(), x_pos, y_pos);
-  } catch (PingusError& err) {
-    std::cout << "BufferGraphicContext: " << err.get_message() << std::endl;
-  }
-}
-
-void
-BufferGraphicContext::draw (CL_Surface sur, int x_pos, int y_pos, int frame)
-{
-  //std::cout << "BufferGraphicContext: " << x_pos << ", " << y_pos  << " 
frame: " << frame << std::endl;
-  try {
-    Blitter::put_surface(canvas, sur.get_pixeldata(), x_pos, y_pos);
-  } catch (PingusError& err) {
-    std::cout << "BufferGraphicContext: " << err.get_message() << std::endl;
-  }
-  UNUSED_ARG(frame);
-}
-
-void
-BufferGraphicContext::draw (CL_Surface sur, int x_pos, int y_pos,
-                            float size_x, float size_y, int frame)
-{
-  std::cout << "BufferGraphicContext: unsupported" << std::endl;
-  UNUSED_ARG(sur);
-  UNUSED_ARG(x_pos);
-  UNUSED_ARG(y_pos);
-  UNUSED_ARG(size_x);
-  UNUSED_ARG(size_y);
-  UNUSED_ARG(frame);
-}
-
-void
-BufferGraphicContext::write(const std::string& filename)
-{
-  std::cout << "BufferGraphicContext::write: " << filename << std::endl;
-  canvas.lock();
-  Screenshot::save_target_to_file(canvas, filename);
-  canvas.unlock();
-}
-
-
-/* EOF */

Deleted: trunk/pingus/src/gui/buffer_graphic_context.hpp
===================================================================
--- trunk/pingus/src/gui/buffer_graphic_context.hpp     2007-09-14 18:21:07 UTC 
(rev 3146)
+++ trunk/pingus/src/gui/buffer_graphic_context.hpp     2007-09-14 19:13:17 UTC 
(rev 3147)
@@ -1,97 +0,0 @@
-//  $Id$
-//
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#ifndef HEADER_PINGUS_BUFFER_GRAPHIC_CONTEXT_HXX
-#define HEADER_PINGUS_BUFFER_GRAPHIC_CONTEXT_HXX
-
-#include <string>
-#include "../vector.hpp"
-#include "graphic_context.hpp"
-
-class CL_Surface;
-class CL_Font;
-
-
-typedef CL_Font FontHandle;
-
-/** Abstract interface */
-class BufferGraphicContext : public GraphicContext
-{
-private:
-  CL_PixelBuffer canvas; 
-
-public:
-  BufferGraphicContext(int width, int height);
-  virtual ~BufferGraphicContext();
-  
-  Vector get_offset () { return Vector(); }
-  void   set_offset (float, float) {}
-  
-  CL_Rect get_clip_rect ();
-
-  float get_x_offset () { return 0; }
-  float get_y_offset () { return 0; }
-
-  int   get_width ()  { return canvas.get_width(); }
-  int   get_height () { return canvas.get_height(); }
-
-  float get_zoom () { return 1.0f; }
-  void  set_zoom (float new_zoom) { UNUSED_ARG(new_zoom); }
-
-  void zoom_to (const CL_Rect & rect) { UNUSED_ARG(rect); }
-  void move (const Vector & delta) { UNUSED_ARG(delta); }
-
-  Vector screen_to_world (Vector pos) { return pos; }
-  Vector world_to_screen (Vector pos) { return pos; }
-
-  void clear (float r, float g, float b);
-
-  void draw(CL_Sprite, const Vector3f&);
-  void draw(CL_Sprite, const Vector3f&, int);
-
-  void draw (CL_Surface sur, int x_pos, int y_pos);
-  void draw (CL_Surface sur, int x_pos, int y_pos, int frame);
-  void draw (CL_Surface sur, int x_pos, int y_pos,
-             float size_x, float size_y, int frame);
-
-  void draw_line (const Vector& /*pos1*/, const Vector& /*pos2*/,
-                  float /*r*/, float /*g*/, float /*b*/, float a = 1.0f) { 
UNUSED_ARG(a); }
-  void draw_line (int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/,
-                  float /*r*/, float /*g*/, float /*b*/, float a = 1.0f) { 
UNUSED_ARG(a); }
-  void draw_fillrect (int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/,
-                      float /*r*/, float /*g*/, float /*b*/, float a = 1.0f) { 
UNUSED_ARG(a); }
-  void draw_rect (int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/,
-                  float /*r*/, float /*g*/, float /*b*/, float a = 1.0f) { 
UNUSED_ARG(a); }
-  void draw_pixel (int /*x_pos*/, int /*y_pos*/,
-                   float /*r*/, float /*g*/, float /*b*/, float a = 1.0f) { 
UNUSED_ARG(a); }
-  void draw_circle (int /*x_pos*/, int /*y_pos*/, int /*radius*/,
-                    float /*r*/, float /*g*/, float /*b*/, float a = 1.0f) { 
UNUSED_ARG(a); }
-
-  void print_left (FontHandle /*font*/, int /*x_pos*/, int /*y_pos*/, const 
std::string& /*str*/) {}
-  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*/) {}
-
-  /** Write the current content of the buffer down to a pnm file */
-  void write(const std::string& filename);
-};
-
-
-#endif
-
-/* EOF */

Modified: trunk/pingus/src/particles/snow_particle_holder.cpp
===================================================================
--- trunk/pingus/src/particles/snow_particle_holder.cpp 2007-09-14 18:21:07 UTC 
(rev 3146)
+++ trunk/pingus/src/particles/snow_particle_holder.cpp 2007-09-14 19:13:17 UTC 
(rev 3147)
@@ -108,7 +108,7 @@
             && pixel != Groundtype::GP_WATER
            && pixel != Groundtype::GP_OUTOFSCREEN)
            {
-             world->get_gfx_map()->put(ground.get_pixelbuffer(), 
static_cast<int>(it->pos.x - 1), static_cast<int>(it->pos.y - 1));
+             world->get_gfx_map()->put(ground.get_surface(), 
static_cast<int>(it->pos.x - 1), static_cast<int>(it->pos.y - 1));
              it->alive = false;
            }
        }

Modified: trunk/pingus/src/pingu_action.hpp
===================================================================
--- trunk/pingus/src/pingu_action.hpp   2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/pingu_action.hpp   2007-09-14 19:13:17 UTC (rev 3147)
@@ -21,7 +21,7 @@
 #define HEADER_PINGUS_PINGU_ACTION_HXX
 
 #include "pingu_enums.hpp"
-#include "pixel_buffer.hpp"
+#include "surface.hpp"
 #include "collision_mask.hpp"
 
 class ActionHolder;

Modified: trunk/pingus/src/pingus_menu_manager.cpp
===================================================================
--- trunk/pingus/src/pingus_menu_manager.cpp    2007-09-14 18:21:07 UTC (rev 
3146)
+++ trunk/pingus/src/pingus_menu_manager.cpp    2007-09-14 19:13:17 UTC (rev 
3147)
@@ -38,15 +38,15 @@
        if (w != 800 && h != 600)
        {
                background.add_layer (Blitter::scale_surface_to_canvas(
-                       Resource::load_pixelbuffer("core/menu/layer1"), w, 185 
* h / 600), 0, 0, 12, 0);
+                       Resource::load_surface("core/menu/layer1"), w, 185 * h 
/ 600), 0, 0, 12, 0);
                background.add_layer (Blitter::scale_surface_to_canvas(
-                       Resource::load_pixelbuffer("core/menu/layer2"), w, 362 
* h / 600), 0, 150 * (float)h / 600, 25, 0);
+                       Resource::load_surface("core/menu/layer2"), w, 362 * h 
/ 600), 0, 150 * (float)h / 600, 25, 0);
                background.add_layer (Blitter::scale_surface_to_canvas(
-                       Resource::load_pixelbuffer("core/menu/layer3"), w, 306 
* h / 600), 0, 200 * (float)h / 600, 50, 0);
+                       Resource::load_surface("core/menu/layer3"), w, 306 * h 
/ 600), 0, 200 * (float)h / 600, 50, 0);
                background.add_layer (Blitter::scale_surface_to_canvas(
-                       Resource::load_pixelbuffer("core/menu/layer4"), w, 171 
* h / 600), 0, 429 * (float)h / 600, 100, 0);
+                       Resource::load_surface("core/menu/layer4"), w, 171 * h 
/ 600), 0, 429 * (float)h / 600, 100, 0);
                background.add_layer (Blitter::scale_surface_to_canvas(
-                       Resource::load_pixelbuffer("core/menu/layer5"), 302 * w 
/ 800, 104 * h / 600), 0, 500 * (float)h / 600, 200, 0);
+                       Resource::load_surface("core/menu/layer5"), 302 * w / 
800, 104 * h / 600), 0, 500 * (float)h / 600, 200, 0);
        }
        else
        {

Deleted: trunk/pingus/src/pixel_buffer.cpp
===================================================================
--- trunk/pingus/src/pixel_buffer.cpp   2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/pixel_buffer.cpp   2007-09-14 19:13:17 UTC (rev 3147)
@@ -1,194 +0,0 @@
-//  $Id$
-//
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#include "SDL_image.h"
-#include <sstream>
-#include <iostream>
-#include "pixel_buffer.hpp"
-
-class PixelBufferImpl
-{
-public:
-  PixelBufferImpl(SDL_Surface* surface = NULL) : surface(surface) {}
-  ~PixelBufferImpl() {
-    SDL_FreeSurface(surface);
-  }
-  SDL_Surface* surface;
-};
-
-PixelBuffer::PixelBuffer()
-{
-}
-
-PixelBuffer::PixelBuffer(const Pathname& pathname)
-  : impl(new PixelBufferImpl())
-{
-  impl->surface = IMG_Load(pathname.get_sys_path().c_str());
-  if (!impl->surface)
-    std::cout << "XXXXXX Failed to load: " << pathname.str() << std::endl;
-  ///else
-  //std::cout << "Loaded pixelbuffer: " << name << ": " << surface->w << "x" 
<< surface->h << std::endl;
-
-}
-
-PixelBuffer::PixelBuffer(int width, int height, SDL_Palette* palette, int 
colorkey)
-  : impl(new PixelBufferImpl())
-{
-  if (colorkey == -1)
-    {
-      impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 8,
-                                           0, 0, 0 ,0);
-    }
-  else
-    {
-      impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCCOLORKEY, 
width, height, 8,
-                                           0, 0, 0 ,0);
-      SDL_SetColorKey(impl->surface, SDL_SRCCOLORKEY, colorkey);
-    }
-
-  SDL_SetColors(impl->surface, palette->colors, 0, palette->ncolors);
-}
-
-PixelBuffer::PixelBuffer(int width, int height)
-  : impl(new PixelBufferImpl())
-{
-  impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
-                                       0x000000ff,
-                                       0x0000ff00,
-                                       0x00ff0000,
-                                       0xff000000);
-  //SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, 0, 0, 0, 0));
-}
-
-PixelBuffer::PixelBuffer(SDL_Surface* surface)
-  : impl(new PixelBufferImpl(surface))
-{
-}
-
-PixelBuffer::~PixelBuffer()
-{
-}
-
-void
-PixelBuffer::blit(const PixelBuffer& src, int x, int y)
-{
-  if (!get_surface())
-    {
-      std::cout << "PixelBuffer: Trying to blit to empty surface" << std::endl;
-    }
-  else if (!src.get_surface())
-    {
-      std::cout << "PixelBuffer: Trying to blit with an empty surface" << 
std::endl;
-    }
-  else
-    {
-      SDL_Rect dstrect;
-
-      dstrect.x = x;
-      dstrect.y = y;
-
-      SDL_BlitSurface(src.get_surface(), NULL, get_surface(), &dstrect);
-    }
-}
-
-void
-PixelBuffer::lock()
-{
-  SDL_LockSurface(get_surface());
-}
-
-void
-PixelBuffer::unlock()
-{
-  SDL_UnlockSurface(get_surface());
-}
-
-uint8_t*
-PixelBuffer::get_data() const
-{
-  return static_cast<uint8_t*>(get_surface()->pixels);
-}
-
-int
-PixelBuffer::get_width()  const
-{
-  if (get_surface())
-    return get_surface()->w;
-  else
-    return 0;
-}
-
-int
-PixelBuffer::get_height() const
-{
-  if (get_surface())
-    return get_surface()->h;
-  else
-    return 0;
-}
-
-int
-PixelBuffer::get_pitch() const
-{
-  if (get_surface())
-    return get_surface()->pitch;
-  else
-    return 0;
-}
-
-SDL_Surface* 
-PixelBuffer::get_surface() const
-{
-  return impl ? impl->surface : 0;
-}
-
-PixelBuffer::operator bool() const
-{
-  return impl ? impl->surface != NULL : false;
-}
-
-Color
-PixelBuffer::get_pixel(int x, int y) const
-{
-  Uint8 *p = (Uint8 *)get_surface()->pixels + y * get_surface()->pitch + x * 
get_surface()->format->BytesPerPixel;
-  Uint32 pixel;
-
-  switch(get_surface()->format->BytesPerPixel)
-    {
-    case 1:
-      pixel = *p;
-    case 2: /* This will cause some problems ... */
-      pixel = *(Uint16 *)p;
-    case 3:
-      if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
-       pixel = p[0] << 16 | p[1] << 8 | p[2];
-      else
-       pixel = p[0] | p[1] << 8 | p[2] << 16;
-    case 4:
-      pixel = *(Uint32 *)p;
-    default:
-      pixel = 0;       /* shouldn't happen, but avoids warnings */
-    } 
-
-  Color color;
-  SDL_GetRGBA(pixel, get_surface()->format, &color.r, &color.g, &color.b, 
&color.a);
-  return color;
-}
-
-/* EOF */

Deleted: trunk/pingus/src/pixel_buffer.hpp
===================================================================
--- trunk/pingus/src/pixel_buffer.hpp   2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/pixel_buffer.hpp   2007-09-14 19:13:17 UTC (rev 3147)
@@ -1,69 +0,0 @@
-//  $Id$
-//
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#ifndef HEADER_PIXEL_BUFFER_HPP
-#define HEADER_PIXEL_BUFFER_HPP
-
-#include "SDL.h"
-#include <string>
-#include <boost/shared_ptr.hpp>
-#include "pathname.hpp"
-#include "math/color.hpp"
-
-class Pathname;
-class PixelBufferImpl;
-
-/** */
-class PixelBuffer
-{
-public:
-  PixelBuffer();
-  PixelBuffer(const Pathname& name);
-  /** Create an empty RGBA PixelBuffer */
-  PixelBuffer(int width, int height);
-
-  /** Create an empty Indexed PixelBuffer (8bit) */
-  PixelBuffer(int width, int height, SDL_Palette* palette, int colorkey = -1);
-  /** Create a PixelBuffer from a SDL_Surface */
-  PixelBuffer(SDL_Surface* surface);
-  ~PixelBuffer();
-
-  uint8_t* get_data() const;
-  void lock();
-  void unlock();
-
-  int get_width()  const;
-  int get_height() const;
-  int get_pitch()  const;
-
-  void blit(const PixelBuffer& source, int x, int y);
-
-  Color get_pixel(int x, int y) const;
-
-  SDL_Surface* get_surface() const;
-
-  operator bool() const;
-
-protected:
-  boost::shared_ptr<PixelBufferImpl> impl;
-};
-
-#endif
-
-/* EOF */

Modified: trunk/pingus/src/resource.cpp
===================================================================
--- trunk/pingus/src/resource.cpp       2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/resource.cpp       2007-09-14 19:13:17 UTC (rev 3147)
@@ -103,11 +103,19 @@
 Sprite
 Resource::load_sprite(const ResDescriptor& desc)
 {
-  return load_sprite(desc.res_name);
+  if (desc.modifier == ResourceModifierNS::ROT0)
+    {
+      return load_sprite(desc.res_name);
+    }
+  else
+    {
+      // FIXME: Add code to apply the modifier
+      return load_sprite(desc.res_name);
+    }
 }
 
-PixelBuffer
-Resource::apply_modifier_to_pixelbuffer(PixelBuffer prov, const ResDescriptor& 
desc)
+Surface
+Resource::apply_modifier_to_surface(Surface prov, const ResDescriptor& desc)
 {
   switch (desc.modifier)
     {
@@ -173,20 +181,20 @@
   return CollisionMask(res_desc);
 }
 
-PixelBuffer
-Resource::load_pixelbuffer(const ResDescriptor& desc_)
+Surface
+Resource::load_surface(const ResDescriptor& desc_)
 {
   SpriteDescription* desc = resmgr.get_sprite_description(desc_.res_name);
   if (desc)
-    return apply_modifier_to_pixelbuffer(PixelBuffer(desc->filename), desc_);
+    return apply_modifier_to_surface(Surface(desc->filename), desc_);
   else
-    return apply_modifier_to_pixelbuffer(PixelBuffer(), desc_);
+    return apply_modifier_to_surface(Surface(), desc_);
 }
 
-PixelBuffer
-Resource::load_pixelbuffer(const std::string& res_name)
+Surface
+Resource::load_surface(const std::string& res_name)
 {
-  return load_pixelbuffer(ResDescriptor(res_name));
+  return load_surface(ResDescriptor(res_name));
 }
 
 #if 0
@@ -247,63 +255,6 @@
 }
 #endif 
 
-#if 0 
-CL_Surface
-Resource::apply_modifier (const CL_Surface& surf, const ResDescriptor& 
res_desc)
-{
-  PixelBuffer prov = surf.get_pixeldata();
-
-  switch (res_desc.modifier)
-    {
-    case ResourceModifierNS::ROT0:
-      return CL_Surface(prov);
-
-    case ResourceModifierNS::ROT90:
-      return CL_Surface(Blitter::rotate_90(prov));
-
-    case ResourceModifierNS::ROT180:
-      return CL_Surface(Blitter::rotate_180(prov));
-                        
-    case ResourceModifierNS::ROT270:
-      return CL_Surface(Blitter::rotate_270(prov));
-
-    case ResourceModifierNS::ROT0FLIP:
-      return CL_Surface(Blitter::flip_horizontal(prov));
-
-    case ResourceModifierNS::ROT90FLIP:
-      return CL_Surface(Blitter::rotate_90_flip(prov));
-
-    case ResourceModifierNS::ROT180FLIP:
-      return CL_Surface(Blitter::rotate_180_flip(prov));
-
-    case ResourceModifierNS::ROT270FLIP:
-      return CL_Surface(Blitter::rotate_270_flip(prov));
-
-    default:
-      perr << "Resource: Unhandled modifier: " << res_desc.modifier << 
std::endl;
-      return CL_Surface(prov);
-    }
-}
-
-CL_Surface
-Resource::load_from_source (const ResDescriptor& res_desc)
-{
-  try {
-    return CL_Surface(res_desc.res_name, &resmgr);
-  } catch (CL_Error err) {
-    pout << "CL_Error: " << err.message << std::endl;
-    pout << "Resource:" << res_desc
-         <<  ":-404-:" << err.message << std::endl;
-    try {
-      return CL_Surface ("core/misc/404", &resmgr);
-    } catch (CL_Error err2) {
-      pout << "Resource: Fatal error, important gfx files (404.pcx) couldn't 
be loaded!" << std::endl;
-      throw err;
-    }
-  }
-}
-#endif 
-
 Font
 Resource::load_font(const std::string& res_name)
 {

Modified: trunk/pingus/src/resource.hpp
===================================================================
--- trunk/pingus/src/resource.hpp       2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/resource.hpp       2007-09-14 19:13:17 UTC (rev 3147)
@@ -23,7 +23,7 @@
 #include <map>
 #include <vector>
 #include "sprite.hpp"
-#include "pixel_buffer.hpp"
+#include "surface.hpp"
 #include "res_descriptor.hpp"
 #include "resource_manager.hpp"
 #include "collision_mask.hpp"
@@ -54,7 +54,7 @@
       Returns all sections if blank */
   static std::vector<std::string> get_sections(const std::string &section = 
std::string());
 #endif
-  static PixelBuffer apply_modifier_to_pixelbuffer(PixelBuffer, const 
ResDescriptor& res_desc);
+  static Surface apply_modifier_to_surface(Surface, const ResDescriptor& 
res_desc);
 
 public:
   static void init();
@@ -69,8 +69,8 @@
   static Sprite        load_sprite(const std::string& res_name);
   static CollisionMask load_collision_mask(const std::string& res_name);
   static CollisionMask load_collision_mask(const ResDescriptor&);
-  static PixelBuffer   load_pixelbuffer(const std::string& res_name);
-  static PixelBuffer   load_pixelbuffer(const ResDescriptor&);
+  static Surface   load_surface(const std::string& res_name);
+  static Surface   load_surface(const ResDescriptor&);
 
   /** Load a font with res_name from datafile */
   static Font load_font(const std::string& res_name);

Modified: trunk/pingus/src/smallmap_image.hpp
===================================================================
--- trunk/pingus/src/smallmap_image.hpp 2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/smallmap_image.hpp 2007-09-14 19:13:17 UTC (rev 3147)
@@ -33,7 +33,7 @@
   Server* server;
 
   /** The canvas that represents the small-colmap */
-  PixelBuffer canvas;
+  Surface canvas;
 
   /** Graphic surface for the generated rectanglar background of the small map 
*/
   Sprite sur;

Modified: trunk/pingus/src/sprite.cpp
===================================================================
--- trunk/pingus/src/sprite.cpp 2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/sprite.cpp 2007-09-14 19:13:17 UTC (rev 3147)
@@ -26,7 +26,7 @@
 #include "SDL_image.h"
 #include "sprite.hpp"
 #include "blitter.hpp"
-#include "pixel_buffer.hpp"
+#include "surface.hpp"
 #include "pathname.hpp"
 #include "sprite_description.hpp"
 
@@ -91,11 +91,11 @@
     optimize();
   }
 
-  SpriteImpl(const PixelBuffer& pixelbuffer)
+  SpriteImpl(const Surface& surface)
     : optimized(false),
       offset(0,0),
       frame_pos(0,0),
-      frame_size(pixelbuffer.get_width(), pixelbuffer.get_height()),
+      frame_size(surface.get_width(), surface.get_height()),
       frame_delay(0),
       array(1,1),
       loop(true),
@@ -104,19 +104,19 @@
       frame(0),
       tick_count(0)
   {
-    if (pixelbuffer.get_surface())
+    if (surface.get_surface())
       {
-        if (pixelbuffer.get_surface()->format->Amask == 0)
-          surface = SDL_DisplayFormat(pixelbuffer.get_surface());
+        if (surface.get_surface()->format->Amask == 0)
+          this->surface = SDL_DisplayFormat(surface.get_surface());
         else
-          surface = SDL_DisplayFormatAlpha(pixelbuffer.get_surface());
+          this->surface = SDL_DisplayFormatAlpha(surface.get_surface());
 
         optimized = true;
       }
     else
       {
-        surface = 0;
-        std::cout << "Sprite: Error trying to create a Sprite out of an empty 
PixelBuffer"  << std::endl;
+        this->surface = 0;
+        std::cout << "Sprite: Error trying to create a Sprite out of an empty 
Surface"  << std::endl;
       }
   }
 
@@ -214,8 +214,8 @@
   impl = boost::shared_ptr<SpriteImpl>(new SpriteImpl(desc));
 }
 
-Sprite::Sprite(const PixelBuffer& pixelbuffer)
-  : impl(new SpriteImpl(pixelbuffer))
+Sprite::Sprite(const Surface& surface)
+  : impl(new SpriteImpl(surface))
 {
   
 }

Modified: trunk/pingus/src/sprite.hpp
===================================================================
--- trunk/pingus/src/sprite.hpp 2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/sprite.hpp 2007-09-14 19:13:17 UTC (rev 3147)
@@ -26,7 +26,7 @@
 #include "SDL.h"
 
 class Color;
-class PixelBuffer;
+class Surface;
 class Pathname;
 class SpriteImpl;
 class SpriteDescription;
@@ -38,7 +38,7 @@
   Sprite();
   Sprite(const Pathname& name);
   Sprite(const SpriteDescription& desc);
-  Sprite(const PixelBuffer& pixelbuffer);
+  Sprite(const Surface& surface);
   ~Sprite();
 
   int get_width()  const;

Copied: trunk/pingus/src/surface.cpp (from rev 3145, 
trunk/pingus/src/pixel_buffer.cpp)
===================================================================
--- trunk/pingus/src/pixel_buffer.cpp   2007-09-14 16:33:50 UTC (rev 3145)
+++ trunk/pingus/src/surface.cpp        2007-09-14 19:13:17 UTC (rev 3147)
@@ -0,0 +1,194 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#include "SDL_image.h"
+#include <sstream>
+#include <iostream>
+#include "surface.hpp"
+
+class SurfaceImpl
+{
+public:
+  SurfaceImpl(SDL_Surface* surface = NULL) : surface(surface) {}
+  ~SurfaceImpl() {
+    SDL_FreeSurface(surface);
+  }
+  SDL_Surface* surface;
+};
+
+Surface::Surface()
+{
+}
+
+Surface::Surface(const Pathname& pathname)
+  : impl(new SurfaceImpl())
+{
+  impl->surface = IMG_Load(pathname.get_sys_path().c_str());
+  if (!impl->surface)
+    std::cout << "XXXXXX Failed to load: " << pathname.str() << std::endl;
+  ///else
+  //std::cout << "Loaded surface: " << name << ": " << surface->w << "x" << 
surface->h << std::endl;
+
+}
+
+Surface::Surface(int width, int height, SDL_Palette* palette, int colorkey)
+  : impl(new SurfaceImpl())
+{
+  if (colorkey == -1)
+    {
+      impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 8,
+                                           0, 0, 0 ,0);
+    }
+  else
+    {
+      impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCCOLORKEY, 
width, height, 8,
+                                           0, 0, 0 ,0);
+      SDL_SetColorKey(impl->surface, SDL_SRCCOLORKEY, colorkey);
+    }
+
+  SDL_SetColors(impl->surface, palette->colors, 0, palette->ncolors);
+}
+
+Surface::Surface(int width, int height)
+  : impl(new SurfaceImpl())
+{
+  impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
+                                       0x000000ff,
+                                       0x0000ff00,
+                                       0x00ff0000,
+                                       0xff000000);
+  //SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, 0, 0, 0, 0));
+}
+
+Surface::Surface(SDL_Surface* surface)
+  : impl(new SurfaceImpl(surface))
+{
+}
+
+Surface::~Surface()
+{
+}
+
+void
+Surface::blit(const Surface& src, int x, int y)
+{
+  if (!get_surface())
+    {
+      std::cout << "Surface: Trying to blit to empty surface" << std::endl;
+    }
+  else if (!src.get_surface())
+    {
+      std::cout << "Surface: Trying to blit with an empty surface" << 
std::endl;
+    }
+  else
+    {
+      SDL_Rect dstrect;
+
+      dstrect.x = x;
+      dstrect.y = y;
+
+      SDL_BlitSurface(src.get_surface(), NULL, get_surface(), &dstrect);
+    }
+}
+
+void
+Surface::lock()
+{
+  SDL_LockSurface(get_surface());
+}
+
+void
+Surface::unlock()
+{
+  SDL_UnlockSurface(get_surface());
+}
+
+uint8_t*
+Surface::get_data() const
+{
+  return static_cast<uint8_t*>(get_surface()->pixels);
+}
+
+int
+Surface::get_width()  const
+{
+  if (get_surface())
+    return get_surface()->w;
+  else
+    return 0;
+}
+
+int
+Surface::get_height() const
+{
+  if (get_surface())
+    return get_surface()->h;
+  else
+    return 0;
+}
+
+int
+Surface::get_pitch() const
+{
+  if (get_surface())
+    return get_surface()->pitch;
+  else
+    return 0;
+}
+
+SDL_Surface* 
+Surface::get_surface() const
+{
+  return impl ? impl->surface : 0;
+}
+
+Surface::operator bool() const
+{
+  return impl ? impl->surface != NULL : false;
+}
+
+Color
+Surface::get_pixel(int x, int y) const
+{
+  Uint8 *p = (Uint8 *)get_surface()->pixels + y * get_surface()->pitch + x * 
get_surface()->format->BytesPerPixel;
+  Uint32 pixel;
+
+  switch(get_surface()->format->BytesPerPixel)
+    {
+    case 1:
+      pixel = *p;
+    case 2: /* This will cause some problems ... */
+      pixel = *(Uint16 *)p;
+    case 3:
+      if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
+       pixel = p[0] << 16 | p[1] << 8 | p[2];
+      else
+       pixel = p[0] | p[1] << 8 | p[2] << 16;
+    case 4:
+      pixel = *(Uint32 *)p;
+    default:
+      pixel = 0;       /* shouldn't happen, but avoids warnings */
+    } 
+
+  Color color;
+  SDL_GetRGBA(pixel, get_surface()->format, &color.r, &color.g, &color.b, 
&color.a);
+  return color;
+}
+
+/* EOF */

Copied: trunk/pingus/src/surface.hpp (from rev 3145, 
trunk/pingus/src/pixel_buffer.hpp)
===================================================================
--- trunk/pingus/src/pixel_buffer.hpp   2007-09-14 16:33:50 UTC (rev 3145)
+++ trunk/pingus/src/surface.hpp        2007-09-14 19:13:17 UTC (rev 3147)
@@ -0,0 +1,69 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2005 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#ifndef HEADER_SURFACE_HPP
+#define HEADER_SURFACE_HPP
+
+#include "SDL.h"
+#include <string>
+#include <boost/shared_ptr.hpp>
+#include "pathname.hpp"
+#include "math/color.hpp"
+
+class Pathname;
+class SurfaceImpl;
+
+/** */
+class Surface
+{
+public:
+  Surface();
+  Surface(const Pathname& name);
+  /** Create an empty RGBA Surface */
+  Surface(int width, int height);
+
+  /** Create an empty Indexed Surface (8bit) */
+  Surface(int width, int height, SDL_Palette* palette, int colorkey = -1);
+  /** Create a Surface from a SDL_Surface */
+  Surface(SDL_Surface* surface);
+  ~Surface();
+
+  uint8_t* get_data() const;
+  void lock();
+  void unlock();
+
+  int get_width()  const;
+  int get_height() const;
+  int get_pitch()  const;
+
+  void blit(const Surface& source, int x, int y);
+
+  Color get_pixel(int x, int y) const;
+
+  SDL_Surface* get_surface() const;
+
+  operator bool() const;
+
+protected:
+  boost::shared_ptr<SurfaceImpl> impl;
+};
+
+#endif
+
+/* EOF */

Modified: trunk/pingus/src/world.cpp
===================================================================
--- trunk/pingus/src/world.cpp  2007-09-14 18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/world.cpp  2007-09-14 19:13:17 UTC (rev 3147)
@@ -285,7 +285,7 @@
 void
 World::put(const CollisionMask& mask, int x, int y, Groundtype::GPType type)
 {
-  gfx_map->put(mask.get_pixelbuffer(), x, y);
+  gfx_map->put(mask.get_surface(), x, y);
   colmap->put(mask, x, y, type);
 }
 
@@ -297,7 +297,7 @@
 void
 World::remove(const CollisionMask& mask, int x, int y)
 {
-  gfx_map->remove(mask.get_pixelbuffer(), x, y);
+  gfx_map->remove(mask.get_surface(), x, y);
   colmap->remove(mask, x, y);
 }
 

Modified: trunk/pingus/src/worldobjs/solid_color_background.hpp
===================================================================
--- trunk/pingus/src/worldobjs/solid_color_background.hpp       2007-09-14 
18:21:07 UTC (rev 3146)
+++ trunk/pingus/src/worldobjs/solid_color_background.hpp       2007-09-14 
19:13:17 UTC (rev 3147)
@@ -21,7 +21,6 @@
 #define HEADER_PINGUS_WORLDOBJS_SOLID_COLOR_BACKGROUND_HXX
 
 #include "../math/color.hpp"
-#include "../pixel_buffer.hpp"
 #include "../worldobj.hpp"
 
 namespace WorldObjsData {





reply via email to

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