Welcome, Guest. Please login or register.

Author Topic: pysfml-cython  (Read 37767 times)

0 Members and 1 Guest are viewing this topic.

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml-cython
« on: July 13, 2011, 12:27:20 am »
Project page: https://github.com/bastienleonard/pysfml-cython

Documentation: http://pysfml2-cython.readthedocs.org/

This binding is up to date (most of the time :roll:) and supports most features of SFML 2.
Currently there's no binary release, you have to compile the module yourself. If you download the current snapshot (in the downloads section on Github), you won't have to install Cython. I noticed in the past that I had forgotten to include some files in the snapshot, or that Github behaved strangely when replacing the it, so please tell me if something goes wrong when using it.
I guess that I will make the first binary release when SFML 2 has a binary release too.

Please read the documentation for more information on the binding, how to build it, etc. ;)
« Last Edit: August 19, 2012, 04:37:43 pm by bastien »
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 31044
    • View Profile
    • SFML's website
    • Email
pysfml2-cython
« Reply #1 on: July 13, 2011, 05:55:50 am »
It's a good thing you made an annoucement for your binding, I was wondering which projects were still active.

It seems like your Python binding is the only one that's still active. So maybe it should be the official Python binding for SFML 2. What do you think?

Do you have any news from the other bindings?
Laurent Gomila - SFML developer

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #2 on: July 17, 2011, 01:43:56 am »
As far as I know, it's the only binding that's kept up-to-date. My main concern is about the API usability and bugs that probably lurk in methods that I never use.
So I don't know about making it the official binding, but it could help to make an announcement on the first page like you did for rbSFML. I think a lot of people don't know about this binding.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 31044
    • View Profile
    • SFML's website
    • Email
pysfml2-cython
« Reply #3 on: July 17, 2011, 08:07:12 am »
Quote
it could help to make an announcement on the first page like you did for rbSFML

Good idea.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 31044
    • View Profile
    • SFML's website
    • Email
pysfml2-cython
« Reply #4 on: July 17, 2011, 09:18:56 am »
Done!
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1470
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
pysfml2-cython
« Reply #5 on: July 17, 2011, 09:20:12 am »
I guess congratz are in order? :D
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #6 on: July 19, 2011, 12:11:29 pm »
Thanks. ;)
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

plink

  • Newbie
  • *
  • Posts: 2
    • View Profile
pysfml2-cython
« Reply #7 on: July 26, 2011, 07:59:39 am »
Thanks for the project ! A up-to-date binding with sfml 2.0 and the smooth desactivation is working. (yeah !) :3 I'll do some test (everything is working in the examples, exept the shader example... I'll make a topic about it if I can't debug it.) I think it could be great if the worms.py example from the binding pySFML 1.6 will be recoded for the actual binding (I can do it).
Oh and I seen the documentation isn't complete, could I help you to complete it ?  :D

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #8 on: July 26, 2011, 01:09:01 pm »
I couldn't test shaders on GNU/Linux, so now that I have compiled the latest version on Windows I'm going to try to fix the example. Apparently the runtime error is simply because set_current_texture() must be used instead of set_texture(). The example still doesn't look right though, but I've never really used shaders and there doesn't seem to be an obvious bug in the binding code, so I'm not sure what the problem is.
I don't remember the worms.py example, but I'll check it out.

I just realized that the Pong example doesn't behave like the C++ one, though. It's not obvious whether I made a mistake when porting it or if it's a bug in the binding. :?

The only part of the documentation that I expect to complete in the near future is the tutorial. Adding complete documentation of the classes and methods would be a lot of work, which would be mostly redundant and subject to change a lot before a SFML 2 is stabilized.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

plink

  • Newbie
  • *
  • Posts: 2
    • View Profile
pysfml2-cython
« Reply #9 on: July 27, 2011, 08:41:16 am »
For the shader example (I'm on GNU/Linux, I forgot to said ^^') , one of the errors was from the blur.sfx, which won't load from the python file. I checked the blur.sfx file, and I converted the integer number in float number, like the edge.sfx file. The second error was indeed because set_texture() was used instead of set_current_texture(). It's work now !
I tried the pong example, but I don't see what's wrong exect that the game lag.
Ok for the doc :D

Thanks again for the binding !

Edit: oh I didn't notice the french topic ^^'

Ghost

  • Newbie
  • *
  • Posts: 1
    • View Profile
pysfml2-cython
« Reply #10 on: August 07, 2011, 01:31:21 am »
I just tried to compile the module. But apparently theres a file missing:
vcvarsall.bat
Is the snapshot broken or am I doing something wrong?
Any advice/response is appreciated.

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #11 on: August 09, 2011, 10:17:19 pm »
This file needs to be executed before using the Visual Studio command-line tool. If you want to use Visual Studio, you should use the command-line prompt (I don't the remember the exact name) in Visual Studio's entry in the start menu.

If you want to use another compiler, you need to pass an option like --compiler=minwgw32 when invoking the setup script.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

th1z

  • Newbie
  • *
  • Posts: 1
    • View Profile
pysfml2-cython
« Reply #12 on: August 14, 2011, 01:44:24 pm »
I tried to compile this under linux, but i am getting errors.
Could somebody help me?
These are the first few lines of the output:

Code: [Select]

python2 ./setup.py build_ext --inplace
running build_ext
skipping 'sf.cpp' Cython extension (up-to-date)
building 'sf' extension
gcc -pthread -fno-strict-aliasing -march=x86-64 -mtune=generic -O2 -pipe -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fPIC -I/usr/include/python2.7 -c sf.cpp -o build/temp.linux-x86_64-2.7/sf.o
sf.cpp:378:3: error: ‘RenderImage’ in namespace ‘sf’ does not name a type
sf.cpp: In function ‘int __pyx_pf_2sf_5Sound___cinit__(PyObject*, PyObject*, PyObject*)’:
sf.cpp:9420:168: error: no matching function for call to ‘sf::Sound::Sound(sf::SoundBuffer&, int&, float&, float&, sf::Vector3f&)’
sf.cpp:9420:168: note: candidates are:
/usr/local/include/SFML/Audio/Sound.hpp:68:5: note: sf::Sound::Sound(const sf::Sound&)
/usr/local/include/SFML/Audio/Sound.hpp:68:5: note:   candidate expects 1 argument, 5 provided
/usr/local/include/SFML/Audio/Sound.hpp:60:5: note: sf::Sound::Sound(const sf::SoundBuffer&)
/usr/local/include/SFML/Audio/Sound.hpp:60:5: note:   candidate expects 1 argument, 5 provided
/usr/local/include/SFML/Audio/Sound.hpp:52:5: note: sf::Sound::Sound()
/usr/local/include/SFML/Audio/Sound.hpp:52:5: note:   candidate expects 0 arguments, 5 provided
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_4Font_5get_image(PyObject*, PyObject*)’:
sf.cpp:13603:84: error: ‘class sf::Font’ has no member named ‘GetImage’
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Image_6smooth___get__(PyObject*)’:
sf.cpp:14253:15: error: ‘class sf::Image’ has no member named ‘IsSmooth’
sf.cpp: In function ‘int __pyx_pf_2sf_5Image_6smooth_1__set__(PyObject*, PyObject*)’:
sf.cpp:14305:57: error: ‘class sf::Image’ has no member named ‘SetSmooth’
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Image_5load_from_screen(PyObject*, PyObject*, PyObject*)’:
sf.cpp:14581:46: error: ‘class sf::Image’ has no member named ‘CopyScreen’
sf.cpp:14593:46: error: ‘class sf::Image’ has no member named ‘CopyScreen’
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Image_7load_from_pixels(PyObject*, PyObject*, PyObject*)’:
sf.cpp:14840:39: error: ‘class sf::Image’ has no member named ‘LoadFromPixels’
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Image_8get_maximum_size(PyObject*, PyObject*)’:
sf.cpp:14915:39: error: ‘GetMaximumSize’ is not a member of ‘sf::Image’
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Image_9bind(PyObject*, PyObject*)’:
sf.cpp:14954:57: error: ‘class sf::Image’ has no member named ‘Bind’
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Image_14get_tex_coords(PyObject*, PyObject*)’:
sf.cpp:15589:71: error: ‘class sf::Image’ has no member named ‘GetTexCoords’
sf.cpp: In function ‘PyObject* __pyx_pf_2sf_5Image_17update_pixels(PyObject*, PyObject*, PyObject*)’:
sf.cpp:15841:59: error: ‘class sf::Image’ has no member named ‘UpdatePixels’
sf.cpp:15862:59: error: ‘class sf::Image’ has no member named ‘UpdatePixels’
sf.cpp: In function ‘int __pyx_pf_2sf_6Sprite___cinit__(PyObject*, PyObject*, PyObject*)’:
sf.cpp:18958:217: error: no matching function for call to ‘sf::Sprite::Sprite(sf::Image&, sf::Vector2f&, sf::Vector2f&, float&, sf::Color&)’


Am i doing something wrong?
Or do i use the wrong sfml2 version? (Should be the newest github version)

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #13 on: August 14, 2011, 11:08:11 pm »
You're not wrong, I need to update the binding. I just fixed a problem with my GNU/Linux installation and I'm going to try to do this ASAP.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

lattyware

  • Newbie
  • *
  • Posts: 9
    • View Profile
pysfml2-cython
« Reply #14 on: August 15, 2011, 06:31:13 pm »
Just as a note, I recently discovered you can't load images before the window is created, or the images show up as solid white instead of the image. Not sure if this is intentional or a bug, but it's not consistant with the old bindings, and I spend quite some time figuring out what the issue was, while porting across a project from the old bindings, so it might be worth noting this in the binding's docs.

Edit: I actually found out the problem was that if you let the images you load go out of scope, they will not be kept around by the sprite. So keep a reference to any images you want to use, besides the sprite.