Commits

Anonymous committed 43748ac

aaline fixes and more

Comments (0)

Files changed (6)

 July 17, 2004
     SysFont extra styles being applied incorrect
     psuedo "configure" and "Makefile" for foolproof installs
+    draw.aaline now works with pixel alphas
 
 July 16, 2004
     mixer.set_num_channels() no longer crashes [BUG]
 
 configcommand = os.environ.get('SDL_CONFIG', 'sdl-config',)
 configcommand = configcommand + ' --version --cflags --libs'
-localbase = os.environ.get('LOCALBASE', '') #do we still need this?
+localbase = os.environ.get('LOCALBASE', '')
+
+#these get prefixes with '/usr' and '/usr/local' or the $LOCALBASE
+origincdirs = ['/include', '/include/SDL', '/include/SDL11',
+               'include/smpeg' ]
+origlibdirs = ['/lib']
 
 
 
         if self.found and self.header:
             fullpath = os.path.join(get_python_inc(0), self.header)
             if not os.path.isfile(fullpath):
-                found = 0
+                self.found = 0
             else:
                 self.inc_dir = os.path.split(fullpath)[0]
         if self.found:
 
 sdl_lib_name = 'SDL'
 if sys.platform.find('bsd') != -1:
-    sdl_lib_name = 'SDL-1.2'
+    sdl_lib_name = 'SDL-1.1'
 
 
 def main():
         print 'Unable to run "sdl-config". Please make sure a development version of SDL is installed.'
         raise SystemExit
 
-    incdirs = ['/usr/include', '/include']
-    libdirs = ['/usr/lib', '/lib']
-    if localbase: #unneeded?
-        incdirs = [localbase + '/include/SDL']
-        libdirs = [localbase + '/lib']
+    if localbase:
+        incdirs = [localbase+d for d in origincdirs]
+        libdirs = [localbase+d for d in origlibdirs]
+    incdirs = ["/usr"+d for d in origincdirs]
+    libdirs = ["/usr"+d for d in origlibdirs]
+    incdirs += ["/usr/local"+d for d in origincdirs]
+    libdirs += ["/usr/local"+d for d in origlibdirs]
     for arg in string.split(DEPS[0].cflags):
         if arg[:2] == '-I':
             incdirs.append(arg[2:])
 
 
 /* macros used to create each constant */
-#define DEC_CONST(x)  PyModule_AddIntConstant(module, #x, SDL_##x);
-#define DEC_CONSTK(x) PyModule_AddIntConstant(module, #x, SDL##x);
-#define DEC_CONSTN(x) PyModule_AddIntConstant(module, #x, x);
+#define DEC_CONST(x)  PyModule_AddIntConstant(module, #x, (int) SDL_##x);
+#define DEC_CONSTK(x) PyModule_AddIntConstant(module, #x, (int) SDL##x);
+#define DEC_CONSTN(x) PyModule_AddIntConstant(module, #x, (int) x);
 
 
 static PyMethodDef builtins[] =
     /*DOC*/    "KMOD_ALT, KMOD_LMETA, KMOD_RMETA, KMOD_META, KMOD_NUM, KMOD_MODE<br>\n"
     /*DOC*/ ;
 
-    /*DOC*/ static char doc_zdeprecated[] =
-    /*DOC*/    "pygame.constants.zdepracated (constants)\n"
-    /*DOC*/    "The following constants are made available, but generally not needed\n"
-    /*DOC*/    "\n"
-    /*DOC*/    "The flags labeled as readonly should never be used,\n"
-    /*DOC*/    "except when comparing checking flags against Surface.get_flags().\n"
-    /*DOC*/    "\n"
-    /*DOC*/    "SWSURFACE - not really usable as a surface flag, equates to 0 and\n"
-    /*DOC*/    "is always default<br>\n"
-    /*DOC*/    "ANYFORMAT - creates a display with in best possible bit depth<br>\n"
-    /*DOC*/    "HWACCEL - surface is hardware accelerated, readonly<br>\n"
-    /*DOC*/    "SRCCOLORKEY- surface has a colorkey for blits, readonly<br>\n"
-    /*DOC*/    "SRCALPHA - surface has alpha enabled, readonly<br>\n"
-    /*DOC*/    "RLEACCELOK - surface is rle accelrated but uncompiled, readonly\n"
-    /*DOC*/ ;
-
-
 #endif
 static PyObject* set_mode(PyObject* self, PyObject* arg)
 {
 	SDL_Surface* surf;
-	int flags = SDL_SWSURFACE, depth = 0;
+	int depth = 0;
+        int flags = SDL_SWSURFACE;
 	int w, h, hasbuf;
 	char *title, *icontitle;
 
 
 static PyObject* mode_ok(PyObject* self, PyObject* args)
 {
-	int flags=SDL_SWSURFACE, depth=0;
+	int depth=0;
 	int w, h;
+        int flags = SDL_SWSURFACE;
 
 	VIDEO_INIT_CHECK();
 
 #include "pygame.h"
 #include <math.h>
 
+#if !defined(__FreeBSD_version) || __FreeBSD_version < 502119
 #ifdef _MSC_VER
 #pragma warning (disable:4244)
 
 }
 
 #endif
+#endif
+
 
 #define FRAC(z) (z-trunc(z))
 #define INVFRAC(z) (1-(z-trunc(z)))
 
 #define DRAWPIX32(pixel,colorptr,br,blend) \
 	if(SDL_BYTEORDER == SDL_BIG_ENDIAN) color <<= 8; \
-	if(blend) { \
-		int x; \
-		x = colorptr[0]*br+pixel[0]; \
-		pixel[0]= (x>254) ? 255: x; \
-		x = colorptr[1]*br+pixel[1]; \
-		pixel[1]= (x>254) ? 255: x; \
-		x = colorptr[2]*br+pixel[2]; \
-		pixel[2]= (x>254) ? 255: x; \
-	} else { \
-		pixel[0]=(Uint8)(colorptr[0]*br); \
-		pixel[1]=(Uint8)(colorptr[1]*br); \
-		pixel[2]=(Uint8)(colorptr[2]*br); \
-	}
+        if(blend) { \
+                int x; \
+                x = colorptr[0]*br+pixel[0]; \
+                pixel[0]= (x>254) ? 255: x; \
+                x = colorptr[1]*br+pixel[1]; \
+                pixel[1]= (x>254) ? 255: x; \
+                x = colorptr[2]*br+pixel[2]; \
+                pixel[2]= (x>254) ? 255: x; \
+                if(hasalpha) pixel[3] = pixel[0]+(br*255) - (pixel[3]*br); \
+        } else { \
+                pixel[0]=(Uint8)(colorptr[0]*br); \
+                pixel[1]=(Uint8)(colorptr[1]*br); \
+                pixel[2]=(Uint8)(colorptr[2]*br); \
+                if(hasalpha) pixel[3] = br*255; \
+	} 
 
 /* Adapted from http://freespace.virgin.net/hugo.elias/graphics/x_wuline.htm */
 static void drawaaline(SDL_Surface* surf, Uint32 color, float x1, float y1, float x2, float y2, int blend) {
 	Uint8* pixel;
 	Uint8* pm = (Uint8*)surf->pixels;
 	Uint8* colorptr = (Uint8*)&color;
+        const int hasalpha = surf->format->Amask;
 
-	pixx = surf->format->BytesPerPixel;
+        pixx = surf->format->BytesPerPixel;
 	pixy = surf->pitch;
 
 	xd = x2-x1;
 	return PyString_FromString(str);
 }
 
+
+
 #if 0
     /*DOC*/ static char doc_Surface_MODULE[] =
     /*DOC*/    "Surface objects represent a simple memory buffer of pixels.\n"
     /*DOC*/    "For a plain software surface, 0 can be used for the flag. \n"
     /*DOC*/    "A plain hardware surface can just use 1 for the flag.\n"
     /*DOC*/ ;
-
-
+   
 static PyTypeObject PySurface_Type =
 {
 	PyObject_HEAD_INIT(NULL)
 	0,                              /*itemsize*/
 	surface_dealloc,                /*dealloc*/
 	0,                              /*print*/
-	NULL/*surface_getattr*/,		/*getattr*/
+	NULL,		/*getattr*/
 	NULL,                           /*setattr*/
 	NULL,                           /*compare*/
 	surface_str,			/*repr*/
 	(hashfunc)NULL, 		/*hash*/
 	(ternaryfunc)NULL,		/*call*/
 	(reprfunc)NULL, 		/*str*/
-	0L,0L,0L,
+	0,
+        0L,0L,
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 	doc_Surface, /* Documentation string */
 	0,					/* tp_traverse */
 	0,					/* tp_iternext */
 	surface_methods,			/* tp_methods */
 	0,					/* tp_members */
-	0,					/* tp_getset */
+	0,				/* tp_getset */
 	0,					/* tp_base */
 	0,					/* tp_dict */
 	0,					/* tp_descr_get */
 	PyObject *module, *dict, *apiobj, *lockmodule;
 	static void* c_api[PYGAMEAPI_SURFACE_NUMSLOTS];
 
-	PyType_Init(PySurface_Type);
         if (PyType_Ready(&PySurface_Type) < 0)
             return;
-
+        
     /* create the module */
 	module = Py_InitModule3("surface", surface_builtins, doc_pygame_surface_MODULE);
 	dict = PyModule_GetDict(module);
 	apiobj = PyCObject_FromVoidPtr(c_api, NULL);
 	PyDict_SetItemString(dict, PYGAMEAPI_LOCAL_ENTRY, apiobj);
 	Py_DECREF(apiobj);
+        Py_INCREF(PySurface_Type.tp_dict);
+        PyDict_SetItemString(dict, "_dict", PySurface_Type.tp_dict);
+        
 	/*imported needed apis*/
 	import_pygame_base();
 	import_pygame_rect();