[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Rotation test level
From: |
Björn Fischer |
Subject: |
Re: Rotation test level |
Date: |
Mon, 07 Apr 2003 08:52:16 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3a) Gecko/20021212 |
No, I'm afraid removing namespace code didn't help. Rotation is
still wrong...
You could try and insert some std::cout's into blitter.cxx and
blitter_impl.cxx to see if the templates are really incorrect or if it
is something else. If the templates are handled incorrectly, we have
not much other choice than either rewriting the stuff to be
template-less or drop MSVC6 compability.
I think that should be your choice.
Anyway, to get it working on my machine I removed the template and
overloaded the modify-function 6 times by copying the source. Not very
beautiful...
But it works on MSVC6. I attached the patch. If you decide to further
support MSVC6 you can take this patch for the first and I can rewrite
the code later to be somehow elegant. If you decide to drop MSVC6
support it's no big deal for me (I can get MSVC7 from the university),
but when keeping the point "attracting developers" in mind it would be
better to support as many compilers as possible.
I think I'd tend to dropping MSVC6-support even though there migth be
some developers who have only this one. I'm quite experienced in using
M$'s programming languages. And I know that this will not be the last
bug in it. So using the newest version is never wrong.
Greetings
Björn
Index: src/blitter_impl.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/blitter_impl.hxx,v
retrieving revision 1.9
diff -u -r1.9 blitter_impl.hxx
--- src/blitter_impl.hxx 3 Apr 2003 17:03:24 -0000 1.9
+++ src/blitter_impl.hxx 7 Apr 2003 06:43:41 -0000
@@ -178,9 +178,9 @@
static inline int get_height(int width, int height) { UNUSED_ARG(height);
return width; }
};
-template<class TransF>
+//template<class TransF>
inline
-CL_Surface modify(const CL_Surface& sur)
+CL_Surface modify(transform_rot180 TransF, const CL_Surface& sur)
{
CL_SurfaceProvider* prov = sur.get_provider ();
int pwidth = prov->get_width();
@@ -190,8 +190,8 @@
{
//std::cout << "Using indexed blitter" << std::endl;
- IndexedCanvas* canvas = new IndexedCanvas(TransF::get_width (pwidth,
pheight),
- TransF::get_height(pwidth,
pheight));
+ IndexedCanvas* canvas = new IndexedCanvas(TransF.get_width (pwidth,
pheight),
+ TransF.get_height(pwidth,
pheight));
if (prov->uses_src_colorkey())
canvas->set_src_colorkey(prov->get_src_colorkey());
@@ -207,7 +207,7 @@
for (int x = 0; x < pwidth; ++x)
{
#ifdef PINGUS_DO_ROTBLITTER_BOUNDCHECK
- int i = TransF::get_index(pwidth, pheight, x, y);
+ int i = TransF.get_index(pwidth, pheight, x, y);
if (i < 0 || i >= pwidth * pheight)
{
std::cout << "Target: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
@@ -221,7 +221,7 @@
<< " " << typeid(TransF()).name() << std::endl;
}
#endif
- target_buf[TransF::get_index(pwidth, pheight, x, y)] =
source_buf[y * pwidth + x];
+ target_buf[TransF.get_index(pwidth, pheight, x, y)] = source_buf[y
* pwidth + x];
}
canvas->unlock ();
@@ -240,8 +240,8 @@
for (unsigned int x = 0; x < sur.get_width (); ++x)
{
prov->get_pixel (x, y, &r, &g, &b, &a);
- canvas->draw_pixel (TransF::get_x(pwidth, pheight, x, y),
- TransF::get_y(pwidth, pheight, x, y),
+ canvas->draw_pixel (TransF.get_x(pwidth, pheight, x, y),
+ TransF.get_y(pwidth, pheight, x, y),
r, g, b, a);
}
@@ -250,6 +250,391 @@
return CL_Surface(canvas, true);
}
}
+
+//-------------------------------------------------------
+//Rotation 270 degrees
+inline
+CL_Surface modify(transform_rot270 TransF, const CL_Surface& sur)
+{
+ CL_SurfaceProvider* prov = sur.get_provider ();
+ int pwidth = prov->get_width();
+ int pheight = prov->get_height();
+
+ if (prov->is_indexed())
+ {
+ //std::cout << "Using indexed blitter" << std::endl;
+
+ IndexedCanvas* canvas = new IndexedCanvas(TransF.get_width (pwidth,
pheight),
+ TransF.get_height(pwidth,
pheight));
+ if (prov->uses_src_colorkey())
+ canvas->set_src_colorkey(prov->get_src_colorkey());
+
+ prov->lock ();
+ canvas->lock ();
+
+ canvas->set_palette(prov->get_palette());
+
+ unsigned char* source_buf = static_cast<unsigned
char*>(prov->get_data());
+ unsigned char* target_buf = static_cast<unsigned
char*>(canvas->get_data());
+
+ for (int y = 0; y < pheight; ++y)
+ for (int x = 0; x < pwidth; ++x)
+ {
+#ifdef PINGUS_DO_ROTBLITTER_BOUNDCHECK
+ int i = TransFget_index(pwidth, pheight, x, y);
+ if (i < 0 || i >= pwidth * pheight)
+ {
+ std::cout << "Target: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+
+ if (y * pwidth + x < 0
+ || y * pwidth + x >= pwidth * pheight)
+ {
+ std::cout << "Source: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+#endif
+ target_buf[TransF.get_index(pwidth, pheight, x, y)] = source_buf[y
* pwidth + x];
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+ else
+ {
+ CL_Canvas* canvas = new CL_Canvas (sur.get_height (), sur.get_width ());
+
+ prov->lock ();
+ canvas->lock ();
+
+ float r, b, g, a;
+ for (unsigned int y = 0; y < sur.get_height (); ++y)
+ for (unsigned int x = 0; x < sur.get_width (); ++x)
+ {
+ prov->get_pixel (x, y, &r, &g, &b, &a);
+ canvas->draw_pixel (TransF.get_x(pwidth, pheight, x, y),
+ TransF.get_y(pwidth, pheight, x, y),
+ r, g, b, a);
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+}
+//end Rotation 270 degrees
+//-------------------------------------------------------
+
+//-------------------------------------------------------
+//Rotation 90 degrees and flip
+inline
+CL_Surface modify(transform_rot90_flip TransF, const CL_Surface& sur)
+{
+ CL_SurfaceProvider* prov = sur.get_provider ();
+ int pwidth = prov->get_width();
+ int pheight = prov->get_height();
+
+ if (prov->is_indexed())
+ {
+ //std::cout << "Using indexed blitter" << std::endl;
+
+ IndexedCanvas* canvas = new IndexedCanvas(TransF.get_width (pwidth,
pheight),
+ TransF.get_height(pwidth,
pheight));
+ if (prov->uses_src_colorkey())
+ canvas->set_src_colorkey(prov->get_src_colorkey());
+
+ prov->lock ();
+ canvas->lock ();
+
+ canvas->set_palette(prov->get_palette());
+
+ unsigned char* source_buf = static_cast<unsigned
char*>(prov->get_data());
+ unsigned char* target_buf = static_cast<unsigned
char*>(canvas->get_data());
+
+ for (int y = 0; y < pheight; ++y)
+ for (int x = 0; x < pwidth; ++x)
+ {
+#ifdef PINGUS_DO_ROTBLITTER_BOUNDCHECK
+ int i = TransFget_index(pwidth, pheight, x, y);
+ if (i < 0 || i >= pwidth * pheight)
+ {
+ std::cout << "Target: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+
+ if (y * pwidth + x < 0
+ || y * pwidth + x >= pwidth * pheight)
+ {
+ std::cout << "Source: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+#endif
+ target_buf[TransF.get_index(pwidth, pheight, x, y)] = source_buf[y
* pwidth + x];
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+ else
+ {
+ CL_Canvas* canvas = new CL_Canvas (sur.get_height (), sur.get_width ());
+
+ prov->lock ();
+ canvas->lock ();
+
+ float r, b, g, a;
+ for (unsigned int y = 0; y < sur.get_height (); ++y)
+ for (unsigned int x = 0; x < sur.get_width (); ++x)
+ {
+ prov->get_pixel (x, y, &r, &g, &b, &a);
+ canvas->draw_pixel (TransF.get_x(pwidth, pheight, x, y),
+ TransF.get_y(pwidth, pheight, x, y),
+ r, g, b, a);
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+}
+//end Rotation 90 degrees and flip
+//-------------------------------------------------------
+
+
+//-------------------------------------------------------
+//Rotation 180 degrees and flip
+inline
+CL_Surface modify(transform_rot180_flip TransF, const CL_Surface& sur)
+{
+ CL_SurfaceProvider* prov = sur.get_provider ();
+ int pwidth = prov->get_width();
+ int pheight = prov->get_height();
+
+ if (prov->is_indexed())
+ {
+ //std::cout << "Using indexed blitter" << std::endl;
+
+ IndexedCanvas* canvas = new IndexedCanvas(TransF.get_width (pwidth,
pheight),
+ TransF.get_height(pwidth,
pheight));
+ if (prov->uses_src_colorkey())
+ canvas->set_src_colorkey(prov->get_src_colorkey());
+
+ prov->lock ();
+ canvas->lock ();
+
+ canvas->set_palette(prov->get_palette());
+
+ unsigned char* source_buf = static_cast<unsigned
char*>(prov->get_data());
+ unsigned char* target_buf = static_cast<unsigned
char*>(canvas->get_data());
+
+ for (int y = 0; y < pheight; ++y)
+ for (int x = 0; x < pwidth; ++x)
+ {
+#ifdef PINGUS_DO_ROTBLITTER_BOUNDCHECK
+ int i = TransFget_index(pwidth, pheight, x, y);
+ if (i < 0 || i >= pwidth * pheight)
+ {
+ std::cout << "Target: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+
+ if (y * pwidth + x < 0
+ || y * pwidth + x >= pwidth * pheight)
+ {
+ std::cout << "Source: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+#endif
+ target_buf[TransF.get_index(pwidth, pheight, x, y)] = source_buf[y
* pwidth + x];
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+ else
+ {
+ CL_Canvas* canvas = new CL_Canvas (sur.get_height (), sur.get_width ());
+
+ prov->lock ();
+ canvas->lock ();
+
+ float r, b, g, a;
+ for (unsigned int y = 0; y < sur.get_height (); ++y)
+ for (unsigned int x = 0; x < sur.get_width (); ++x)
+ {
+ prov->get_pixel (x, y, &r, &g, &b, &a);
+ canvas->draw_pixel (TransF.get_x(pwidth, pheight, x, y),
+ TransF.get_y(pwidth, pheight, x, y),
+ r, g, b, a);
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+}
+//end Rotation 180 degrees and flip
+//-------------------------------------------------------
+
+
+//-------------------------------------------------------
+//Rotation 270 degrees and flip
+inline
+CL_Surface modify(transform_rot270_flip TransF, const CL_Surface& sur)
+{
+ CL_SurfaceProvider* prov = sur.get_provider ();
+ int pwidth = prov->get_width();
+ int pheight = prov->get_height();
+
+ if (prov->is_indexed())
+ {
+ //std::cout << "Using indexed blitter" << std::endl;
+
+ IndexedCanvas* canvas = new IndexedCanvas(TransF.get_width (pwidth,
pheight),
+ TransF.get_height(pwidth,
pheight));
+ if (prov->uses_src_colorkey())
+ canvas->set_src_colorkey(prov->get_src_colorkey());
+
+ prov->lock ();
+ canvas->lock ();
+
+ canvas->set_palette(prov->get_palette());
+
+ unsigned char* source_buf = static_cast<unsigned
char*>(prov->get_data());
+ unsigned char* target_buf = static_cast<unsigned
char*>(canvas->get_data());
+
+ for (int y = 0; y < pheight; ++y)
+ for (int x = 0; x < pwidth; ++x)
+ {
+#ifdef PINGUS_DO_ROTBLITTER_BOUNDCHECK
+ int i = TransFget_index(pwidth, pheight, x, y);
+ if (i < 0 || i >= pwidth * pheight)
+ {
+ std::cout << "Target: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+
+ if (y * pwidth + x < 0
+ || y * pwidth + x >= pwidth * pheight)
+ {
+ std::cout << "Source: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+#endif
+ target_buf[TransF.get_index(pwidth, pheight, x, y)] = source_buf[y
* pwidth + x];
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+ else
+ {
+ CL_Canvas* canvas = new CL_Canvas (sur.get_height (), sur.get_width ());
+
+ prov->lock ();
+ canvas->lock ();
+
+ float r, b, g, a;
+ for (unsigned int y = 0; y < sur.get_height (); ++y)
+ for (unsigned int x = 0; x < sur.get_width (); ++x)
+ {
+ prov->get_pixel (x, y, &r, &g, &b, &a);
+ canvas->draw_pixel (TransF.get_x(pwidth, pheight, x, y),
+ TransF.get_y(pwidth, pheight, x, y),
+ r, g, b, a);
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+}
+//end Rotation 270 degrees and flip
+//-------------------------------------------------------
+
+
+
+//-------------------------------------------------------
+//only flip
+inline
+CL_Surface modify(transform_flip TransF, const CL_Surface& sur)
+{
+ CL_SurfaceProvider* prov = sur.get_provider ();
+ int pwidth = prov->get_width();
+ int pheight = prov->get_height();
+
+ if (prov->is_indexed())
+ {
+ //std::cout << "Using indexed blitter" << std::endl;
+
+ IndexedCanvas* canvas = new IndexedCanvas(TransF.get_width (pwidth,
pheight),
+ TransF.get_height(pwidth,
pheight));
+ if (prov->uses_src_colorkey())
+ canvas->set_src_colorkey(prov->get_src_colorkey());
+
+ prov->lock ();
+ canvas->lock ();
+
+ canvas->set_palette(prov->get_palette());
+
+ unsigned char* source_buf = static_cast<unsigned
char*>(prov->get_data());
+ unsigned char* target_buf = static_cast<unsigned
char*>(canvas->get_data());
+
+ for (int y = 0; y < pheight; ++y)
+ for (int x = 0; x < pwidth; ++x)
+ {
+#ifdef PINGUS_DO_ROTBLITTER_BOUNDCHECK
+ int i = TransFget_index(pwidth, pheight, x, y);
+ if (i < 0 || i >= pwidth * pheight)
+ {
+ std::cout << "Target: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+
+ if (y * pwidth + x < 0
+ || y * pwidth + x >= pwidth * pheight)
+ {
+ std::cout << "Source: Out of bounce: " << i << " " << pwidth
<< "x" << pheight
+ << " " << typeid(TransF()).name() << std::endl;
+ }
+#endif
+ target_buf[TransF.get_index(pwidth, pheight, x, y)] = source_buf[y
* pwidth + x];
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+ else
+ {
+ CL_Canvas* canvas = new CL_Canvas (sur.get_height (), sur.get_width ());
+
+ prov->lock ();
+ canvas->lock ();
+
+ float r, b, g, a;
+ for (unsigned int y = 0; y < sur.get_height (); ++y)
+ for (unsigned int x = 0; x < sur.get_width (); ++x)
+ {
+ prov->get_pixel (x, y, &r, &g, &b, &a);
+ canvas->draw_pixel (TransF.get_x(pwidth, pheight, x, y),
+ TransF.get_y(pwidth, pheight, x, y),
+ r, g, b, a);
+ }
+
+ canvas->unlock ();
+ prov->unlock ();
+ return CL_Surface(canvas, true);
+ }
+}
+//end only flip
+//-------------------------------------------------------
+
} // namespace BlitterImpl
Index: src/blitter.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/blitter.cxx,v
retrieving revision 1.24
diff -u -r1.24 blitter.cxx
--- src/blitter.cxx 25 Mar 2003 00:37:44 -0000 1.24
+++ src/blitter.cxx 7 Apr 2003 06:44:23 -0000
@@ -565,14 +565,16 @@
CL_Surface
Blitter::flip_horizontal (const CL_Surface& sur)
{
- return BlitterImpl::modify<BlitterImpl::transform_flip>(sur);
+ BlitterImpl::transform_flip transformation;
+ return BlitterImpl::modify(transformation, sur);
}
/** Flip a surface vertical */
CL_Surface
Blitter::flip_vertical (const CL_Surface& sur)
{
- return BlitterImpl::modify<BlitterImpl::transform_rot180_flip>(sur);
+ BlitterImpl::transform_rot180_flip transformation;
+ return BlitterImpl::modify(transformation, sur);
}
/** Rotate a surface 90 degrees */
@@ -634,33 +636,40 @@
CL_Surface
Blitter::rotate_180 (const CL_Surface& sur)
{
- return BlitterImpl::modify<BlitterImpl::transform_rot180>(sur);
+ BlitterImpl::transform_rot180 transformation;
+ return BlitterImpl::modify(transformation, sur);
}
CL_Surface
Blitter::rotate_270 (const CL_Surface& sur)
{
- return BlitterImpl::modify<BlitterImpl::transform_rot270>(sur);
+ BlitterImpl::transform_rot270 transformation;
+ return BlitterImpl::modify(transformation, sur);
}
CL_Surface
Blitter::rotate_90_flip (const CL_Surface& sur)
{
- return BlitterImpl::modify<BlitterImpl::transform_rot90_flip>(sur);
+ BlitterImpl::transform_rot90_flip transformation;
+ return BlitterImpl::modify(transformation, sur);
//return Blitter::flip_horizontal(Blitter::rotate_90(sur));
}
CL_Surface
Blitter::rotate_180_flip (const CL_Surface& sur)
{
- return BlitterImpl::modify<BlitterImpl::transform_rot180_flip>(sur);
+ BlitterImpl::transform_rot180_flip transformation;
+ return BlitterImpl::modify(transformation, sur);
+ //return BlitterImpl::modify<BlitterImpl::transform_rot180_flip>(sur);
//return Blitter::flip_horizontal(Blitter::rotate_180(sur));
}
CL_Surface
Blitter::rotate_270_flip (const CL_Surface& sur)
{
- return BlitterImpl::modify<BlitterImpl::transform_rot270_flip>(sur);
+ BlitterImpl::transform_rot270_flip transformation;
+ return BlitterImpl::modify(transformation, sur);
+ //return BlitterImpl::modify<BlitterImpl::transform_rot270_flip>(sur);
//return Blitter::flip_horizontal(Blitter::rotate_270(sur));
}
- Re: Rotation test level, (continued)
- Re: Rotation test level, Ingo Ruhnke, 2003/04/02
- Re: Rotation test level, Björn Fischer, 2003/04/03
- Re: Rotation test level, David Philippi, 2003/04/03
- Re: Rotation test level, Björn Fischer, 2003/04/04
- Re: Rotation test level, Kenneth Gangstoe, 2003/04/04
- Re: Rotation test level, Björn Fischer, 2003/04/04
- Re: Rotation test level, Kenneth Gangstoe, 2003/04/05
- Re: Rotation test level, Ingo Ruhnke, 2003/04/05
- Re: Rotation test level,
Björn Fischer <=
- Re: Rotation test level, David Philippi, 2003/04/07
- Re: Rotation test level, Neil Mitchell, 2003/04/07