Commits

Anonymous committed 19da6dc

Added sdlgfx.primitives example.
Added sdlgfx.primitives.aaline() method for drawing anti-aliased lines.
Fixed minor C API test issues.
Fixed sdlgfx.primitives cast overflow bugs.

Comments (0)

Files changed (9)

   WITH_PORTMIDI=[yes|no|1|True]           Example: make -DWITH_PORTMIDI=False
 
 Build and install the :mod:`pygame2.pypm` and :mod:`pygame2.midi` modules. This
-wraps the portmidi library and gives access to the :mod:`pygame2.midi` module.
+wraps the portmidi library and gives access to the :mod:`pygame2.midi`
+module. ::
 
   WITH_OPENAL=[yes|no|1|True]             Example: make -DWITH_OPENAL=False
     

doc/src/examples.rst

 | pygame2.examples.sdl.hello_world   | The almighty "Hello World" example     |
 |                                    | using the :mod:`pygame2.sdl` module.   |
 +------------------------------------+----------------------------------------+
+| pygame2.examples.sdl.joystick      | Demonstrates joystick input and event  |
+|                                    | handling for the                       |
+|                                    | :mod:`pygame2.sdl.joystick` module.    |
++------------------------------------+----------------------------------------+
 | pygame2.examples.sdl.keyboard      | Demonstrates keyboard input and event  |
 |                                    | handling for the                       |
 |                                    | :mod:`pygame2.sdl.keyboard` module.    |
 |                                    | :class:`pygame2.sdlext.PixelArray`     |
 |                                    | class.                                 |
 +------------------------------------+----------------------------------------+
+| pygame2.examples.sdlgfx.fpsmanager | Demonstrates the features of the       |
+|                                    | :class:`pygame2.sdlgfx.FPSmanager`     |
+|                                    | class.                                 |
++------------------------------------+----------------------------------------+
+| pygame2.examples.sdlgfx.primitives | Demonstrates the features of the       |
+|                                    | :class:`pygame2.sdlgfx.primitives`     |
+|                                    | module.                                 |
++------------------------------------+----------------------------------------+

doc/src/sdlgfxprimitives.xml

       ellipse, *rx*, *ry* the radius for the x- and y-axis.
     </desc>
   </func>
+  <func name="aaline">
+    <call>aaline (surface, x1, y1, x2, y2, color) -> None
+    aaline (surface, point1, point2, color) -> None</call>
+    <desc>Draws an anti-aliased line on a surface.
+    
+      Draws an anti-aliased line on a *surface* with a fixed width of
+      1px. *x1*, *y1* and *x2*, *y2* denote the start and end position
+      of the line.
+    </desc>
+  </func>
   <func name="aapolygon">
     <call>aapolygon (surface, (point1, point2, ...), color) -> None</call>
     <desc>Draws an anti-aliased polygonal shape on a surface.

examples/sdlgfx/primitives.py

+import sys
+import pygame2
+try:
+    import pygame2.sdl.constants as sdlconst
+    import pygame2.sdl.event as event
+    import pygame2.sdl.video as video
+    import pygame2.sdl.wm as wm
+except ImportError:
+    print ("No pygame2.sdl support")
+    sys.exit ()
+
+try:
+    import pygame2.sdlgfx.primitives as primitives
+except ImportError:
+    print ("No pygame2.sdlgfx support")
+    sys.exit ()
+
+white = pygame2.Color (255, 255, 255)
+black = pygame2.Color (0, 0, 0)
+red = pygame2.Color (255, 0, 0)
+green = pygame2.Color (0, 255, 0)
+blue = pygame2.Color (0, 0, 255)
+
+def draw_aacircle (screen):
+    wm.set_caption ("primitives.aacircle examples")
+    primitives.aacircle (screen, (100, 200), 45, black)
+    primitives.aacircle (screen, (200, 160), 80, red)
+    primitives.aacircle (screen, (370, 210), 100, green)
+    primitives.aacircle (screen, (400, 400), 45, blue)
+
+def draw_circle (screen):
+    wm.set_caption ("primitives.circle examples")
+    primitives.circle (screen, (100, 200), 45, black)
+    primitives.circle (screen, (200, 160), 80, red)
+    primitives.circle (screen, (370, 210), 100, green)
+    primitives.circle (screen, (400, 400), 45, blue)
+
+def draw_filledcircle (screen):
+    wm.set_caption ("primitives.filled_circle examples")
+    primitives.filled_circle (screen, (100, 200), 45, black)
+    primitives.filled_circle (screen, (200, 160), 80, red)
+    primitives.filled_circle (screen, (370, 210), 100, green)
+    primitives.filled_circle (screen, (400, 400), 45, blue)
+
+def draw_box (screen):
+    wm.set_caption ("primitves.box examples")
+    primitives.box (screen, pygame2.Rect (20, 20, 100, 100), black)
+    primitives.box (screen, pygame2.Rect (160, 100, 160, 60), red)
+    primitives.box (screen, pygame2.Rect (180, 190, 180, 200), green)
+    primitives.box (screen, pygame2.Rect (390, 120, 200, 140), blue)
+
+def draw_rectangle (screen):
+    wm.set_caption ("primitves.rectangle examples")
+    primitives.rectangle (screen, pygame2.Rect (20, 20, 100, 100), black)
+    primitives.rectangle (screen, pygame2.Rect (160, 100, 160, 60), red)
+    primitives.rectangle (screen, pygame2.Rect (180, 190, 180, 200), green)
+    primitives.rectangle (screen, pygame2.Rect (390, 120, 200, 140), blue)
+
+def draw_arc (screen):
+    wm.set_caption ("primitives.arc examples")
+    primitives.arc (screen, (80, 100), 75, 0, 30, black)
+    primitives.arc (screen, (100, 200), 123, 4, 70, red)
+    primitives.arc (screen, (300, 300), 78, 200, 30, green)
+    primitives.arc (screen, (400, 80), 55, 10, 360, blue)
+
+def draw_line (screen):
+    wm.set_caption ("primitives.line examples")
+    primitives.line (screen, 4, 40, 17, 320, black)
+    primitives.line (screen, 280, 7, 40, 220, red)
+    primitives.line (screen, 33, 237, 580, 370, green)
+    primitives.line (screen, 0, 0, 640, 480, blue)
+
+def draw_aaline (screen):
+    wm.set_caption ("primitives.aaline examples")
+    primitives.aaline (screen, 4, 40, 17, 320, black)
+    primitives.aaline (screen, 280, 7, 40, 220, red)
+    primitives.aaline (screen, 33, 237, 580, 370, green)
+    primitives.aaline (screen, 0, 0, 640, 480, blue)
+
+def draw_polygon (screen):
+    wm.set_caption ("primitives.polygon examples")
+    primitives.polygon (screen, ((4, 40), (280, 7), (40, 220),
+                                 (33, 237), (580, 370),
+                                 (0, 0), (640, 480)), black)
+
+def draw_aapolygon (screen):
+    wm.set_caption ("primitives.aapolygon examples")
+    primitives.aapolygon (screen, ((4, 40), (280, 7), (40, 220),
+                                   (33, 237), (580, 370),
+                                   (0, 0), (640, 480)), black)
+
+def draw_ellipse (screen):
+    wm.set_caption ("primitives.ellipse examnples")
+    primitives.ellipse (screen, 210, 400, 50, 50, black)
+    primitives.ellipse (screen, 160, 100, 80, 30, red)
+    primitives.ellipse (screen, 180, 190, 90, 100, green)
+    primitives.ellipse (screen, 390, 120, 100, 70, blue)
+
+def draw_aaellipse (screen):
+    wm.set_caption ("primitives.aaellipse examnples")
+    primitives.aaellipse (screen, 210, 400, 50, 50, black)
+    primitives.aaellipse (screen, 160, 100, 80, 30, red)
+    primitives.aaellipse (screen, 180, 190, 90, 100, green)
+    primitives.aaellipse (screen, 390, 120, 100, 70, blue)
+
+def draw_filledellipse (screen):
+    wm.set_caption ("primitives.filled_ellipse examnples")
+    primitives.filled_ellipse (screen, 210, 400, 50, 50, black)
+    primitives.filled_ellipse (screen, 160, 100, 80, 30, red)
+    primitives.filled_ellipse (screen, 180, 190, 90, 100, green)
+    primitives.filled_ellipse (screen, 390, 120, 100, 70, blue)
+
+def run ():
+    drawtypes = [ draw_aacircle, draw_circle, draw_filledcircle, draw_box,
+                  draw_rectangle, draw_arc, draw_line, draw_aaline,
+                  draw_polygon, draw_aapolygon, draw_ellipse, draw_aaellipse,
+                  draw_filledellipse
+                  ]
+    curtype = 0
+    video.init ()
+
+    screen = video.set_mode (640, 480, 32)
+    screen.fill (white)
+    draw_aacircle (screen)
+    screen.flip ()
+
+    okay = True
+    while okay:
+        for ev in event.get ():
+            if ev.type == sdlconst.QUIT:
+                okay = False
+            if ev.type == sdlconst.KEYDOWN and ev.key == sdlconst.K_ESCAPE:
+                okay = False
+            if ev.type == sdlconst.MOUSEBUTTONDOWN:
+                curtype += 1
+                if curtype >= len (drawtypes):
+                    curtype = 0
+                screen.fill (white)
+                drawtypes[curtype] (screen)
+                screen.flip ()
+    video.quit ()
+
+if __name__ == "__main__":
+    run ()

src/base/basemod.c

         PyErr_SetString (PyExc_TypeError, "argument is NULL");
         return 0;
     }
+
     
     if (PyNumber_Check (obj))
     {
     }
     else if (PySequence_Check (obj) && PySequence_Size (obj) >= 2)
     {
-        if (!IntFromSeqIndex (obj, 0, x))
+        if (!IntFromSeqIndex (obj, (Py_ssize_t)0, x))
             goto failed;
-        if (!IntFromSeqIndex (obj, 1, y))
+        if (!IntFromSeqIndex (obj, (Py_ssize_t)1, y))
             goto failed;
         return 1;
     }

src/openal/context.c

 static PyObject* _context_repr (PyObject *self);
 
 static PyObject* _context_makecurrent (PyObject *self);
+static PyObject* _context_iscurrent (PyObject* self, void *closure);
 
 /**
  */
 /**
  */
 static PyGetSetDef _context_getsets[] = {
+    { "is_current", _context_iscurrent, NULL, NULL, NULL },
     { NULL, NULL, NULL, NULL, NULL }
 };
 
     return Text_FromUTF8 ("<alcContext>");
 }
 
+/* Context getters/setters */
+static PyObject*
+_context_iscurrent (PyObject* self, void *closure)
+{
+    return PyBool_FromLong
+        (alcGetCurrentContext () == PyContext_AsContext (self));
+}
+
+
 /* Context methods */
 static PyObject*
 _context_makecurrent (PyObject *self)

src/sdlgfx/primitivesmod.c

 /*
   pygame - Python Game Library
-  Copyright (C) 2008 Marcus von Appen
+  Copyright (C) 2008-2010 Marcus von Appen
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
 */
 #define PYGAME_SDLGFXPRIM_INTERNAL
 
+#include "pgbase.h"
 #include "pgsdl.h"
 #include "pggfx.h"
 #include "surface.h"
 static PyObject* _gfx_vlinecolor (PyObject *self, PyObject* args);
 static PyObject* _gfx_rectanglecolor (PyObject *self, PyObject* args);
 static PyObject* _gfx_boxcolor (PyObject *self, PyObject* args);
+static PyObject* _gfx_aalinecolor (PyObject *self, PyObject* args);
 static PyObject* _gfx_linecolor (PyObject *self, PyObject* args);
 static PyObject* _gfx_circlecolor (PyObject *self, PyObject* args);
 static PyObject* _gfx_arccolor (PyObject *self, PyObject* args);
     { "rectangle", _gfx_rectanglecolor, METH_VARARGS,
       DOC_PRIMITIVES_RECTANGLE },
     { "box", _gfx_boxcolor, METH_VARARGS, DOC_PRIMITIVES_BOX },
+    { "aaline", _gfx_aalinecolor, METH_VARARGS, DOC_PRIMITIVES_AALINE },
     { "line", _gfx_linecolor, METH_VARARGS, DOC_PRIMITIVES_LINE },
     { "arc", _gfx_arccolor, METH_VARARGS, DOC_PRIMITIVES_ARC },
     { "circle", _gfx_circlecolor, METH_VARARGS, DOC_PRIMITIVES_CIRCLE },
 _gfx_pixelcolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt;
-    Sint16 x, y;
+    int x, y;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+        if (!PointFromObject (pt, &x, &y))
             return NULL;
     }
     
     if (!ColorFromObj (color, &c))
         return NULL;
 
-    if (pixelColor (((PySDLSurface*)surface)->surface, x, y, c) == -1)
+    if (pixelColor (((PySDLSurface*)surface)->surface, (Sint16)x, (Sint16)y, c)
+        == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_hlinecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color;
-    Sint16 x1, x2, y;
+    int x1, x2, y;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     c = (Uint32) PyColor_AsNumber (color);
     c = ARGB_2_RGBA (c);
 
-    if (hlineColor (((PySDLSurface*)surface)->surface, x1, x2, y, c) == -1)
+    if (hlineColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x1, (Sint16)x2, y, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_vlinecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color;
-    Sint16 x, _y1, y2;
+    int x, _y1, y2;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     c = (Uint32) PyColor_AsNumber (color);
     c = ARGB_2_RGBA (c);
 
-    if (vlineColor (((PySDLSurface*)surface)->surface, x, _y1, y2, c) == -1)
+    if (vlineColor (((PySDLSurface*)surface)->surface, (Sint16) x, (Sint16)_y1,
+            (Sint16)y2, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
     c = (Uint32) PyColor_AsNumber (color);
     c = ARGB_2_RGBA (c);
 
-    if (rectangleColor (((PySDLSurface*)surface)->surface, x1, x2,_y1, y2, c) ==
-        -1)
+    if (rectangleColor (((PySDLSurface*)surface)->surface, x1, _y1, x2, y2, c)
+        == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
     c = (Uint32) PyColor_AsNumber (color);
     c = ARGB_2_RGBA (c);
 
-    if (rectangleColor (((PySDLSurface*)surface)->surface, x1, x2,_y1, y2, c) ==
-        -1)
+    if (boxColor (((PySDLSurface*)surface)->surface, x1, _y1, x2, y2, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 }
 
 static PyObject*
-_gfx_linecolor (PyObject *self, PyObject* args)
+_gfx_aalinecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color;
     PyObject *p1, *p2;
-    Sint16 x1, x2, _y1, y2;
+    int x1, x2, _y1, y2;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OOOO:line", &surface, &p1, &p2, color))
+    if (!PyArg_ParseTuple (args, "OOOO:aaline", &surface, &p1, &p2, color))
     {
         PyErr_Clear ();
-        if (!PyArg_ParseTuple (args, "OiiiiO:line", &surface, &x1, &_y1,
+        if (!PyArg_ParseTuple (args, "OiiiiO:aaline", &surface, &x1, &_y1,
             &x2, &y2, &color))
         return NULL;
     }
     else
     {
-        if (!PointFromObject (p1, (int*)&x1, (int*)&_y1) ||
-            !PointFromObject (p2, (int*)&x2, (int*)&y2))
+        if (!PointFromObject (p1, &x1, &_y1) || !PointFromObject (p2, &x2, &y2))
             return NULL;
     }
     
     c = (Uint32) PyColor_AsNumber (color);
     c = ARGB_2_RGBA (c);
 
-    if (lineColor (((PySDLSurface*)surface)->surface, x1, _y1, x2, y2, c) == -1)
+    if (aalineColor (((PySDLSurface*)surface)->surface, 
+            (Sint16)x1, (Sint16)_y1, (Sint16)x2, (Sint16)y2, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 }
 
 static PyObject*
-_gfx_circlecolor (PyObject *self, PyObject* args)
+_gfx_linecolor (PyObject *self, PyObject* args)
 {
-    PyObject *surface, *color, *pt;
-    Sint16 x, y, r;
+    PyObject *surface, *color;
+    PyObject *p1, *p2;
+    int x1, x2, _y1, y2;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
 
-    if (!PyArg_ParseTuple (args, "OOiO:circle", &surface, &pt, &r, &color))
+    if (!PyArg_ParseTuple (args, "OOOO:line", &surface, &p1, &p2, color))
     {
         PyErr_Clear ();
-        if (!PyArg_ParseTuple (args, "OiiiO:circle", &surface, &x, &y, &r,
-            &color))
+        if (!PyArg_ParseTuple (args, "OiiiiO:line", &surface, &x1, &_y1,
+            &x2, &y2, &color))
         return NULL;
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+        if (!PointFromObject (p1, &x1, &_y1) || !PointFromObject (p2, &x2, &y2))
             return NULL;
     }
     
     c = (Uint32) PyColor_AsNumber (color);
     c = ARGB_2_RGBA (c);
 
-    if (circleColor (((PySDLSurface*)surface)->surface, x, y, r, c) == -1)
+    if (lineColor (((PySDLSurface*)surface)->surface, 
+            (Sint16)x1, (Sint16)_y1, (Sint16)x2, (Sint16)y2, c) == -1)
+    {
+        PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
+        return NULL;
+    }
+    Py_RETURN_NONE;
+}
+
+static PyObject*
+_gfx_circlecolor (PyObject *self, PyObject* args)
+{
+    PyObject *surface, *color, *pt;
+    int x, y, r;
+    Uint32 c;
+
+    ASSERT_VIDEO_INIT (NULL);
+
+    if (!PyArg_ParseTuple (args, "OOiO:circle", &surface, &pt, &r, &color))
+    {
+        PyErr_Clear ();
+        if (!PyArg_ParseTuple (args, "OiiiO:circle", &surface, &x, &y, &r,
+            &color))
+        return NULL;
+    }
+    else
+    {
+        if (!PointFromObject (pt, &x, &y))
+            return NULL;
+    }
+    
+    if (!PySDLSurface_Check (surface))
+    {
+        PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
+        return NULL;
+    }
+    if (!PyColor_Check (color))
+    {
+        PyErr_SetString (PyExc_TypeError, "color must be a Color");
+        return NULL;
+    }
+
+    c = (Uint32) PyColor_AsNumber (color);
+    c = ARGB_2_RGBA (c);
+
+    if (circleColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x, (Sint16)y, (Sint16)r, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_arccolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt;
-    Sint16 x, y, r, start, end;
+    int x, y, r, start, end;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+        if (!PointFromObject (pt, &x, &y))
             return NULL;
     }
 
     c = (Uint32) PyColor_AsNumber (color);
     c = ARGB_2_RGBA (c);
 
-    if (arcColor (((PySDLSurface*)surface)->surface, x, y, r, start, end, c)
-        == -1)
+    if (arcColor (((PySDLSurface*)surface)->surface, (Sint16)x, (Sint16)y,
+            (Sint16)r, (Sint16)start, (Sint16)end, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_aacirclecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt;
-    Sint16 x, y, r;
+    int x, y, r;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+        if (!PointFromObject (pt, &x, &y))
             return NULL;
     }
+
     if (!PySDLSurface_Check (surface))
     {
         PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
         return NULL;
     }
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
-    printf ("%x\n", c);
-/*    c = (Uint32) PyColor_AsNumber (color);
-      c = ARGB_2_RGBA (c);*/
-    if (aacircleColor (((PySDLSurface*)surface)->surface, x, y, r, c) == -1)
+    c = ARGB_2_RGBA (c);
+
+    if (aacircleColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x, (Sint16)y, (Sint16)r, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_filledcirclecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt;
-    Sint16 x, y, r;
+    int x, y, r;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     c = PyColor_AsNumber (color);
     c = ARGB_2_RGBA (c);
-    if (filledCircleColor (((PySDLSurface*)surface)->surface, x, y, r, c) == -1)
+
+    if (filledCircleColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x, (Sint16)y, (Sint16)r, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_ellipsecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt, *rd;
-    Sint16 x, y, rx, ry;
+    int x, y, rx, ry;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&x, (int*)&y) ||
-            !PointFromObject (rd, (int*)&rx, (int*)&ry))
+        if (!PointFromObject (pt, &x, &y) || !PointFromObject (rd, &rx, &ry))
             return NULL;
     }
     
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
-    if (ellipseColor (((PySDLSurface*)surface)->surface, x, y, rx, ry, c) == -1)
+    if (ellipseColor (((PySDLSurface*)surface)->surface, (Sint16)x, (Sint16)y,
+            (Sint16)rx, (Sint16)ry, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_aaellipsecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt, *rd;
-    Sint16 x, y, rx, ry;
+    int x, y, rx, ry;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&x, (int*)&y) ||
-            !PointFromObject (rd, (int*)&rx, (int*)&ry))
+        if (!PointFromObject (pt, &x, &y) || !PointFromObject (rd, &rx, &ry))
             return NULL;
     }
     
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
-    if (aaellipseColor (((PySDLSurface*)surface)->surface, x, y, rx, ry, c)
-        == -1)
+    if (aaellipseColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x, (Sint16)y, (Sint16)rx, (Sint16)ry, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_filledellipsecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt, *rd;
-    Sint16 x, y, rx, ry;
+    int x, y, rx, ry;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&x, (int*)&y) ||
-            !PointFromObject (rd, (int*)&rx, (int*)&ry))
+        if (!PointFromObject (pt, &x, &y) || !PointFromObject (rd, &rx, &ry))
             return NULL;
     }
 
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
-    if (filledEllipseColor (((PySDLSurface*)surface)->surface, x, y, rx, ry, c)
-        == -1)
+    if (filledEllipseColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x, (Sint16)y, (Sint16)rx, (Sint16)ry, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_piecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt;
-    Sint16 x, y, r, start, end;
+    int x, y, r, start, end;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&x, (int*)&y))
+        if (!PointFromObject (pt, &x, &y))
             return NULL;
     }
     if (!PySDLSurface_Check (surface))
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
-    if (pieColor (((PySDLSurface*)surface)->surface, x, y, r, start, end, c)
-        == -1)
+    if (pieColor (((PySDLSurface*)surface)->surface, (Sint16)x, (Sint16)y,
+            (Sint16)r, (Sint16)start, (Sint16)end, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_filledpiecolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *pt;
-    Sint16 x, y, r, start, end;
+    int x, y, r, start, end;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
-    if (filledPieColor (((PySDLSurface*)surface)->surface, x, y, r, start,
-            end, c) == -1)
+    if (filledPieColor (((PySDLSurface*)surface)->surface, (Sint16)x,
+            (Sint16)y, (Sint16)r, (Sint16)start, (Sint16)end, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_trigoncolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *p1, *p2, *p3;
-    Sint16 x1, x2, x3, _y1, y2, y3;
+    int x1, x2, x3, _y1, y2, y3;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (p1, (int*)&x1, (int*)&_y1) ||
-            !PointFromObject (p2, (int*)&x2, (int*)&y2) ||
-            !PointFromObject (p3, (int*)&x3, (int*)&y3))
+        if (!PointFromObject (p1, &x1, &_y1) ||
+            !PointFromObject (p2, &x2, &y2) ||
+            !PointFromObject (p3, &x3, &y3))
             return NULL;
     }
     
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
-    if (trigonColor (((PySDLSurface*)surface)->surface, x1, _y1, x2, y2, x3,
-            y3, c) == -1)
+    if (trigonColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x1, (Sint16)_y1, (Sint16)x2, (Sint16)y2,
+            (Sint16)x3, (Sint16)y3, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_aatrigoncolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *p1, *p2, *p3;
-    Sint16 x1, x2, x3, _y1, y2, y3;
+    int x1, x2, x3, _y1, y2, y3;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (p1, (int*)&x1, (int*)&_y1) ||
-            !PointFromObject (p2, (int*)&x2, (int*)&y2) ||
-            !PointFromObject (p3, (int*)&x3, (int*)&y3))
+        if (!PointFromObject (p1, &x1, &_y1) ||
+            !PointFromObject (p2, &x2, &y2) ||
+            !PointFromObject (p3, &x3, &y3))
             return NULL;
     }
     
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
-    if (aatrigonColor (((PySDLSurface*)surface)->surface, x1, _y1, x2, y2, x3,
-            y3, c) == -1)
+    if (aatrigonColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x1, (Sint16)_y1, (Sint16)x2, (Sint16)y2,
+            (Sint16)x3, (Sint16)y3, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_filledtrigoncolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *p1, *p2, *p3;
-    Sint16 x1, x2, x3, _y1, y2, y3;
+    int x1, x2, x3, _y1, y2, y3;
     Uint32 c;
 
     ASSERT_VIDEO_INIT (NULL);
     }
     else
     {
-        if (!PointFromObject (p1, (int*)&x1, (int*)&_y1) ||
-            !PointFromObject (p2, (int*)&x2, (int*)&y2) ||
-            !PointFromObject (p3, (int*)&x3, (int*)&y3))
+        if (!PointFromObject (p1, &x1, &_y1) ||
+            !PointFromObject (p2, &x2, &y2) ||
+            !PointFromObject (p3, &x3, &y3))
             return NULL;
     }
     
     }
 
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
-    if (filledTrigonColor (((PySDLSurface*)surface)->surface, x1, _y1, x2, y2,
-            x3, y3, c) == -1)
+    if (filledTrigonColor (((PySDLSurface*)surface)->surface,
+            (Sint16)x1, (Sint16)_y1, (Sint16)x2, (Sint16)y2,
+            (Sint16)x3, (Sint16)y3, c) == -1)
     {
         PyErr_SetString (PyExc_PyGameError, SDL_GetError ());
         return NULL;
 _gfx_polygoncolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *points, *item;
-    Sint16 *vx, *vy, x, y;
+    Sint16 *vx, *vy;
+    int tmp1, tmp2;
     Py_ssize_t count, i;
     int ret;
     Uint32 c;
         return NULL;
     }
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     vx = PyMem_New (Sint16, (size_t) count);
     vy = PyMem_New (Sint16, (size_t) count);
     for (i = 0; i < count; i++)
     {
         item = PySequence_ITEM (points, i);
-        if (!PointFromObject (item, (int*)&x, (int*)&y))
+        if (!PointFromObject (item, &tmp1, &tmp2))
         {
             PyMem_Free (vx);
             PyMem_Free (vy);
             return NULL;
         }
         Py_DECREF (item);
-        vx[i] = x;
-        vy[i] = y;
+        vx[i] = (Sint16)tmp1;
+        vy[i] = (Sint16)tmp2;
     }
 
     Py_BEGIN_ALLOW_THREADS;
 _gfx_aapolygoncolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *points, *item;
-    Sint16 *vx, *vy, x, y;
+    Sint16 *vx, *vy;
+    int tmp1, tmp2;
     Py_ssize_t count, i;
     int ret;
     Uint32 c;
         return NULL;
     }
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     vx = PyMem_New (Sint16, (size_t) count);
     vy = PyMem_New (Sint16, (size_t) count);
     for (i = 0; i < count; i++)
     {
         item = PySequence_ITEM (points, i);
-        if (!PointFromObject (item, (int*)&x, (int*)&y))
+        if (!PointFromObject (item, &tmp1, &tmp2))
         {
             PyMem_Free (vx);
             PyMem_Free (vy);
             return NULL;
         }
         Py_DECREF (item);
-        vx[i] = x;
-        vy[i] = y;
+        vx[i] = (Sint16)tmp1;
+        vy[i] = (Sint16)tmp2;
     }
 
     Py_BEGIN_ALLOW_THREADS;
 _gfx_filledpolygoncolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *points, *item;
-    Sint16 *vx, *vy, x, y;
+    Sint16 *vx, *vy;
+    int tmp1, tmp2;
     Py_ssize_t count, i;
     int ret;
     Uint32 c;
         return NULL;
     }
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     vx = PyMem_New (Sint16, (size_t) count);
     vy = PyMem_New (Sint16, (size_t) count);
     for (i = 0; i < count; i++)
     {
         item = PySequence_ITEM (points, i);
-        if (!PointFromObject (item, (int*)&x, (int*)&y))
+        if (!PointFromObject (item, &tmp1, &tmp2))
         {
             PyMem_Free (vx);
             PyMem_Free (vy);
             return NULL;
         }
         Py_DECREF (item);
-        vx[i] = x;
-        vy[i] = y;
+        vx[i] = (Sint16)tmp1;
+        vy[i] = (Sint16)tmp2;
     }
 
     Py_BEGIN_ALLOW_THREADS;
 _gfx_texturedpolygon (PyObject *self, PyObject* args)
 {
     PyObject *surface, *texture, *points, *item, *pt;
-    Sint16 *vx, *vy, x, y, tdx, tdy;
+    Sint16 *vx, *vy;
+    int tmp1, tmp2, tdx, tdy;
     Py_ssize_t count, i;
     int ret;
 
     }
     else
     {
-        if (!PointFromObject (pt, (int*)&tdx, (int*)&tdy))
+        if (!PointFromObject (pt, &tdx, &tdy))
             return NULL;
     }
     
     for (i = 0; i < count; i++)
     {
         item = PySequence_ITEM (points, i);
-        if (!PointFromObject (item, (int*)&x, (int*)&y))
+        if (!PointFromObject (item, &tmp1, &tmp2))
         {
             PyMem_Free (vx);
             PyMem_Free (vy);
             return NULL;
         }
         Py_DECREF (item);
-        vx[i] = x;
-        vy[i] = y;
+        vx[i] = (Sint16)tmp1;
+        vy[i] = (Sint16)tmp2;
     }
 
     Py_BEGIN_ALLOW_THREADS;
     ret = texturedPolygon (((PySDLSurface*)surface)->surface, vx, vy,
-        (int)count, ((PySDLSurface*)texture)->surface, tdx, tdy);
+        (int)count, ((PySDLSurface*)texture)->surface, (Sint16)tdx,
+        (Sint16)tdy);
     Py_END_ALLOW_THREADS;
 
     PyMem_Free (vx);
 _gfx_beziercolor (PyObject *self, PyObject* args)
 {
     PyObject *surface, *color, *points, *item;
-    Sint16 *vx, *vy, x, y;
+    Sint16 *vx, *vy;
+    int x, y;
     Py_ssize_t count, i;
     int ret, steps;
     Uint32 c;
         return NULL;
     }
     c = (Uint32) PyColor_AsNumber (color);
-    ARGB2FORMAT (c, ((PySDLSurface*)surface)->surface->format);
+    c = ARGB_2_RGBA (c);
 
     vx = PyMem_New (Sint16, (size_t) count);
     vy = PyMem_New (Sint16, (size_t) count);
     for (i = 0; i < count; i++)
     {
         item = PySequence_ITEM (points, i);
-        if (!PointFromObject (item, (int*)&x, (int*)&y))
+        if (!PointFromObject (item, &x, &y))
         {
             PyMem_Free (vx);
             PyMem_Free (vy);
             return NULL;
         }
         Py_DECREF (item);
-        vx[i] = x;
-        vy[i] = y;
+        vx[i] = (Sint16)x;
+        vy[i] = (Sint16)y;
     }
 
     Py_BEGIN_ALLOW_THREADS;
 #endif
     if (!mod)
         goto fail;
-
     if (import_pygame2_base () < 0)
         goto fail;
     if (import_pygame2_sdl_base () < 0)
         goto fail;
     if (import_pygame2_sdl_video () < 0)
         goto fail;
+
     MODINIT_RETURN(mod);
 fail:
     Py_XDECREF (mod);

test/c_api/Makefile

 CFLAGS = -W -Wall -g 
 
 # Windows includes (MinGW)
-#INCLUDES = -DWIN32 -I. -Ic:\\Python25\\include
-#LIBS = -Lc:\\Python25\\libs -mwindows -lm -lpython25 
+#INCLUDES = -DWIN32 -I. -Ic:\\Python26\\include
+#LIBS = -Lc:\\Python25\\libs -mwindows -lm -lpython26 
 
 # Linux/Unix includes
-INCLUDES = -I. -I/usr/local/include/ -I/usr/local/include/python2.5
-LIBS = -L/usr/local/lib -lpython2.5 -lm
+INCLUDES = -I. -I/usr/local/include/ -I/usr/local/include/python2.6
+LIBS = -L/usr/local/lib -lpython2.6 -lm
 
 CFLAGS += $(INCLUDES)
 LDFLAGS += $(LIBS)

test/c_api/base_tests.c

     val = PyLong_FromUnsignedLong (0xff00ff00ff);
     if (!UlongFromObj(val, &q))
         ERROR ("Mismatch in UlongFromObj");
-    if (u != 0xff00ff00ff)
+    if (q != 0xff00ff00ff)
         ERROR ("Mismatch in UlongFromObj result");
     Py_DECREF (val);
 
     PyTuple_SET_ITEM (seq, 0, PyLong_FromLong (2));
     PyTuple_SET_ITEM (seq, 1, PyLong_FromLong (4));
 
+    d = 0;
     if (!DoubleFromSeqIndex (seq, 0, &d))
         ERROR ("Mismatch in DoubleFromSeqIndex (0)");
     if (d != 2.f)
     if (d != 4.f)
         ERROR ("Mismatch in DoubleFromSeqIndex result 1");
 
+    i = 0;
     if (!IntFromSeqIndex (seq, 0, &i))
         ERROR ("Mismatch in IntFromSeqIndex (0)");
     if (i != 2)
     if (i != 4)
         ERROR ("Mismatch in IntFromSeqIndex result 1");
 
+    u = 0;
     if (!UintFromSeqIndex (seq, 0, &u))
         ERROR ("Mismatch in UintFromSeqIndex (0)");
     if (u != 2)
     if (u != 4)
         ERROR ("Mismatch in UintFromSeqIndex result 1");
 
+    i = j = 0;
     if (!PointFromObject (seq, &i, &j))
         ERROR ("Mismatch in PointFromObject");
     if (i != 2 || j != 4)
         ERROR ("Mismatch in PointFromObject result");
 
+    sw = sh = 0;
     if (!SizeFromObject (seq, &sw, &sh))
         ERROR ("Mismatch in SizeFromObject");
     if (sw != 2 || sh != 4)
         ERROR ("Mismatch in SizeFromObject result");
 
+    d = e = 0;
     if (!FPointFromObject (seq, &d, &e))
         ERROR ("Mismatch in FPointFromObject");
     if (d != 2.f || e != 4.f)
         ERROR ("Mismatch in FPointFromObject result");
 
+    d = e = 0;
     if (!FSizeFromObject (seq, &d, &e))
         ERROR ("Mismatch in FSizeFromObject");
     if (d != 2.f || e != 4.f)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.