[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3396 - trunk/pingus/src
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3396 - trunk/pingus/src |
Date: |
Tue, 30 Oct 2007 07:59:29 +0100 |
Author: grumbel
Date: 2007-10-30 07:59:28 +0100 (Tue, 30 Oct 2007)
New Revision: 3396
Modified:
trunk/pingus/src/blitter.cpp
trunk/pingus/src/smallmap_image.cpp
trunk/pingus/src/surface.cpp
trunk/pingus/src/surface.hpp
Log:
- some debugging code to track down a bug in Surface::clone()
Modified: trunk/pingus/src/blitter.cpp
===================================================================
--- trunk/pingus/src/blitter.cpp 2007-10-30 06:39:44 UTC (rev 3395)
+++ trunk/pingus/src/blitter.cpp 2007-10-30 06:59:28 UTC (rev 3396)
@@ -247,6 +247,9 @@
surface->format->Bmask,
surface->format->Amask);
+ if (surface->flags & SDL_SRCALPHA)
+ SDL_SetAlpha(new_surface, SDL_SRCALPHA, surface->format->alpha);
+
if (surface->format->palette)
SDL_SetPalette(new_surface, SDL_LOGPAL, surface->format->palette->colors,
0, surface->format->palette->ncolors);
Modified: trunk/pingus/src/smallmap_image.cpp
===================================================================
--- trunk/pingus/src/smallmap_image.cpp 2007-10-30 06:39:44 UTC (rev 3395)
+++ trunk/pingus/src/smallmap_image.cpp 2007-10-30 06:59:28 UTC (rev 3396)
@@ -17,12 +17,12 @@
// 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 "world.hpp"
#include "smallmap_image.hpp"
#include "col_map.hpp"
#include "server.hpp"
-
SmallMapImage::SmallMapImage(Server* s, int width, int height)
: server(s),
canvas(width, height),
@@ -149,9 +149,17 @@
}
canvas.unlock();
+
+ Surface s = canvas.clone();
+ std::cout << "========================================" << std::endl;
+ canvas.print(std::cout);
+ std::cout << "----------------------------------------" << std::endl;
+ s.print(std::cout);
+ std::cout << "========================================\n" << std::endl;
+
// FIXME: Should do: sur = Sprite(canvas.clone());
// but doesn't work, gives transparent surface as result
- sur = Sprite(canvas);
+ sur = Sprite(s);
}
/* EOF */
Modified: trunk/pingus/src/surface.cpp
===================================================================
--- trunk/pingus/src/surface.cpp 2007-10-30 06:39:44 UTC (rev 3395)
+++ trunk/pingus/src/surface.cpp 2007-10-30 06:59:28 UTC (rev 3396)
@@ -18,6 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "SDL_image.h"
+#include <boost/format.hpp>
#include <sstream>
#include <iostream>
#include "math/rect.hpp"
@@ -288,7 +289,7 @@
{
SDL_Surface* new_surface =
Blitter::create_surface_from_format(impl->surface,
impl->surface->w, impl->surface->h);
- SDL_BlitSurface(impl->surface, NULL, new_surface, NULL);
+ std::cout << "Blit: " << SDL_BlitSurface(impl->surface, NULL, new_surface,
NULL) << std::endl;
return Surface(boost::shared_ptr<SurfaceImpl>(new SurfaceImpl(new_surface,
true)));
}
@@ -338,5 +339,37 @@
{
return impl.use_count() != 1;
}
+
+void
+Surface::print(std::ostream& out)
+{
+ out << boost::format("Pointer: 0x%p\n"
+ "Rmask: 0x%08x\n"
+ "Gmask: 0x%08x\n"
+ "Bmask: 0x%08x\n"
+ "Amask: 0x%08x\n"
+ "Flags: 0x%08x -> %s%s%s%s\n"
+ "Palette: 0x%08x\n"
+ "BitsPerPixel: %d\n"
+ )
+ % impl->surface
+ % impl->surface->format->Rmask
+ % impl->surface->format->Gmask
+ % impl->surface->format->Bmask
+ % impl->surface->format->Amask
+ % impl->surface->flags
+ % ((impl->surface->flags & SDL_HWSURFACE) ? "HWSURFACE " : "")
+ % ((impl->surface->flags & SDL_SWSURFACE) ? "SWSURFACE " : "")
+ % ((impl->surface->flags & SDL_SRCCOLORKEY) ? "SRCCOLORKEY " : "")
+ % ((impl->surface->flags & SDL_SRCALPHA) ? "SRCALPHA " : "")
+ % impl->surface->format->palette
+ % impl->surface->format->BitsPerPixel;
+
+ if (impl->surface->flags & SDL_SRCCOLORKEY)
+ out << "Colorkey: " << (int)impl->surface->format->colorkey << std::endl;
+
+ if (impl->surface->flags & SDL_SRCALPHA)
+ out << "Alpha: " << (int)impl->surface->format->alpha << std::endl;
+}
/* EOF */
Modified: trunk/pingus/src/surface.hpp
===================================================================
--- trunk/pingus/src/surface.hpp 2007-10-30 06:39:44 UTC (rev 3395)
+++ trunk/pingus/src/surface.hpp 2007-10-30 06:59:28 UTC (rev 3396)
@@ -80,6 +80,8 @@
bool is_shared() const;
+ void print(std::ostream& out);
+
protected:
boost::shared_ptr<SurfaceImpl> impl;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3396 - trunk/pingus/src,
grumbel at BerliOS <=