[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - So 21. Jan 2007, 13:16:40]:
> 
> On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]> wrote:
> >
> >
> > And these two commands?
> >
> > cat Makefile.in | grep SDL_rotozoom
> > cat Makefile.am | grep SDL_rotozoom
> >
> >
> 
> ibg3:~/freeciv/client/gui-sdl daniel$ cat Makefile | grep SDL_rotozoom
> ibg3:~/freeciv/client/gui-sdl daniel$ cat Makefile.in | grep SDL_rotozoom
> ibg3:~/freeciv/client/gui-sdl daniel$ cat Makefile.am | grep SDL_rotozoom
> SDL_rotozoom.c  \
> SDL_rotozoom.h  \
> 

This looks like autogen.sh didn't work as expected. Does it work when
you delete Makefile and Makefile.in and then run autogen.sh and "make"
again?


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - So 21. Jan 2007, 12:57:40]:
> 
> On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]> wrote:
> >
> > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> >
> > > [dmarks - So 21. Jan 2007, 11:56:07]:
> > >
> > > On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> > > wrote:
> > > >
> > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > >
> > > > > [dmarks - So 21. Jan 2007, 11:12:47]:
> > > > >
> > > > > On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> > > wrote:
> > > > > >
> > > > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > > > >
> > > > > > > [dmarks - So 21. Jan 2007, 09:51:18]:
> > > > > > >
> > > > > > > On 1/21/07, Christian Prochaska
> > > <[EMAIL PROTECTED]>
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > > > > > >
> > > > > > > > > [dmarks - So 21. Jan 2007, 09:31:09]:
> > > > > > > > >
> > > > > > > > > On 1/21/07, Christian Prochaska
> > > <[EMAIL PROTECTED]>
> > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > >  > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > > > > > > > >
> > > > > > > > > > What output do you get when you enter "nm libguiclient.a
> > > | grep
> > > > > > > > > > zoomSurface" in client/gui-sdl?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > ibg3:~/freeciv/client/gui-sdl daniel$ nm libguiclient.a |
> > > grep
> > > > > > > zoomSurface
> > > > > > > > > nm: no name list
> > > > > > > > > nm: no name list
> > > > > > > > >  U _zoomSurface
> > > > > > > > >
> > > > > > > >
> > > > > > > > And "nm SDL_rotozoom.o"?
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > > There no such file in the gui-sdl/ directory.
> > > > > > >
> > > > > >
> > > > > > Did you run autogen.sh after applying the patch?
> > > > > >
> > > > > >
> > > > >
> > > > > Yes I did, but that file is not created.
> > > > >
> > > >
> > > > And when you run "make clean" in gui-sdl before compiling?
> > > >
> > > >
> > >
> > > It didn't make any difference. Isn't it a problem that the ".o" isn't
> > > created?
> > >
> >
> > It's a problem, because the *.o files contain the binary code that gcc
> > generates from the *.c source files. The error message you got ("ld:
> > Undefined symbols: _zoomSurface") means that the binary code of the
> > zoomSurface() function could not be found. It's supposed to be stored in
> > SDL_rotozoom.o, because the source code of the zoomSurface() function is
> > defined in SDL_rotozoom.c. But for some reason SDL_rotozoom.c doesn't
> > seem to get compiled on your machine.
> >
> > What output do you get from "cat Makefile | grep SDL_rotozoom" in the
> > gui-sdl directory?
> >
> >
> 
> That gives no output.
> 

And these two commands?

cat Makefile.in | grep SDL_rotozoom
cat Makefile.am | grep SDL_rotozoom


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - So 21. Jan 2007, 11:56:07]:
> 
> On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> wrote:
> >
> > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> >
> > > [dmarks - So 21. Jan 2007, 11:12:47]:
> > >
> > > On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> wrote:
> > > >
> > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > >
> > > > > [dmarks - So 21. Jan 2007, 09:51:18]:
> > > > >
> > > > > On 1/21/07, Christian Prochaska
> <[EMAIL PROTECTED]>
> > > > > wrote:
> > > > > >
> > > > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > > > >
> > > > > > > [dmarks - So 21. Jan 2007, 09:31:09]:
> > > > > > >
> > > > > > > On 1/21/07, Christian Prochaska
> <[EMAIL PROTECTED]>
> > > > > wrote:
> > > > > > > >
> > > > > > > >  http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > > > > > >
> > > > > > > > What output do you get when you enter "nm libguiclient.a
> | grep
> > > > > > > > zoomSurface" in client/gui-sdl?
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > > ibg3:~/freeciv/client/gui-sdl daniel$ nm libguiclient.a |
> grep
> > > > > zoomSurface
> > > > > > > nm: no name list
> > > > > > > nm: no name list
> > > > > > >  U _zoomSurface
> > > > > > >
> > > > > >
> > > > > > And "nm SDL_rotozoom.o"?
> > > > > >
> > > > > >
> > > > >
> > > > > There no such file in the gui-sdl/ directory.
> > > > >
> > > >
> > > > Did you run autogen.sh after applying the patch?
> > > >
> > > >
> > >
> > > Yes I did, but that file is not created.
> > >
> >
> > And when you run "make clean" in gui-sdl before compiling?
> >
> >
> 
> It didn't make any difference. Isn't it a problem that the ".o" isn't
> created?
> 

It's a problem, because the *.o files contain the binary code that gcc
generates from the *.c source files. The error message you got ("ld:
Undefined symbols: _zoomSurface") means that the binary code of the
zoomSurface() function could not be found. It's supposed to be stored in
SDL_rotozoom.o, because the source code of the zoomSurface() function is
defined in SDL_rotozoom.c. But for some reason SDL_rotozoom.c doesn't
seem to get compiled on your machine. 

What output do you get from "cat Makefile | grep SDL_rotozoom" in the
gui-sdl directory?


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - So 21. Jan 2007, 11:12:47]:
> 
> On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]> wrote:
> >
> > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> >
> > > [dmarks - So 21. Jan 2007, 09:51:18]:
> > >
> > > On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> > > wrote:
> > > >
> > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > >
> > > > > [dmarks - So 21. Jan 2007, 09:31:09]:
> > > > >
> > > > > On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> > > wrote:
> > > > > >
> > > > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > > > >
> > > > > > What output do you get when you enter "nm libguiclient.a | grep
> > > > > > zoomSurface" in client/gui-sdl?
> > > > > >
> > > > > >
> > > > >
> > > > > ibg3:~/freeciv/client/gui-sdl daniel$ nm libguiclient.a | grep
> > > zoomSurface
> > > > > nm: no name list
> > > > > nm: no name list
> > > > >  U _zoomSurface
> > > > >
> > > >
> > > > And "nm SDL_rotozoom.o"?
> > > >
> > > >
> > >
> > > There no such file in the gui-sdl/ directory.
> > >
> >
> > Did you run autogen.sh after applying the patch?
> >
> >
> 
> Yes I did, but that file is not created.
> 

And when you run "make clean" in gui-sdl before compiling?


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - So 21. Jan 2007, 09:51:18]:
> 
> On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> wrote:
> >
> > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> >
> > > [dmarks - So 21. Jan 2007, 09:31:09]:
> > >
> > > On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> wrote:
> > > >
> > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > >
> > > > What output do you get when you enter "nm libguiclient.a | grep
> > > > zoomSurface" in client/gui-sdl?
> > > >
> > > >
> > >
> > > ibg3:~/freeciv/client/gui-sdl daniel$ nm libguiclient.a | grep
> zoomSurface
> > > nm: no name list
> > > nm: no name list
> > >  U _zoomSurface
> > >
> >
> > And "nm SDL_rotozoom.o"?
> >
> >
> 
> There no such file in the gui-sdl/ directory.
> 

Did you run autogen.sh after applying the patch?


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - So 21. Jan 2007, 09:31:09]:
> 
> On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]> wrote:
> >
> > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> >
> > > [dmarks - So 21. Jan 2007, 06:05:37]:
> > >
> > > On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> > > wrote:
> > > >
> > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > >
> > > > > [dmarks - Sa 20. Jan 2007, 23:45:51]:
> > > > >
> > > > > On 1/20/07, Christian Prochaska <[EMAIL PROTECTED]>
> > > wrote:
> > > > > >
> > > > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > > > >
> > > > > >
> > > > > > Does it work with the attached patch? It adds two new source
> > > files, so
> > > > > > you need to rerun autogen.sh before compiling.
> > > > > >
> > > > >
> > > > > It doesn't seem to be working fully. Scaled flags and buildings
> > > aren't
> > > > > showing up.
> > > > >
> > > > >  ~Daniel
> > > > >
> > > >
> > > > And with this patch?
> > > >
> > > >
> > >
> > > Make fails with this:
> > >
> > >
> >
> > What output do you get when you enter "nm libguiclient.a | grep
> > zoomSurface" in client/gui-sdl?
> >
> >
> 
> ibg3:~/freeciv/client/gui-sdl daniel$ nm libguiclient.a | grep zoomSurface
> nm: no name list
> nm: no name list
>  U _zoomSurface
> 

And "nm SDL_rotozoom.o"?


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - So 21. Jan 2007, 06:05:37]:
> 
> On 1/21/07, Christian Prochaska <[EMAIL PROTECTED]>
> wrote:
> >
> > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> >
> > > [dmarks - Sa 20. Jan 2007, 23:45:51]:
> > >
> > > On 1/20/07, Christian Prochaska <[EMAIL PROTECTED]>
> wrote:
> > > >
> > > > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> > > >
> > > >
> > > > Does it work with the attached patch? It adds two new source
> files, so
> > > > you need to rerun autogen.sh before compiling.
> > > >
> > >
> > > It doesn't seem to be working fully. Scaled flags and buildings
> aren't
> > > showing up.
> > >
> > >  ~Daniel
> > >
> >
> > And with this patch?
> >
> >
> 
> Make fails with this:
> 
> 

What output do you get when you enter "nm libguiclient.a | grep
zoomSurface" in client/gui-sdl?


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-20 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - Sa 20. Jan 2007, 23:45:51]:
> 
> On 1/20/07, Christian Prochaska <[EMAIL PROTECTED]> wrote:
> >
> > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> >
> > > [cproc - Mi 20. Dez 2006, 12:01:14]:
> > >
> > > > [dmarks - Mi 20. Dez 2006, 01:18:32]:
> > > >
> > > > On 12/20/06, Christian Prochaska <[EMAIL PROTECTED]>
> > > > wrote:
> > > > >
> > > > > So it seems there is a problem with antialiased zooming. Does the
> > > > > attached patch make the other missing images visible?
> > > > >
> > > >
> > > > It does, yes. Am I missing some component in my SDL installation?
> > >
> > > No, the zoom code is part of the SDL client and as it seems Rafal
put a
> > > lot of effort into optimizing it for speed, but apparently at the cost
> > > of portability. I'll try to add the hopefully more portable zoom
> > > function from SDL_gfx as an alternative for platforms where the
> > > optimized version doesn't work.
> > >
> >
> > Does it work with the attached patch? It adds two new source files, so
> > you need to rerun autogen.sh before compiling.
> >
> 
> It doesn't seem to be working fully. Scaled flags and buildings aren't
> showing up.
> 
>  ~Daniel
> 

And with this patch?

Index: client/gui-sdl/gui_zoom.c
===
--- client/gui-sdl/gui_zoom.c	(Revision 12506)
+++ client/gui-sdl/gui_zoom.c	(Arbeitskopie)
@@ -56,6 +56,8 @@
 
 #include 
 
+#include "SDL_rotozoom.h"
+
 /* gui-sdl */
 #include "graphics.h"
 
@@ -2246,6 +2248,7 @@
 
 #define VALUE_LIMIT	0.001
 
+#if 0
 /**
   zoomSurfaceSize( ... )
   Calculate new width and height from the scaling factors
@@ -2270,6 +2273,7 @@
   *pNew_width = MAX(*pNew_width, 1);
   *pNew_height = MAX(*pNew_height, 1);
 }
+#endif
 
 /* == */
 /* === Public Functions = */
@@ -2293,11 +2297,15 @@
 SDL_Surface *ZoomSurface(const SDL_Surface * pSrc, double zoomx,
 			 double zoomy, int smooth)
 {
+  return zoomSurface((SDL_Surface*)pSrc, zoomx, zoomy, smooth);
+#if 0
   int dstwidth, dstheight;
+  
   /* Get size if target */
   ZoomSurfaceSize(pSrc->w, pSrc->h, zoomx, zoomy, &dstwidth, &dstheight);
   return ResizeSurface(pSrc, (Uint16) dstwidth, (Uint16) dstheight,
 		   smooth);
+#endif
 }
 
 /**
@@ -2326,6 +2334,10 @@
 return NULL;
   }
   
+  double zoomx = (double)new_width / pSrc->w;
+  double zoomy = (double)new_height / pSrc->h;
+  return zoomSurface((SDL_Surface*)pSrc, zoomx, zoomy, smooth);
+  
   /*
* Alloc space to completely contain the zoomed surface 
*/
Index: client/gui-sdl/SDL_rotozoom.c
===
--- client/gui-sdl/SDL_rotozoom.c	(Revision 0)
+++ client/gui-sdl/SDL_rotozoom.c	(Revision 0)
@@ -0,0 +1,972 @@
+/*  
+
+  SDL_rotozoom.c - rotozoomer for 32bit or 8bit surfaces
+
+  LGPL (c) A. Schiffler
+
+*/
+
+#ifdef WIN32
+#include 
+#endif
+
+#include 
+#include 
+
+#include "SDL_rotozoom.h"
+
+#define MAX(a,b)(((a) > (b)) ? (a) : (b))
+
+/* 
+ 
+ 32bit Zoomer with optional anti-aliasing by bilinear interpolation.
+
+ Zoomes 32bit RGBA/ABGR 'src' surface to 'dst' surface.
+ 
+*/
+
+static int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int flipx, int flipy, int smooth)
+{
+int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy, ex, ey, t1, t2, sstep;
+tColorRGBA *c00, *c01, *c10, *c11;
+tColorRGBA *sp, *csp, *dp;
+int dgap;
+
+/*
+ * Variable setup 
+ */
+if (smooth) {
+	/*
+	 * For interpolation: assume source dimension is one pixel 
+	 */
+	/*
+	 * smaller to avoid overflow on right and bottom edge. 
+	 */
+	sx = (int) (65536.0 * (float) (src->w - 1) / (float) dst->w);
+	sy = (int) (65536.0 * (float) (src->h - 1) / (float) dst->h);
+} else {
+	sx = (int) (65536.0 * (float) src->w / (float) dst->w);
+	sy = (int) (65536.0 * (float) src->h / (float) dst->h);
+}
+
+/*
+ * Allocate memory for row increments 
+ */
+if ((sax = (int *) malloc((dst->w + 1) * sizeof(Uint32))) == NULL) {
+	return (-1);
+}
+if ((say = (int *) malloc((dst->h + 1) * sizeof(Uint32))) == NULL) {
+	free(sax);
+	return (-1);
+}
+
+/*
+ * Precalculate row increments 
+ */
+sp = csp = (tColorRGBA *) src->pixels;
+dp = (tColorRGBA *) dst->pixels;
+
+if (flipx) csp += (src->w-1);
+if (flipy) csp  = (tColorRGBA*)( (Uint8*)csp + src->pitch*(src->h-1) );
+
+csx = 0;
+csax = sax;
+for (x = 0; x <= dst->w; x++) {
+	*csax = csx;
+	csax++;
+	csx &= 0x;
+	csx += sx;
+}
+csy = 0;
+csay = say;
+for (y = 0; y <= dst->h; y++) {
+	*csay = csy;
+	csay++;
+	csy &= 0x;
+	csy += sy;
+}
+
+dgap = dst->pitch - dst->w * 4;
+
+

[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2007-01-20 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [cproc - Mi 20. Dez 2006, 12:01:14]:
> 
> > [dmarks - Mi 20. Dez 2006, 01:18:32]:
> > 
> > On 12/20/06, Christian Prochaska <[EMAIL PROTECTED]>
> > wrote:
> > >
> > > So it seems there is a problem with antialiased zooming. Does the
> > > attached patch make the other missing images visible?
> > >
> > 
> > It does, yes. Am I missing some component in my SDL installation?
> 
> No, the zoom code is part of the SDL client and as it seems Rafal put a
> lot of effort into optimizing it for speed, but apparently at the cost
> of portability. I'll try to add the hopefully more portable zoom
> function from SDL_gfx as an alternative for platforms where the
> optimized version doesn't work.
> 

Does it work with the attached patch? It adds two new source files, so
you need to rerun autogen.sh before compiling.

Index: client/gui-sdl/gui_zoom.c
===
--- client/gui-sdl/gui_zoom.c	(Revision 12506)
+++ client/gui-sdl/gui_zoom.c	(Arbeitskopie)
@@ -56,6 +56,8 @@
 
 #include 
 
+#include "SDL_rotozoom.h"
+
 /* gui-sdl */
 #include "graphics.h"
 
@@ -2246,6 +2248,7 @@
 
 #define VALUE_LIMIT	0.001
 
+#ifndef __MACOS__
 /**
   zoomSurfaceSize( ... )
   Calculate new width and height from the scaling factors
@@ -2270,6 +2273,7 @@
   *pNew_width = MAX(*pNew_width, 1);
   *pNew_height = MAX(*pNew_height, 1);
 }
+#endif
 
 /* == */
 /* === Public Functions = */
@@ -2293,11 +2297,17 @@
 SDL_Surface *ZoomSurface(const SDL_Surface * pSrc, double zoomx,
 			 double zoomy, int smooth)
 {
+#ifdef __MACOS__
+  /* use SDL_gfx's more portable zoom function on MacOS to avoid crash */
+  return zoomSurface((SDL_Surface*)pSrc, zoomx, zoomy, smooth);
+#else
   int dstwidth, dstheight;
+  
   /* Get size if target */
   ZoomSurfaceSize(pSrc->w, pSrc->h, zoomx, zoomy, &dstwidth, &dstheight);
   return ResizeSurface(pSrc, (Uint16) dstwidth, (Uint16) dstheight,
 		   smooth);
+#endif
 }
 
 /**
@@ -2326,6 +2336,13 @@
 return NULL;
   }
   
+#ifdef __MACOS__
+  /* use SDL_gfx's more portable zoom function on MacOS to avoid crash */
+  double zoomx = (double)new_width / pSrc->w;
+  double zoomy = (double)new_height / pSrc->h;
+  return zoomSurface((SDL_Surface*)pSrc, zoomx, zoomy, smooth);
+#endif  
+  
   /*
* Alloc space to completely contain the zoomed surface 
*/
Index: client/gui-sdl/SDL_rotozoom.c
===
--- client/gui-sdl/SDL_rotozoom.c	(Revision 0)
+++ client/gui-sdl/SDL_rotozoom.c	(Revision 0)
@@ -0,0 +1,972 @@
+/*  
+
+  SDL_rotozoom.c - rotozoomer for 32bit or 8bit surfaces
+
+  LGPL (c) A. Schiffler
+
+*/
+
+#ifdef WIN32
+#include 
+#endif
+
+#include 
+#include 
+
+#include "SDL_rotozoom.h"
+
+#define MAX(a,b)(((a) > (b)) ? (a) : (b))
+
+/* 
+ 
+ 32bit Zoomer with optional anti-aliasing by bilinear interpolation.
+
+ Zoomes 32bit RGBA/ABGR 'src' surface to 'dst' surface.
+ 
+*/
+
+static int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int flipx, int flipy, int smooth)
+{
+int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy, ex, ey, t1, t2, sstep;
+tColorRGBA *c00, *c01, *c10, *c11;
+tColorRGBA *sp, *csp, *dp;
+int dgap;
+
+/*
+ * Variable setup 
+ */
+if (smooth) {
+	/*
+	 * For interpolation: assume source dimension is one pixel 
+	 */
+	/*
+	 * smaller to avoid overflow on right and bottom edge. 
+	 */
+	sx = (int) (65536.0 * (float) (src->w - 1) / (float) dst->w);
+	sy = (int) (65536.0 * (float) (src->h - 1) / (float) dst->h);
+} else {
+	sx = (int) (65536.0 * (float) src->w / (float) dst->w);
+	sy = (int) (65536.0 * (float) src->h / (float) dst->h);
+}
+
+/*
+ * Allocate memory for row increments 
+ */
+if ((sax = (int *) malloc((dst->w + 1) * sizeof(Uint32))) == NULL) {
+	return (-1);
+}
+if ((say = (int *) malloc((dst->h + 1) * sizeof(Uint32))) == NULL) {
+	free(sax);
+	return (-1);
+}
+
+/*
+ * Precalculate row increments 
+ */
+sp = csp = (tColorRGBA *) src->pixels;
+dp = (tColorRGBA *) dst->pixels;
+
+if (flipx) csp += (src->w-1);
+if (flipy) csp  = (tColorRGBA*)( (Uint8*)csp + src->pitch*(src->h-1) );
+
+csx = 0;
+csax = sax;
+for (x = 0; x <= dst->w; x++) {
+	*csax = csx;
+	csax++;
+	csx &= 0x;
+	csx += sx;
+}
+csy = 0;
+csay = say;
+for (y = 0; y <= dst->h; y++) {
+	*csay = csy;
+	csay++;
+	csy &= 0x;
+	csy += sy;
+}
+
+dgap = dst->pitch - dst->w * 4;
+
+/*
+ * Switch between interpolating and non-interpolating code 
+ */
+if (smooth) {
+
+	/*
+	 * Interpolating Zoom 
+	 */
+
+	/*
+	 * Scan destination 
+	 */
+	csay =

[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-31 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - Sa 23. Dez 2006, 04:45:07]:
> 
> On 12/22/06, Christian Prochaska <[EMAIL PROTECTED]> wrote:
> >
> > http://bugs.freeciv.org/Ticket/Display.html?id=29557 >
> >
> > > [cproc - Fr 22. Dez 2006, 04:32:52]:
> > >
> > > You can compile it with
> > > "gcc `pkg-config --cflags sdl` `pkg-config --libs sdl`
> > > -o sdl-crashtest sdl-crashtest.c"
> > >
> >
> > Or better use sdl-config instead of pkg-config:
> >
> > "gcc `sdl-config --cflags` `sdl-config --libs` -o sdl-crashtest
> > sdl-crashtest.c"
> >
> 
> It fails with:
> 
> sdl-crashtest.c: In function `SDL_main':
> sdl-crashtest.c:4: error: number of arguments doesn't match prototype
> /usr/local/include/SDL/SDL_main.h:53: error: prototype declaration
> 
> --Daniel
> 

Ok, this one should compile.



sdl-crashtest.c
Description: Binary data
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [cproc - Fr 22. Dez 2006, 04:32:52]:
> 
> You can compile it with
> "gcc `pkg-config --cflags sdl` `pkg-config --libs sdl`
> -o sdl-crashtest sdl-crashtest.c"
> 

Or better use sdl-config instead of pkg-config: 

"gcc `sdl-config --cflags` `sdl-config --libs` -o sdl-crashtest
sdl-crashtest.c"

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - Do 21. Dez 2006, 01:23:50]:
> 
> This was the last output before the crash:
> 
> 2: clear_surface(0x1547790, 0x15b1358)
> 2: clear_surface() finished
> Segmentation fault
> 
> It's worth noting that the crash doesn't occur when switching from
> fullscreen 1024x768 to windowed 1024x768. However, now the client
> defaults to windowed 1024x768 and crashes upon startup:
> 
> ibg3:~ daniel$ ./freeciv-sdl/bin/civclient
> 2: Using Video Output: Quartz
> 2: clear_surface(0x1556820, 0x0)
> 2: clear_surface() finished
> 2: clear_surface(0x1556820, 0x0)
> 2: clear_surface() finished
> 2: clear_surface(0x15a1fc0, 0x0)
> 2: clear_surface() finished
> 2: clear_surface(0x159a120, 0x0)
> 2: clear_surface() finished
> 2: clear_surface(0x15ae2a0, 0x0)
> 2: clear_surface() finished
> Segmentation fault
> 

Seems like it crashes in the SDL_SetVideoMode() function in SDL. Some
googling found a similar bug report for Wesnoth:
http://www.wesnoth.org/forum/viewtopic.php?t=3231&start=0&postdays=0&postorder=asc&highlight=

Does the attached little program also crash? You can compile it with
"gcc `pkg-config --cflags sdl` `pkg-config --libs sdl` -o sdl-crashtest
sdl-crashtest.c"

#include 
#include 

int main() {

  if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("SDL_Init() failed.\n");
exit(1);
  }

  if (SDL_SetVideoMode(0, 0, 0, SDL_SWSURFACE | SDL_ANYFORMAT | SDL_RESIZABLE) < 0) {
printf("SDL_SetVideoMode() failed.\n");
exit(1);
  }

  printf("Video mode change successful.\n");

  return 0;
}
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-21 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - Do 21. Dez 2006, 01:23:50]:
> 
> 
> Can I change the resolution with a command line parameter or something
> like that?
> 

You can start the client in fullscreen mode with the "-- -f" parameter
or change the resolution in .civclientrc ("gui_sdl_fullscreen_width" and
"gui_sdl_fullscreen_height").


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-20 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - Mi 20. Dez 2006, 01:18:32]:
> 
> On 12/20/06, Christian Prochaska <[EMAIL PROTECTED]>
> wrote:
> >
> > So it seems there is a problem with antialiased zooming. Does the
> > attached patch make the other missing images visible?
> >
> 
> It does, yes. Am I missing some component in my SDL installation?

No, the zoom code is part of the SDL client and as it seems Rafal put a
lot of effort into optimizing it for speed, but apparently at the cost
of portability. I'll try to add the hopefully more portable zoom
function from SDL_gfx as an alternative for platforms where the
optimized version doesn't work.

> > > > The SDL client crashes semi-randomly on Mac OS X (10.3.9), but there
> > > > is one segfault that is 100% reproducible: Go to 'video options' and
> > > > chose 1024x768 (max res on my machine) without first selecting 'full
> > > > screen' = immediate segfault. (The resolution works fine in full
> > > > screen tho'.)
> > > >
> > >
> > > can you please send a backtrace?
> > >
> >
> > In the works! (How to figure out how to do it on this machine.)
> >
> 
> This is what I got:
> 
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> 0x00447438 in SDL_FillRect (dst=0xc36200, dstrect=0xc36220, color=0)
> at src/video/SDL_surface.c:610
> 610 src/video/SDL_surface.c: No such file or directory.
> in src/video/SDL_surface.c
> 
> 
> Hope it helps!
> 
> ––Daniel
> 

At least it tells us that the crash happened while trying to fill a
surface with transparency/black color. Unfortunately it doesn't tell us
where exactly the SDL_FillRect() function was called. Can you please
apply the attached patch and post the console output?

Index: client/gui-sdl/graphics.c
===
--- client/gui-sdl/graphics.c	(Revision 12428)
+++ client/gui-sdl/graphics.c	(Arbeitskopie)
@@ -396,13 +396,22 @@
   the per pixel alpha
 **/
 int clear_surface(SDL_Surface *pSurf, SDL_Rect *dstrect) {
-  /* SDL_FillRect might change the rectangle, so we create a copy */
+
+  int result;
+
+  freelog(LOG_NORMAL, "clear_surface(%p, %p)", pSurf, dstrect);
+
   if (dstrect) {
+/* SDL_FillRect might change the rectangle, so we create a copy */
 SDL_Rect _dstrect = *dstrect;
-return SDL_FillRect(pSurf, &_dstrect, SDL_MapRGBA(pSurf->format, 0, 0, 0, 0));
+result = SDL_FillRect(pSurf, &_dstrect, SDL_MapRGBA(pSurf->format, 0, 0, 0, 0));
   } else {
-return SDL_FillRect(pSurf, NULL, SDL_MapRGBA(pSurf->format, 0, 0, 0, 0));
+result = SDL_FillRect(pSurf, NULL, SDL_MapRGBA(pSurf->format, 0, 0, 0, 0));
   }
+  
+  freelog(LOG_NORMAL, "clear_surface() finished");
+  
+  return result;
 }
 
 /**
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-19 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - Di 19. Dez 2006, 03:15:32]:
> 
> One more graphics bug: The wrong building icon is sometimes shown in
> the science dialog. See attached screen.
> 

Patch attached.

Index: client/gui-sdl/repodlgs.c
===
--- client/gui-sdl/repodlgs.c	(Revision 12428)
+++ client/gui-sdl/repodlgs.c	(Arbeitskopie)
@@ -2351,7 +2351,7 @@
   pImpr = get_improvement_type(imp);
 		
   requirement_vector_iterate(&pImpr->reqs, preq) {
-if (preq->source.value.tech == tech_id) {
+if ((preq->source.type == REQ_TECH) && (preq->source.value.tech == tech_id)) {
   pTmp2 = get_building_surface(imp);
   Surf_Array[w++] = ZoomSurface(pTmp2, DEFAULT_ZOOM * ((float)36 / pTmp2->w), DEFAULT_ZOOM * ((float)36 / pTmp2->w), 1);
   }
@@ -2598,7 +2598,7 @@
   pImpr = get_improvement_type(imp);
 		
   requirement_vector_iterate(&pImpr->reqs, preq) {
-if (preq->source.value.tech == get_player_research(game.player_ptr)->researching) {		  
+if ((preq->source.type == REQ_TECH) && (preq->source.value.tech == get_player_research(game.player_ptr)->researching)) {
   pSurf = adj_surf(get_building_surface(imp));
   alphablit(pSurf, NULL, pWindow->dst->surface, &dest);
   dest.x += pSurf->w + 1;
@@ -2675,7 +2675,7 @@
   impr_type_iterate(imp) {
 pImpr = get_improvement_type(imp);
 	requirement_vector_iterate(&pImpr->reqs, preq) {  
-  if (preq->source.value.tech == get_player_research(game.player_ptr)->tech_goal) {			
+  if ((preq->source.type == REQ_TECH) && (preq->source.value.tech == get_player_research(game.player_ptr)->tech_goal)) {
 pSurf = adj_surf(get_building_surface(imp));
 alphablit(pSurf, NULL, pWindow->dst->surface, &dest);
 dest.x += pSurf->w + 1;
Index: client/gui-sdl/helpdlg.c
===
--- client/gui-sdl/helpdlg.c	(Revision 12428)
+++ client/gui-sdl/helpdlg.c	(Arbeitskopie)
@@ -1099,7 +1099,7 @@
  * Currently it's limited to 1 req. Remember MAX_NUM_REQS is a compile-time
  * definition. */
 requirement_vector_iterate(&(get_improvement_type(imp)->reqs), preq) {
-  if (preq->source.value.tech == tech) {
+  if ((preq->source.type == REQ_TECH) && (preq->source.value.tech == tech)) {
 pSurf = get_building_surface(imp);
 pBuf = create_iconlabel_from_chars(
 ZoomSurface(pSurf, DEFAULT_ZOOM * ((float)36 / pSurf->w), DEFAULT_ZOOM * ((float)36 / pSurf->w), 1),
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-19 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - Di 19. Dez 2006, 03:15:32]:
> 
> > > Other graphical irregularities includes:
> > > -The national flag to the upper right in the pregame nation selection
> > > screen only appear once. As soon as you select another nation, it
> > > disappears.
> > > -Building icons are missing from the city production screen.
> > > -National flags are missing from the players screen.
> > >
> >
> > does the attached patch fix the problem in the nation selection dialog?
> >
> 
> It does indeed!
> 

So it seems there is a problem with antialiased zooming. Does the
attached patch make the other missing images visible?

> BTW, can you re-inplement science icons for SDL since we have a full
> GPLed set now!
> 

The tech icons are still being used by the client if they are available.
I just tried and copied the techs.png and techs.spec into data/misc and
uncommented the corresponding line in amplio.tilespec and then the icons
were shown.

Index: client/gui-sdl/gui_zoom.c
===
--- client/gui-sdl/gui_zoom.c	(Revision 12428)
+++ client/gui-sdl/gui_zoom.c	(Arbeitskopie)
@@ -2319,6 +2319,8 @@
   SDL_Surface *pReal_dst, *pBuf_Src = (SDL_Surface *) pSrc;
   int i;
 
+  smooth = 0;
+
   /*
* Sanity check 
*/
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-18 Thread Christian Prochaska

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

> [dmarks - Sa 16. Dez 2006, 11:25:45]:
> 
> The SDL client crashes semi-randomly on Mac OS X (10.3.9), but there
> is one segfault that is 100% reproducible: Go to 'video options' and
> chose 1024x768 (max res on my machine) without first selecting 'full
> screen' = immediate segfault. (The resolution works fine in full
> screen tho'.)
> 

can you please send a backtrace?

> Other graphical irregularities includes:
> -The national flag to the upper right in the pregame nation selection
> screen only appear once. As soon as you select another nation, it
> disappears.
> -Building icons are missing from the city production screen.
> -National flags are missing from the players screen.
> 

does the attached patch fix the problem in the nation selection dialog?

Index: client/gui-sdl/dialogs.c
===
--- client/gui-sdl/dialogs.c	(Revision 12428)
+++ client/gui-sdl/dialogs.c	(Arbeitskopie)
@@ -2556,17 +2556,13 @@
 **/
 static void change_nation_label(void)
 {
-  SDL_Surface *pTmp_Surf, *pTmp_Surf_zoomed;
   struct widget *pWindow = pNationDlg->pEndWidgetList;
   struct NAT *pSetup = (struct NAT *)(pWindow->data.ptr);  
   struct widget *pLabel = pSetup->pName_Edit->next;
   struct nation_type *pNation = get_nation_by_idx(pSetup->nation);
 
-  pTmp_Surf = get_nation_flag_surface(get_nation_by_idx(pSetup->nation));
-  pTmp_Surf_zoomed = ZoomSurface(pTmp_Surf, DEFAULT_ZOOM * 1.0, DEFAULT_ZOOM * 1.0, 1);  
-
   FREESURFACE(pLabel->theme);
-  pLabel->theme = pTmp_Surf_zoomed;
+  pLabel->theme = adj_surf(get_nation_flag_surface(get_nation_by_idx(pSetup->nation)));
   
   copy_chars_to_string16(pLabel->string16, Q_(pNation->name_plural));
   
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#29557) segfault with SDL client on Mac OS X

2006-12-16 Thread Daniel Markstedt

http://bugs.freeciv.org/Ticket/Display.html?id=29557 >

The SDL client crashes semi-randomly on Mac OS X (10.3.9), but there
is one segfault that is 100% reproducible: Go to 'video options' and
chose 1024x768 (max res on my machine) without first selecting 'full
screen' = immediate segfault. (The resolution works fine in full
screen tho'.)

Other graphical irregularities includes:
-The national flag to the upper right in the pregame nation selection
screen only appear once. As soon as you select another nation, it
disappears.
-Building icons are missing from the city production screen.
-National flags are missing from the players screen.


Otherwise, the SDL client runs beautifully on OSX and does not require
sluggish Apple X11. It seems to run somewhat swifter than GTK2 on my
ancient iBook G3!

--Daniel



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev