* PySFML now compiles and runs with python3 (and still compiles and runs
with python 2.5) * Improved support for unicode * Fixed a mysterious bug with the opengl sample * Code clean up git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1024 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
af3dd7c630
commit
39f4805a98
14 changed files with 306 additions and 140 deletions
python/src
|
@ -34,7 +34,9 @@ extern PyTypeObject PySfColorType;
|
|||
void CustomDrawable::Render (sf::RenderTarget& Target) const
|
||||
{
|
||||
if (RenderFunction)
|
||||
PyObject_CallFunction(RenderFunction, (char *)"O", RenderWindow);
|
||||
PyObject_CallFunction(RenderFunction, (char *)"O", RenderTarget);
|
||||
else
|
||||
PyErr_SetString(PyExc_RuntimeError, "Custom drawables must have a render method defined");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -48,23 +50,19 @@ static PyObject *
|
|||
PySfDrawable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PySfDrawable *self;
|
||||
|
||||
self = (PySfDrawable *)type->tp_alloc(type, 0);
|
||||
|
||||
if (self != NULL)
|
||||
{
|
||||
}
|
||||
|
||||
return (PyObject *)self;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
PySfDrawable_init(PySfDrawable *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
self->obj = new CustomDrawable();
|
||||
self->obj = new CustomDrawable();
|
||||
self->obj->RenderFunction = NULL;
|
||||
self->obj->RenderTarget = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PySfDrawable_SetX(PySfDrawable* self, PyObject *args)
|
||||
{
|
||||
|
@ -81,7 +79,7 @@ static PyObject *
|
|||
PySfDrawable_SetScale(PySfDrawable* self, PyObject *args)
|
||||
{
|
||||
float ScaleX, ScaleY;
|
||||
if ( !PyArg_ParseTuple(args, "ff", &ScaleX, &ScaleY) )
|
||||
if (!PyArg_ParseTuple(args, "ff:Drawable.SetScale", &ScaleX, &ScaleY) )
|
||||
return NULL;
|
||||
self->obj->SetScale(ScaleX, ScaleY);
|
||||
Py_RETURN_NONE;
|
||||
|
@ -109,7 +107,7 @@ static PyObject *
|
|||
PySfDrawable_SetCenter(PySfDrawable* self, PyObject *args)
|
||||
{
|
||||
float x, y;
|
||||
if ( !PyArg_ParseTuple(args, "ff", &x, &y) )
|
||||
if (!PyArg_ParseTuple(args, "ff:Drawable.SetCenter", &x, &y) )
|
||||
return NULL;
|
||||
self->obj->SetCenter(x, y);
|
||||
Py_RETURN_NONE;
|
||||
|
@ -127,7 +125,7 @@ PySfDrawable_SetColor(PySfDrawable* self, PyObject *args)
|
|||
PySfColor *Color = (PySfColor *)args;
|
||||
if (! PyObject_TypeCheck(args, &PySfColorType))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "Argument is not a sfColor");
|
||||
PyErr_SetString(PyExc_TypeError, "Drawable.SetColor() Argument is not a sf.Color");
|
||||
return NULL;
|
||||
}
|
||||
PySfColorUpdate(Color);
|
||||
|
@ -170,7 +168,7 @@ static PyObject *
|
|||
PySfDrawable_Move(PySfDrawable* self, PyObject *args)
|
||||
{
|
||||
float x, y;
|
||||
if ( !PyArg_ParseTuple(args, "ff", &x, &y) )
|
||||
if (!PyArg_ParseTuple(args, "ff:Drawable.Move", &x, &y) )
|
||||
return NULL;
|
||||
self->obj->Move(x, y);
|
||||
Py_RETURN_NONE;
|
||||
|
@ -185,7 +183,7 @@ static PyObject *
|
|||
PySfDrawable_Scale(PySfDrawable* self, PyObject *args)
|
||||
{
|
||||
float FactorX, FactorY;
|
||||
if ( !PyArg_ParseTuple(args, "ff", &FactorX, &FactorY) )
|
||||
if (!PyArg_ParseTuple(args, "ff:Drawable.Scale", &FactorX, &FactorY) )
|
||||
return NULL;
|
||||
self->obj->Scale(FactorX, FactorY);
|
||||
Py_RETURN_NONE;
|
||||
|
@ -202,7 +200,7 @@ static PyObject *
|
|||
PySfDrawable_SetPosition(PySfDrawable* self, PyObject *args)
|
||||
{
|
||||
float Left, Top;
|
||||
if ( !PyArg_ParseTuple(args, "ff", &Left, &Top) )
|
||||
if (!PyArg_ParseTuple(args, "ff:Drawable.SetPosition", &Left, &Top) )
|
||||
return NULL;
|
||||
self->obj->SetPosition(Left, Top);
|
||||
Py_RETURN_NONE;
|
||||
|
@ -212,7 +210,7 @@ static PyObject *
|
|||
PySfDrawable_TransformToLocal(PySfDrawable* self, PyObject *args)
|
||||
{
|
||||
float X, Y;
|
||||
if ( !PyArg_ParseTuple(args, "ff", &X, &Y) )
|
||||
if (!PyArg_ParseTuple(args, "ff:Drawable.TransformToLocal", &X, &Y) )
|
||||
return NULL;
|
||||
sf::Vector2f result = self->obj->TransformToLocal(sf::Vector2f(X, Y));
|
||||
return Py_BuildValue("ff", result.x, result.y);
|
||||
|
@ -222,7 +220,7 @@ static PyObject *
|
|||
PySfDrawable_TransformToGlobal(PySfDrawable* self, PyObject *args)
|
||||
{
|
||||
float X, Y;
|
||||
if ( !PyArg_ParseTuple(args, "ff", &X, &Y) )
|
||||
if (!PyArg_ParseTuple(args, "ff:Drawable.TransformToGlobal", &X, &Y) )
|
||||
return NULL;
|
||||
sf::Vector2f result = self->obj->TransformToGlobal(sf::Vector2f(X, Y));
|
||||
return Py_BuildValue("ff", result.x, result.y);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue