Giter Club home page Giter Club logo

pysfml-cython's People

Contributors

aphonicchaos avatar bastienleonard avatar benediktseidl avatar chisumu avatar intjelic avatar l-p avatar mkeeter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pysfml-cython's Issues

Use default_encoding in Text.string and Text's constructor

Currently, when a Text object is created with a bytes object, it calls the underlying C++ constructor with the same bytes, which SFML will interpret as an “ANSI string” (cp1252 encoding). It would probably make more sense to decode the bytes with the sfml.default_encoding attribute, especially since ANSI strings are barely used outside of the Windows world.

On the other hand, this could slow down the API, even when the user is only using ASCII characters.

install on windows 10 fails

Python 3.8

C:\Users\Bayer\Desktop\fputs\pysfml>python setup3k.py build_ext

If the build fails, run patch.py and try again
----------------------------------------------

running build_ext
building 'sfml' extension
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Bayer\AppData\Local\Programs\Python\Python38\include -IC:\Users\Bayer\AppData\Local\Programs\Python\Python38\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt" /EHsc /Tpsrc\sfml.cpp /Fobuild\temp.win-amd64-3.8\Release\src\sfml.obj
sfml.cpp
C:\Users\Bayer\Desktop\fputs\pysfml\src\hacks.hpp(84): error C2555: CppShape::getPointCount: возвращаемый тип перегруженной виртуальной функции отличается от "sf::Shape::getPointCount" и не является ковариантным
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Shape.hpp(196): note:  см. объявление "sf::Shape::getPointCount"
src\sfml.cpp(1405): warning C4190: для "convert_to_vector2f" задана С-связывание, но возвращаемый тип UDT "sf::Vector2<float>" несовместим с языком Си
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/System/Vector2.hpp(255): note:  см. объявление "sf::Vector2<float>"
src\sfml.cpp(6984): warning C4244: аргумент: преобразование "int" в "T", возможна потеря данных
        with
        [
            T=float
        ]
src\sfml.cpp(21955): warning C4244: аргумент: преобразование "float" в "long", возможна потеря данных
src\sfml.cpp(22014): warning C4244: =: преобразование "int" в "float", возможна потеря данных
src\sfml.cpp(22066): error C2679: бинарный "=": не найден оператор, принимающий правый операнд типа "sf::FloatRect" (или приемлемое преобразование отсутствует)
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Rect.hpp(161): note: может быть "sf::Rect<int> &sf::Rect<int>::operator =(sf::Rect<int> &&)"
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Rect.hpp(161): note: или       "sf::Rect<int> &sf::Rect<int>::operator =(const sf::Rect<int> &)"
src\sfml.cpp(22066): note: при попытке сопоставить список аргументов "(sf::IntRect, sf::FloatRect)"
src\sfml.cpp(22140): error C2679: бинарный "=": не найден оператор, принимающий правый операнд типа "sf::IntRect" (или приемлемое преобразование отсутствует)
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Rect.hpp(161): note: может быть "sf::Rect<float> &sf::Rect<float>::operator =(sf::Rect<float> &&)"
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Rect.hpp(161): note: или       "sf::Rect<float> &sf::Rect<float>::operator =(const sf::Rect<float> &)"
src\sfml.cpp(22140): note: при попытке сопоставить список аргументов "(sf::FloatRect, sf::IntRect)"
src\sfml.cpp(23150): warning C4244: аргумент: преобразование "float" в "long", возможна потеря данных
src\sfml.cpp(23214): warning C4244: аргумент: преобразование "float" в "long", возможна потеря данных
src\sfml.cpp(27193): error C2664: "void sf::Texture::bind(const sf::Texture *,sf::Texture::CoordinateType)": невозможно преобразовать аргумент 1 из "sf::Texture::CoordinateType" в "const sf::Texture *"
src\sfml.cpp(27193): note: Для преобразования из целого типа в указатель требуется reinterpret_cast, приведение в стиле С или приведение в стиле функции
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Texture.hpp(572): note:  см. объявление "sf::Texture::bind"
src\sfml.cpp(29824): warning C4996: 'sf::Text::getColor': объявлен deprecate
src\sfml.cpp(30049): warning C4996: 'sf::Text::setColor': объявлен deprecate
src\sfml.cpp(31941): error C2259: "CppShape": невозможно создать экземпляр абстрактного класса
C:\Users\Bayer\Desktop\fputs\pysfml\src\hacks.hpp(79): note:  см. объявление "CppShape"
src\sfml.cpp(31941): note: из-за следующих членов:
src\sfml.cpp(31941): note: sf::Vector2f sf::Shape::getPoint(size_t) const: абстрактный
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Shape.hpp(213): note:  см. объявление "sf::Shape::getPoint"
src\sfml.cpp(33496): warning C4267: аргумент: преобразование из "size_t" в "unsigned long"; возможна потеря данных
src\sfml.cpp(33953): warning C4267: аргумент: преобразование из "size_t" в "unsigned long"; возможна потеря данных
src\sfml.cpp(39062): error C2660: sf::Shader::bind: функция не принимает 0 аргументов
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Shader.hpp(661): note:  см. объявление "sf::Shader::bind"
src\sfml.cpp(39214): warning C4996: 'sf::Shader::setParameter': объявлен deprecate
src\sfml.cpp(39239): warning C4996: 'sf::Shader::setParameter': объявлен deprecate
src\sfml.cpp(39263): warning C4996: 'sf::Shader::setParameter': объявлен deprecate
src\sfml.cpp(39287): warning C4996: 'sf::Shader::setParameter': объявлен deprecate
src\sfml.cpp(39311): warning C4996: 'sf::Shader::setParameter': объявлен deprecate
src\sfml.cpp(39369): warning C4996: 'sf::Shader::setParameter': объявлен deprecate
src\sfml.cpp(39393): warning C4996: 'sf::Shader::setParameter': объявлен deprecate
src\sfml.cpp(39409): warning C4996: 'sf::Shader::setParameter': объявлен deprecate
src\sfml.cpp(39458): error C2039: "unbind": не является членом "sf::Shader".
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/Shader.hpp(52): note:  см. объявление "sf::Shader"
src\sfml.cpp(40476): error C2440: приведение типов: невозможно преобразовать "int" в "sf::BlendMode"
src\sfml.cpp(40476): note: Ни один конструктор не смог принять исходный тип, либо разрешение перегрузки конструктора неоднозначно
src\sfml.cpp(40597): error C2440: приведение типов: невозможно преобразовать "sf::BlendMode" в "int"
src\sfml.cpp(40597): note: Для выполнения данного преобразования нет доступного оператора преобразования, определенного пользователем, или вызов оператора невозможен
src\sfml.cpp(40656): error C2440: приведение типов: невозможно преобразовать "int" в "sf::BlendMode"
src\sfml.cpp(40656): note: Ни один конструктор не смог принять исходный тип, либо разрешение перегрузки конструктора неоднозначно
src\sfml.cpp(41867): error C2039: "convertCoords": не является членом "sf::RenderTarget".
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/VertexBuffer.hpp(39): note:  см. объявление "sf::RenderTarget"
src\sfml.cpp(41879): error C2039: "convertCoords": не является членом "sf::RenderTarget".
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Graphics/VertexBuffer.hpp(39): note:  см. объявление "sf::RenderTarget"
src\sfml.cpp(42165): warning C4244: =: преобразование "Py_ssize_t" в "unsigned int", возможна потеря данных
src\sfml.cpp(43516): warning C4244: аргумент: преобразование "int" в "float", возможна потеря данных
src\sfml.cpp(44144): warning C4311: приведение типов: усечение указателя из "sf::WindowHandle" в "unsigned long"
src\sfml.cpp(44144): warning C4302: приведение типов: усечение из "sf::WindowHandle" к "unsigned long"
src\sfml.cpp(44619): warning C4312: приведение типов: преобразование из "unsigned long" в "sf::WindowHandle" большего размера
src\sfml.cpp(44631): warning C4312: приведение типов: преобразование из "unsigned long" в "sf::WindowHandle" большего размера
src\sfml.cpp(45510): warning C4996: 'sf::RenderTexture::create': объявлен deprecate
src\sfml.cpp(56414): error C2664: "PyObject *PyLong_FromLong(long)": невозможно преобразовать аргумент 1 из "const sf::BlendMode" в "long"
src\sfml.cpp(56414): note: Для выполнения данного преобразования нет доступного оператора преобразования, определенного пользователем, или вызов оператора невозможен
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\longobject.h(18): note:  см. объявление "PyLong_FromLong"
src\sfml.cpp(56426): error C2664: "PyObject *PyLong_FromLong(long)": невозможно преобразовать аргумент 1 из "const sf::BlendMode" в "long"
src\sfml.cpp(56426): note: Для выполнения данного преобразования нет доступного оператора преобразования, определенного пользователем, или вызов оператора невозможен
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\longobject.h(18): note:  см. объявление "PyLong_FromLong"
src\sfml.cpp(56438): error C2664: "PyObject *PyLong_FromLong(long)": невозможно преобразовать аргумент 1 из "const sf::BlendMode" в "long"
src\sfml.cpp(56438): note: Для выполнения данного преобразования нет доступного оператора преобразования, определенного пользователем, или вызов оператора невозможен
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\longobject.h(18): note:  см. объявление "PyLong_FromLong"
src\sfml.cpp(56450): error C2664: "PyObject *PyLong_FromLong(long)": невозможно преобразовать аргумент 1 из "const sf::BlendMode" в "long"
src\sfml.cpp(56450): note: Для выполнения данного преобразования нет доступного оператора преобразования, определенного пользователем, или вызов оператора невозможен
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\longobject.h(18): note:  см. объявление "PyLong_FromLong"
src\sfml.cpp(57678): error C2039: "Back": не является членом "sf::Keyboard".
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\SFML/Window/Keyboard.hpp(40): note:  см. объявление "sf::Keyboard"
src\sfml.cpp(57678): error C2065: Back: необъявленный идентификатор
src\sfml.cpp(59968): error C2039: "exc_type": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(59969): error C2039: "exc_value": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(59970): error C2039: "exc_traceback": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(59971): error C2039: "exc_type": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(59972): error C2039: "exc_value": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(59973): error C2039: "exc_traceback": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60104): error C3688: недопустимый литеральный суффикс "PY_FORMAT_SIZE_T"; не удалось найти литеральный оператор или шаблон литерального оператора "operator ""PY_FORMAT_SIZE_T"
src\sfml.cpp(60318): error C3688: недопустимый литеральный суффикс "PY_FORMAT_SIZE_T"; не удалось найти литеральный оператор или шаблон литерального оператора "operator ""PY_FORMAT_SIZE_T"
src\sfml.cpp(60317): error C2664: "PyObject *PyErr_Format(PyObject *,const char *,...)": невозможно преобразовать аргумент 2 из "Py_ssize_t" в "const char *"
src\sfml.cpp(60319): note: Для преобразования из целого типа в указатель требуется reinterpret_cast, приведение в стиле С или приведение в стиле функции
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\pyerrors.h(168): note:  см. объявление "PyErr_Format"
src\sfml.cpp(60324): error C3688: недопустимый литеральный суффикс "PY_FORMAT_SIZE_T"; не удалось найти литеральный оператор или шаблон литерального оператора "operator ""PY_FORMAT_SIZE_T"
src\sfml.cpp(60323): error C2664: "PyObject *PyErr_Format(PyObject *,const char *,...)": невозможно преобразовать аргумент 2 из "Py_ssize_t" в "const char *"
src\sfml.cpp(60324): note: Для преобразования из целого типа в указатель требуется reinterpret_cast, приведение в стиле С или приведение в стиле функции
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\pyerrors.h(168): note:  см. объявление "PyErr_Format"
src\sfml.cpp(60359): error C2039: "exc_type": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60360): error C2039: "exc_value": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60361): error C2039: "exc_traceback": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60369): error C2039: "exc_type": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60370): error C2039: "exc_value": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60371): error C2039: "exc_traceback": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60372): error C2039: "exc_type": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60373): error C2039: "exc_value": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
src\sfml.cpp(60374): error C2039: "exc_traceback": не является членом "_ts".
C:\Users\Bayer\AppData\Local\Programs\Python\Python38\include\cpython/pystate.h(51): note:  см. объявление "_ts"
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

Troubles building with python3.5

Here is how I have tried to build the module:

git clone https://github.com/bastienleonard/pysfml-cython
cd pysfml-cython/
cd src/
cython -3 --cplus sfml.pyx
cd ..
sudo python3.5 setup3k.py build_ext  # error: command 'gcc' failed with exit status 1
./patch.py
sudo python3.5 setup3k.py build_ext # fails again

Here is the output of the last command:

running build_ext
skipping 'src/sfml.cpp' Cython extension (up-to-date)
building 'sfml' extension
gcc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python3.5m -c src/sfml.cpp -o build/temp.linux-x86_64-3.5/src/sfml.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from src/sfml.cpp:260:0:
src/hacks.hpp:84:26: error: conflicting return type specified for ‘virtual unsigned int CppShape::getPointCount() const’
     virtual unsigned int getPointCount() const;
                          ^
In file included from /usr/local/include/SFML/Graphics/CircleShape.hpp:32:0,
                 from /usr/local/include/SFML/Graphics.hpp:34,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/Shape.hpp:196:25: error:   overriding ‘virtual std::size_t sf::Shape::getPointCount() const’
     virtual std::size_t getPointCount() const = 0;
                         ^
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_5Glyph_6bounds___get__(__pyx_obj_4sfml_Glyph*)’:
src/sfml.cpp:26173:13: error: no match for ‘operator=’ (operand types are ‘sf::IntRect {aka sf::Rect<int>}’ and ‘sf::FloatRect {aka sf::Rect<float>}’)
   __pyx_t_1 = __pyx_v_self->p_this->bounds;
             ^
src/sfml.cpp:26173:13: note: candidate is:
In file included from /usr/local/include/SFML/Graphics/Transform.hpp:32:0,
                 from /usr/local/include/SFML/Graphics/RenderStates.hpp:33,
                 from /usr/local/include/SFML/Graphics/Drawable.hpp:32,
                 from /usr/local/include/SFML/Graphics/Shape.hpp:32,
                 from /usr/local/include/SFML/Graphics/CircleShape.hpp:32,
                 from /usr/local/include/SFML/Graphics.hpp:34,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note: sf::Rect<int>& sf::Rect<int>::operator=(const sf::Rect<int>&)
 class Rect
       ^
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note:   no known conversion for argument 1 from ‘sf::FloatRect {aka sf::Rect<float>}’ to ‘const sf::Rect<int>&’
src/sfml.cpp: In function ‘int __pyx_pf_4sfml_5Glyph_6bounds_2__set__(__pyx_obj_4sfml_Glyph*, PyObject*)’:
src/sfml.cpp:26257:32: error: no match for ‘operator=’ (operand types are ‘sf::FloatRect {aka sf::Rect<float>}’ and ‘sf::IntRect {aka sf::Rect<int>}’)
   __pyx_v_self->p_this->bounds = __pyx_v_rect;
                                ^
src/sfml.cpp:26257:32: note: candidate is:
In file included from /usr/local/include/SFML/Graphics/Transform.hpp:32:0,
                 from /usr/local/include/SFML/Graphics/RenderStates.hpp:33,
                 from /usr/local/include/SFML/Graphics/Drawable.hpp:32,
                 from /usr/local/include/SFML/Graphics/Shape.hpp:32,
                 from /usr/local/include/SFML/Graphics/CircleShape.hpp:32,
                 from /usr/local/include/SFML/Graphics.hpp:34,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note: sf::Rect<float>& sf::Rect<float>::operator=(const sf::Rect<float>&)
 class Rect
       ^
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note:   no known conversion for argument 1 from ‘sf::IntRect {aka sf::Rect<int>}’ to ‘const sf::Rect<float>&’
src/sfml.cpp: In function ‘int __pyx_pf_4sfml_5Shape___init__(__pyx_obj_4sfml_Shape*, PyObject*, PyObject*)’:
src/sfml.cpp:38009:72: error: invalid new-expression of abstract class type ‘CppShape’
   __pyx_v_self->__pyx_base.p_this = ((sf::Transformable *)new CppShape());
                                                                        ^
In file included from src/sfml.cpp:260:0:
src/hacks.hpp:79:7: note:   because the following virtual functions are pure within ‘CppShape’:
 class CppShape : public sf::Shape
       ^
In file included from /usr/local/include/SFML/Graphics/CircleShape.hpp:32:0,
                 from /usr/local/include/SFML/Graphics.hpp:34,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/Shape.hpp:213:22: note:    virtual sf::Vector2f sf::Shape::getPoint(std::size_t) const
     virtual Vector2f getPoint(std::size_t index) const = 0;
                      ^
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_12RenderStates_10blend_mode___get__(__pyx_obj_4sfml_RenderStates*)’:
src/sfml.cpp:48479:64: error: invalid cast from type ‘sf::BlendMode’ to type ‘int’
   __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_v_self->p_this->blendMode)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                                ^
src/sfml.cpp: In function ‘int __pyx_pf_4sfml_12RenderStates_10blend_mode_2__set__(__pyx_obj_4sfml_RenderStates*, int)’:
src/sfml.cpp:48550:53: error: no matching function for call to ‘sf::BlendMode::BlendMode(int&)’
   __pyx_v_self->p_this->blendMode = ((sf::BlendMode)__pyx_v_value);
                                                     ^
src/sfml.cpp:48550:53: note: candidates are:
In file included from /usr/local/include/SFML/Graphics.hpp:33:0,
                 from src/sfml.cpp:258:
/usr/local/include/SFML/Graphics/BlendMode.hpp:107:5: note: sf::BlendMode::BlendMode(sf::BlendMode::Factor, sf::BlendMode::Factor, sf::BlendMode::Equation, sf::BlendMode::Factor, sf::BlendMode::Factor, sf::BlendMode::Equation)
     BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,
     ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:107:5: note:   candidate expects 6 arguments, 1 provided
/usr/local/include/SFML/Graphics/BlendMode.hpp:94:5: note: sf::BlendMode::BlendMode(sf::BlendMode::Factor, sf::BlendMode::Factor, sf::BlendMode::Equation)
     BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Add);
     ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:94:5: note:   candidate expects 3 arguments, 1 provided
/usr/local/include/SFML/Graphics/BlendMode.hpp:81:5: note: sf::BlendMode::BlendMode()
     BlendMode();
     ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:81:5: note:   candidate expects 0 arguments, 1 provided
/usr/local/include/SFML/Graphics/BlendMode.hpp:41:26: note: sf::BlendMode::BlendMode(const sf::BlendMode&)
 struct SFML_GRAPHICS_API BlendMode
                          ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:41:26: note:   no known conversion for argument 1 from ‘int’ to ‘const sf::BlendMode&’
src/sfml.cpp: In function ‘PyObject* PyInit_sfml()’:
src/sfml.cpp:62640:50: error: cannot convert ‘const sf::BlendMode’ to ‘int’ for argument ‘1’ to ‘PyObject* __Pyx_PyInt_From_int(int)’
   __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendAlpha); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                  ^
src/sfml.cpp:62652:48: error: cannot convert ‘const sf::BlendMode’ to ‘int’ for argument ‘1’ to ‘PyObject* __Pyx_PyInt_From_int(int)’
   __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendAdd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                ^
src/sfml.cpp:62664:53: error: cannot convert ‘const sf::BlendMode’ to ‘int’ for argument ‘1’ to ‘PyObject* __Pyx_PyInt_From_int(int)’
   __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendMultiply); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                     ^
src/sfml.cpp:62676:49: error: cannot convert ‘const sf::BlendMode’ to ‘int’ for argument ‘1’ to ‘PyObject* __Pyx_PyInt_From_int(int)’
   __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendNone); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                                 ^
src/sfml.cpp: At global scope:
src/sfml.cpp:41551:39: warning: ‘__pyx_obj_4sfml_Vertex* __pyx_f_4sfml_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
 static struct __pyx_obj_4sfml_Vertex *__pyx_f_4sfml_wrap_vertex_instance(sf::Vertex *__pyx_v_p) {
                                       ^

If the build fails, run patch.py and try again
----------------------------------------------

error: command 'gcc' failed with exit status 1 

Have I done anything wrong? A similar thing seems to happen with python3.4 anyway.

I do have SFML installed:

$ sudo ldconfig -p | grepl libsfml
libsfml-window.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-window.so.2.3
libsfml-window.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-window.so.2
libsfml-window.so (libc6,x86-64) => /usr/local/lib/libsfml-window.so
libsfml-system.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-system.so.2.3
libsfml-system.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-system.so.2
libsfml-system.so (libc6,x86-64) => /usr/local/lib/libsfml-system.so
libsfml-network.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-network.so.2.3
libsfml-network.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-network.so.2
libsfml-network.so (libc6,x86-64) => /usr/local/lib/libsfml-network.so
libsfml-graphics.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-graphics.so.2.3
libsfml-graphics.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2
libsfml-graphics.so (libc6,x86-64) => /usr/local/lib/libsfml-graphics.so
libsfml-audio.so.2.3 (libc6,x86-64) => /usr/local/lib/libsfml-audio.so.2.3
libsfml-audio.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libsfml-audio.so.2
libsfml-audio.so (libc6,x86-64) => /usr/local/lib/libsfml-audio.so

During troubleshooting, I would like to use ancient pysfml binding, but I can't download it anymore. How is this repo related to that project? Do you know why is this link dead?

This is it, thank you for this precious binding :)

Per-Point Colors

Hi Bastien,

In an earlier version of this library, it was possible to generate a shape with
per-point coloring, e.g.

s = sf.Shape()
s.add_point(xLoc, yLoc + 1, sf.Color.WHITE)
s.add_point(xLoc, yLoc + 2, sf.Color(255, 255, 255, 0))
s.add_point(xLoc + 1, yLoc + 2, sf.Color(255, 255, 255, 0))
s.add_point(xLoc + 1, yLoc + 1, sf.Color.WHITE)

Is there a way to do this with the current library version?

Compiling with XCode 4+ error and also a gcc-4.2 question.

XCode 4+ removes PowerPC support so compilation fails with a lipo error. I'm guessing the following is all that's needed to fix this problem:

export ARCHFLAGS="-arch i386 -arch x86_64"

I'm just thinking maybe there's something you can do with your Makefile so that this is handled automatically (I don't know anything about CMake)? I'm [trying to] walk someone through getting this compiled. It would make it a little easier for people who are trying to compile this who aren't used to the whole compilation thing.

Also, I noticed you're explicitly using gcc-4.0, any reason you're not using gcc? I'm just wondering what would happen if say gcc-4.0 was symlinked to gcc-4.2? I'm not really expecting it to work but it's worth a shot heh.

Just gcc-4.0 isn't on the system and I figured I'd try that before having the guy compile gcc 4.0 as it's not available in homebrew etc.

Texture::bind and Shader::bind are now static and need an argument

pysfml is broken since SFML/SFML@91e1743

gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -I/usr/include/python3.2mu -c src/sfml.cpp -o build/temp.linux-x86_64-3.2/src/sfml.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_7Texture_12bind(__pyx_obj_4sfml_Texture*, int)’:
src/sfml.cpp:27247:84: error: no matching function for call to ‘sf::Texture::bind(sf::Texture::CoordinateType)’
src/sfml.cpp:27247:84: note: candidate is:
In file included from /usr/local/include/SFML/Graphics/Font.hpp:33:0,
                 from /usr/local/include/SFML/Graphics.hpp:35,
                 from src/sfml.cpp:264:
/usr/local/include/SFML/Graphics/Texture.hpp:454:17: note: static void sf::Texture::bind(const sf::Texture*, sf::Texture::CoordinateType)
/usr/local/include/SFML/Graphics/Texture.hpp:454:17: note:   no known conversion for argument 1 from ‘sf::Texture::CoordinateType’ to ‘const sf::Texture*’
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_6Shader_16bind(__pyx_obj_4sfml_Shader*)’:
src/sfml.cpp:39040:30: error: no matching function for call to ‘sf::Shader::bind()’
src/sfml.cpp:39040:30: note: candidate is:
In file included from /usr/local/include/SFML/Graphics.hpp:41:0,
                 from src/sfml.cpp:264:
/usr/local/include/SFML/Graphics/Shader.hpp:471:17: note: static void sf::Shader::bind(const sf::Shader*)
/usr/local/include/SFML/Graphics/Shader.hpp:471:17: note:   candidate expects 1 argument, 0 provided
src/sfml.cpp: At global scope:
src/sfml.cpp:34929:39: warning: ‘__pyx_obj_4sfml_Vertex* __pyx_f_4sfml_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
error: command 'gcc' failed with exit status 1

Can't build for Python3

I followed the instructions and it failed for Python3, building for Python2 seems to work fine.

Here is the log :

[2123:0]@leo-laptop:src$ /home/leo/Documents/src/Cython-0.15.1/cython.py --cplus sf.pyx 
[2124:0]@leo-laptop:src$ cd ..
[2125:0]@leo-laptop:pysfml2-cython$ py setup3k.py build_ext
running build_ext
building 'sf' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python3.2mu -c src/sf.cpp -o build/temp.linux-x86_64-3.2/src/sf.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_9Transform_6matrix___get__(PyObject*)’:
src/sf.cpp:7551:8: warning: variable ‘__pyx_v_i’ set but not used [-Wunused-but-set-variable]
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Chunk_7samples___get__(PyObject*)’:
src/sf.cpp:13662:10: warning: variable ‘__pyx_v_i’ set but not used [-Wunused-but-set-variable]
src/sf.cpp: At global scope:
src/sf.cpp:26578:37: warning: ‘__pyx_obj_2sf_Vertex* __pyx_f_2sf_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python3.2mu -c src/hacks.cpp -o build/temp.linux-x86_64-3.2/src/hacks.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
In file included from src/hacks.cpp:30:0:
src/sf.h:15:32: error: expected constructor, destructor, or type conversion before ‘set_error_message’
src/sf.h:16:40: error: expected constructor, destructor, or type conversion before ‘convert_to_vector2f’
src/sf.h:17:53: error: expected constructor, destructor, or type conversion before ‘*’ token
src/sf.h:18:54: error: expected constructor, destructor, or type conversion before ‘*’ token
src/sf.h:19:61: error: expected constructor, destructor, or type conversion before ‘*’ token
src/sf.h:20:61: error: expected constructor, destructor, or type conversion before ‘*’ token
src/hacks.cpp: In member function ‘virtual int MyBuff::sync()’:
src/hacks.cpp:103:38: error: ‘set_error_message’ was not declared in this scope
src/hacks.cpp: In member function ‘virtual void CppDrawable::Draw(sf::RenderTarget&, sf::RenderStates) const’:
src/hacks.cpp:137:73: error: ‘wrap_render_target_instance’ was not declared in this scope
src/hacks.cpp:139:37: error: ‘wrap_render_states_instance’ was not declared in this scope
src/hacks.cpp: In member function ‘virtual sf::Vector2f CppShape::GetPoint(unsigned int) const’:
src/hacks.cpp:206:40: error: ‘convert_to_vector2f’ was not declared in this scope
src/hacks.cpp: In member function ‘virtual bool CppSoundStream::OnGetData(sf::SoundStream::Chunk&)’:
src/hacks.cpp:239:69: error: ‘wrap_chunk_instance’ was not declared in this scope
src/hacks.cpp: In member function ‘virtual void CppSoundStream::OnSeek(sf::Time)’:
src/hacks.cpp:277:34: error: ‘wrap_time_instance’ was not declared in this scope
error: command 'gcc' failed with exit status 1

Other infos :

[2155:0]@leo-laptop:~$ py
Python 3.2.2 (default, Sep  5 2011, 21:17:14) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
[2155:0]@leo-laptop:~$ uname -a
Linux leo-laptop 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[2156:0]@leo-laptop:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)

Sprite.set_texture_rect set to read only

it seems that you cannot modify/set the texture coordinates of a texture of a sprite, since that method was introduced in pysfml 0.13

I am running Win7/64bit.

sfml class RectangleShape crashes on Windows

When initializing RectangleShape, or its other descendents that inherit from sfml.Shape with an open window, python.exe goes into not responding on Windows and then crashes.

This issue does not appear to happen on Ubuntu 12.04 64bit Linux.

I am running Windows 7 64 bit and am running on Python 2.7.

window.draw does not work with RenderStates

a call:

window.draw(points, sfml.LINES_STRIP, sfml.RenderStates())

crashes the whole app, while the call:

window.draw(points, sfml.LINES_STRIP)

work perfectly. I need to use RenderStates with my own transformation so I need to get the first call working. Is this a known issue? Am I doing something wrong?

Thanks,

no member named 'BackSpace' in 'sf::Keyboard'

src/sfml.cpp:57531:44: error: no member named 'BackSpace' in 'sf::Keyboard'; did you mean 'BackSlash'?
  __pyx_t_3 = PyInt_FromLong(sf::Keyboard::BackSpace); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                             ~~~~~~~~~~~~~~^~~~~~~~~
                                       BackSlash
/usr/local/include/SFML/Window/Keyboard.hpp:103:9: note: 'BackSlash' declared here
        BackSlash,    ///< The \ key
        ^
6 warnings and 1 error generated.
error: command 'clang' failed with exit status 1

Using the 2.0 installer here and pySFML 0.2.

I'm guessing the change in Keyboard (I read about it in another ticket) was recent and the SFML installer isn't up to date, so I'd need to build SFML from source or use pySFML 0.1.3?

Don't Draw

I am don't speaking English well.

https://gist.github.com/1438129

pencere.draw(st) this line as to application exit.

st.font = sf.Font.load_from_file("akaDora.ttf") line to comment. No problem

Latest SFML commit broke build

Due to the GetWidth/GetHeight/GetSize refactoring that happened here pysfml is broken.

I tried to fiddle with sf.pyx but I have no idea how it works and did not manage to get it running.

src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_9Transform_6matrix___get__(PyObject*)’:
src/sf.cpp:7576:8: warning: variable ‘__pyx_v_i’ set but not used [-Wunused-but-set-variable]
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_12RenderTarget_6height___get__(PyObject*)’:
src/sf.cpp:32236:100: error: ‘class sf::RenderTarget’ has no member named ‘GetHeight’
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_12RenderTarget_5width___get__(PyObject*)’:
src/sf.cpp:32380:100: error: ‘class sf::RenderTarget’ has no member named ‘GetWidth’
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_12RenderWindow_5width___get__(PyObject*)’:
src/sf.cpp:33850:111: error: ‘class sf::RenderTarget’ has no member named ‘GetWidth’
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_12RenderWindow_6height___get__(PyObject*)’:
src/sf.cpp:33959:111: error: ‘class sf::RenderTarget’ has no member named ‘GetHeight’
src/sf.cpp: In function ‘int __pyx_pf_2sf_12RenderWindow_4size_1__set__(PyObject*, PyObject*)’:
src/sf.cpp:34160:125: error: no matching function for call to ‘sf::RenderWindow::SetSize(unsigned int&, unsigned int&)’
src/sf.cpp:34160:125: note: candidate is:
/usr/local/include/SFML/Window/Window.hpp:277:10: note: void sf::Window::SetSize(sf::Vector2u)
/usr/local/include/SFML/Window/Window.hpp:277:10: note:   candidate expects 1 argument, 2 provided
src/sf.cpp: In function ‘int __pyx_pf_2sf_12RenderWindow_18key_repeat_enabled___set__(PyObject*, PyObject*)’:
src/sf.cpp:34251:97: error: ‘class sf::RenderWindow’ has no member named ‘EnableKeyRepeat’
src/sf.cpp: In function ‘int __pyx_pf_2sf_12RenderWindow_8position___set__(PyObject*, PyObject*)’:
src/sf.cpp:34362:129: error: no matching function for call to ‘sf::RenderWindow::SetPosition(int&, int&)’
src/sf.cpp:34362:129: note: candidate is:
/usr/local/include/SFML/Window/Window.hpp:254:10: note: void sf::Window::SetPosition(const Vector2i&)
/usr/local/include/SFML/Window/Window.hpp:254:10: note:   candidate expects 1 argument, 2 provided
src/sf.cpp: In function ‘int __pyx_pf_2sf_12RenderWindow_17show_mouse_cursor___set__(PyObject*, PyObject*)’:
src/sf.cpp:34475:97: error: ‘class sf::RenderWindow’ has no member named ‘ShowMouseCursor’
src/sf.cpp: In function ‘int __pyx_pf_2sf_12RenderWindow_21vertical_sync_enabled___set__(PyObject*, PyObject*)’:
src/sf.cpp:34609:97: error: ‘class sf::RenderWindow’ has no member named ‘EnableVerticalSync’
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_12RenderWindow_11show(PyObject*, PyObject*)’:
src/sf.cpp:35223:97: error: ‘class sf::RenderWindow’ has no member named ‘Show’
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_13RenderTexture_5width___get__(PyObject*)’:
src/sf.cpp:35677:112: error: ‘class sf::RenderTarget’ has no member named ‘GetWidth’
src/sf.cpp: In function ‘PyObject* __pyx_pf_2sf_13RenderTexture_6height___get__(PyObject*)’:
src/sf.cpp:35721:112: error: ‘class sf::RenderTarget’ has no member named ‘GetHeight’
src/sf.cpp: At global scope:
src/sf.cpp:26762:37: warning: ‘__pyx_obj_2sf_Vertex* __pyx_f_2sf_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
error: command 'gcc' failed with exit status 1

Changing View inside RenderWindow doesn't work

Trying to change the size of a View inside a RenderWindow has no effect.

import sf
window = sf.RenderWindow(sf.VideoMode(800, 600), "defense")
window.view.height
600.0
window.view.height = 1000
window.view.height
600.0

This also means that it's impossible to move, rotate, or scale a view inside a RenderWindow.

If you make a stand-alone View object, then you can change its properties - it's only Views living inside
RenderWindows that have this issue (though it may also apply to Views within RenderImages).

ImportError: libsfml-******.so.2

Hello.

The pySFML-cython in Linux (in my Debian Wheezy 64bits) expects to find SFML2 libraries in /usr/lib, but for example, when installing SFML2 from source (cmake -> make -> sudo make install) are installed in /usr/local/lib, and pySFML not found, showing an error like this:

$ python test_pySFML.py 
Traceback (most recent call last):
  File "test_pySFML.py", line 4, in <module>
    import sfml as sf
ImportError: libsfml-graphics.so.2: cannot open shared object file: No such file or directory

This is solved by creating a symbolic link in /usr/lib, but it would be better to find them pySFML also in /usr/local/lib.

_set_error_message not found on import

Compiling from the pyx file works fine, but upon import gives the following error:

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfml.so, 2): Symbol not found: _set_error_message
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfml.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfml.so

Doing a diff between the generated sfml.cpp and the version of sfml.cpp distributed with pySFML-0.1.2 gives the
following:

1c1
< /* Generated by Cython 0.16 on Mon Jun 11 11:22:36 2012 */

---
> /* Generated by Cython 0.16 on Thu May 31 22:48:26 2012 */
1361a1362,1369
> 
> 
> __PYX_EXTERN_C DL_EXPORT(PyObject) *wrap_render_target_instance(sf::RenderTarget *);
> __PYX_EXTERN_C void set_error_message(char*);
> __PYX_EXTERN_C DL_EXPORT(PyObject) *wrap_chunk_instance(sf::SoundStream::Chunk*,                                                        int);
> 
> 
> 
1882c1890
<   static char __pyx_k_82[] = "/Users/mkeeter/code/lib/pysfml2-cython/src/sfml.pyx";

---
>   static char __pyx_k_82[] = "/home/bastien/info/python/cython/pysfml2-cython/src/sfml.pyx";

Any idea why Cython isn't producing the right code?

Additional Dependencies for Py2Exe

I recently tried to create a py2exe application using sfml, but giving it to someone else without sfml/pysfml installed seems to not work properly
File "sfml.pyc", line 12, in
File "sfml.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.

all of the sfml dlls (sfml-graphics-2, sfml-audio-2, etc.) are included in the same directory as the main executable.

deepcopy

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from PySFML import sf
c = sf.Color(123, 123, 123)
l = [[c]]
import copy
l2 = copy.deepcopy(l)
l2
[[]]
l2[0][0].r
0L
l2[0][0].b
0L
l2[0][0].g
0L

Documentation:
In order for a class to define its own copy implementation, it can define special methods copy() and deepcopy().

Initiating a Render Window for the purpose of integrating with PyQt

Qt and SFML seem to intergrate well with eachother http://www.sfml-dev.org/tutorials/1.5/graphics-qt.php, but while I was trying to make the equivalent code, I couldn't figure out how to initialize it to the context of the Qt window.

Is there something I'm not understanding? is RenderWindow.from_window_handle supposed to be used somehow for this purpose? I'm not so sure how to use it.

Also I had an issue with making a class that both inherits QWidget and RenderWindow, I got some sort of " multiple bases have instance lay-out conflict" error

Cannot use inherited methods from Transformable (crash)

A common use of inheriting sf::Transformable is designing custom objects container, as contained objects will be drawn relatively to their container, using the container's transformation states.
It seems a such pattern cannot be realized in pysfml, as I cannot use inherited methods from a sf::Transformable object.

#! /usr/bin/env python2
# -*- coding: utf-8 -*-

import sfml as sf

class Container(sf.Transformable):
    def __init__(self):
        super(Container, self).__init__()

app = sf.RenderWindow(sf.VideoMode(640, 480), 'Title')
app.framerate_limit = 60
running = True

container = Container()
container.position = (50, 50) # crash
container.get_transform() # crash

while running:
    for event in app.iter_events():
        if event.type == sf.Event.CLOSED:
            running = False

    app.clear(sf.Color.WHITE)
    app.display()

app.close()

Accessing container.position and container.get_transform() crash the application.

Output: none
Environment: Windows XP / Python 2.7 / pySFML-0.1.win32-py2.7 (installer)

Sprite.copy() crashes my window

trying to assign the return from sprite.copy() to any sort of variable (or returning it at all) seems to crash the window (no error message, just not responding/white screen)

b = Sprite.copy()
//error

I am running Win7/64bit, built off of the 0.13 Source (also crashed from the 0.12 source)

Cannot use arguments in ctor when inheriting sf.Sprite

When inheriting sf.Sprite, the sub-class cannot be initialized if the constructor is invoked with an argument.
The code bellow reproduces the bug:

import sfml as sf

class Entity(sf.Sprite):

    def __init__(self, hp=1):
        print "Entity.__init__ called"
        super(Entity, self).__init__()
        self.hp = hp

Entity(5) # ERROR

A TypeError exception is raised:

Entity(5) # ERROR
  File "sfml.pyx", line 2280, in sfml.Sprite.__cinit__ (src\sfml.cpp:25311)
TypeError: Argument 'texture' has incorrect type (expected sfml.Texture, got int)

The line print "Entity.__init__ called" is not executed, I assume Entity.__init__ is bypassed and sf.Sprite.__init__ is directly called instead.

By removing the argument in the last line (replacing Entity(5) with Entity()), the code runs correctly and enters Entity.__init__ as expected.

Environment: Windows XP / Python 2.7 / pySFML-0.1.win32-py2.7 (installer)

python 3 fails to compile

hack.cpp uses PyInt_Check and PyInt_AsLong which don't exist in Python 3. They were changed to PyLong_Check and PyLong_AsLong.

shape.size produces an Exception TypeError

Hi,

When I try to use shape.size (e.g., var = shape.size) where shape is an instance of sf.RectangleShape I get:

Exception TypeError: TypeError("Expected Vector2f or tuple, found <type 'int'>",) in 'sfml.convert_to_vector2f' ignored (276.0, 276.0)

I guess something is wrong in the getter method of the property size?

Thanks,
k

Bunch of compiling errors while building on OS X El Capitan with clang

Hey,

I'm trying to build PySFML on OS X El Capitan.

When I run python3 setup3k.py build_ext -I /usr/local/include, I get a bunch of errors from clang:

bash-3.2$ python3 setup3k.py build_ext -I /usr/local/include

If the build fails, run patch.py and try again
----------------------------------------------

running build_ext
skipping 'src/sfml.cpp' Cython extension (up-to-date)
building 'sfml' extension
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c src/sfml.cpp -o build/temp.macosx-10.6-x86_64-3.3/src/sfml.o
In file included from src/sfml.cpp:260:
src/hacks.hpp:84:26: error: virtual function 'getPointCount' has a different return type ('unsigned int') than the function it overrides (which has return type 'std::size_t' (aka 'unsigned long'))
    virtual unsigned int getPointCount() const;
            ~~~~~~~~     ^
/usr/local/include/SFML/Graphics/Shape.hpp:196:25: note: overridden virtual function is here
    virtual std::size_t getPointCount() const = 0;
            ~~~~~~~~~~~ ^
In file included from src/sfml.cpp:260:
src/hacks.hpp:85:26: warning: 'CppShape::getPoint' hides overloaded virtual function [-Woverloaded-virtual]
    virtual sf::Vector2f getPoint(unsigned int index) const;
                         ^
/usr/local/include/SFML/Graphics/Shape.hpp:213:22: note: hidden overloaded virtual function 'sf::Shape::getPoint' declared here: type mismatch at 1st parameter ('std::size_t' (aka 'unsigned long') vs 'unsigned int')
    virtual Vector2f getPoint(std::size_t index) const = 0;
                     ^
src/sfml.cpp:1602:40: warning: 'convert_to_vector2f' has C-linkage specified, but returns user-defined type 'sf::Vector2f' (aka 'Vector2<float>') which is incompatible with C [-Wreturn-type-c-linkage]
__PYX_EXTERN_C DL_EXPORT(sf::Vector2f) convert_to_vector2f(PyObject *); /*proto*/
                                       ^
src/sfml.cpp:26165:13: error: no viable overloaded '='
  __pyx_t_1 = __pyx_v_self->p_this->bounds;
  ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Rect<float>' to 'const Rect<int>' for 1st argument
class Rect
      ^
src/sfml.cpp:26249:32: error: no viable overloaded '='
  __pyx_v_self->p_this->bounds = __pyx_v_rect;
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
/usr/local/include/SFML/Graphics/Rect.hpp:42:7: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Rect<int>' to 'const Rect<float>' for 1st argument
class Rect
      ^
src/sfml.cpp:38001:63: error: allocating an object of abstract class type 'CppShape'
  __pyx_v_self->__pyx_base.p_this = ((sf::Transformable *)new CppShape());
                                                              ^
/usr/local/include/SFML/Graphics/Shape.hpp:213:22: note: unimplemented pure virtual method 'getPoint' in 'CppShape'
    virtual Vector2f getPoint(std::size_t index) const = 0;
                     ^
src/sfml.cpp:48471:37: error: cannot convert 'sf::BlendMode' to 'int' without a conversion operator
  __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_v_self->p_this->blendMode)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sfml.cpp:48542:38: error: no matching conversion for C-style cast from 'int' to 'sf::BlendMode'
  __pyx_v_self->p_this->blendMode = ((sf::BlendMode)__pyx_v_value);
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/SFML/Graphics/BlendMode.hpp:41:26: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const sf::BlendMode' for 1st argument
struct SFML_GRAPHICS_API BlendMode
                         ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:81:5: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
    BlendMode();
    ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:94:5: note: candidate constructor not viable: requires at least 2 arguments, but 1 was provided
    BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Add);
    ^
/usr/local/include/SFML/Graphics/BlendMode.hpp:107:5: note: candidate constructor not viable: requires 6 arguments, but 1 was provided
    BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,
    ^
src/sfml.cpp:62631:15: error: no matching function for call to '__Pyx_PyInt_From_int'
  __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendAlpha); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              ^~~~~~~~~~~~~~~~~~~~
src/sfml.cpp:1370:32: note: candidate function not viable: no known conversion from 'const sf::BlendMode' to 'int' for 1st argument
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
                               ^
src/sfml.cpp:62643:15: error: no matching function for call to '__Pyx_PyInt_From_int'
  __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendAdd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              ^~~~~~~~~~~~~~~~~~~~
src/sfml.cpp:1370:32: note: candidate function not viable: no known conversion from 'const sf::BlendMode' to 'int' for 1st argument
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
                               ^
src/sfml.cpp:62655:15: error: no matching function for call to '__Pyx_PyInt_From_int'
  __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendMultiply); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              ^~~~~~~~~~~~~~~~~~~~
src/sfml.cpp:1370:32: note: candidate function not viable: no known conversion from 'const sf::BlendMode' to 'int' for 1st argument
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
                               ^
src/sfml.cpp:62667:15: error: no matching function for call to '__Pyx_PyInt_From_int'
  __pyx_t_1 = __Pyx_PyInt_From_int(sf::BlendNone); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              ^~~~~~~~~~~~~~~~~~~~
src/sfml.cpp:1370:32: note: candidate function not viable: no known conversion from 'const sf::BlendMode' to 'int' for 1st argument
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
                               ^
2 warnings and 10 errors generated.
error: command '/usr/bin/clang' failed with exit status 1

I retried after running patch.py but I got the exact same error. I also tried building from the rc-compatible branch after seeing this thread on SFML's forum, also got the same error.

Thanks.

Compiling error: Back not a member of sf::Keyboard (Recent SFML 2 change)

While compiling pysfml, I get these errors:

src/sfml.cpp: In function ‘void initsfml()’:
src/sfml.cpp:55699:30: error: ‘Back’ is not a member of ‘sf::Keyboard’
src/sfml.cpp: At global scope:
src/sfml.cpp:33682:39: warning: ‘__pyx_obj_4sfml_Vertex* __pyx_f_4sfml_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
error: command 'gcc' failed with exit status 1

before the build fails.
This is strange, as the documentation in SFML 2.0, sf::Keyboard does includes 'Back', but a test in regular c++ for sf::Keyboard::Back also results in an error for 'Back' not being a member of sf::Keyboard

I am running Ubuntu 32bit

Edit: see comment below

Be able to draw a tuple of vertices

I was testing low-level custom drawables, and noticed that pysfml doesn't allow drawing a tuple of vertices:

render_target.draw((vertex1, vertex2), sf.LINES) (an AttributeError is raised)

You must use a list of vertices:

render_target.draw([vertex1, vertex2], sf.LINES)

Could tuples be allowed as well? (see sfml.pyx:3153)
I believe using a tuple instead of a list can be faster when dealing with large amounts of vertices.

Memory leak in event iterator

There appears to be a memory leak in the event iterator.

import sf

window = sf.RenderWindow(sf.VideoMode(640, 400), "")

while True:
    for event in window.iter_events():
        print event.type

Run this for a while, mashing keys or waving the mouse around, and
watch RAM slowly climb. Not a huge leak, but annoying.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.