Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: pysfml-cython  (Read 82299 times)

0 Members and 2 Guests are viewing this topic.

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #105 on: April 24, 2012, 12:23:28 pm »
I tried to make an updated installer using the SFML 2.0 RC release, but I can't get to load the binding with it. python27.dll can't get loaded; if I try to load it with Dependency walker, the only actual problem seems to be that I'm mismatching 32 bits with 64 bits (I'm on a 64 bits OS). This seems pretty weird since the release is for 32 bits, and I'm using 32 bits Python to build a 32 bits module.
I'll try to build SFML myself, since it worked last time. By the way, can someone confirm that the installers work on 32 bits systems?
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #106 on: May 09, 2012, 12:17:53 am »
Currently, the module doesn't compile because of a bug in Cython: http://trac.cython.org/cython_trac/ticket/767
It's already been fixed in the Git repo, so I guess the update will come soon.

(I'm having some problems with building SFML, but I'll try to fix that and make a new release soon.)
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #107 on: May 13, 2012, 12:51:00 am »
I have finally added two new installers, as well as a source release that doesn't require Cython: https://github.com/bastienleonard/pysfml2-cython/downloads
As usual, feedback is welcome.

The “crash at the end of the program” is still there. I'll try to fix it for the next release.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

danman

  • Hero Member
  • *****
  • Posts: 1121
    • View Profile
    • Email
Re: pysfml2-cython
« Reply #108 on: May 15, 2012, 07:31:27 pm »
I've got problems with pysfml2-cython on both python3 and python2 versions :

Code: [Select]
alexandre@danman:~/Documents$ python
Python 3.2.3 (default, Apr 23 2012, 23:14:44)
[GCC 4.7.0 20120414 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sfml
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /usr/lib/python3.2/site-packages/sfml.cpython-32mu.so: undefined symbol: wrap_render_target_instance
>>>

Do you have an idea ? i've checked the files but I didn't find this symbol, it must be autogenerated by cython itself .
Pointilleur professionnel

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #109 on: May 15, 2012, 10:56:13 pm »
I explained the problem here: http://groups.google.com/group/cython-users/browse_thread/thread/5bc84c723b057c35

I uploaded a source release a day ago, if that's sufficient you can simply use that: https://github.com/bastienleonard/pysfml2-cython/downloads

If you really want to build from Git, you need to modify the generated sfml.cpp file.
You need all these declarations:

Code: [Select]
__PYX_EXTERN_C DL_EXPORT(PyObject) *wrap_time_instance(sf::Time *);
__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);

I don't know if it's the same exact problem everywhere, but on my system I get the first declaration and not the others. So you can look for the wrap_time_instance() declaration, and copy-paste the others after it.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

danman

  • Hero Member
  • *****
  • Posts: 1121
    • View Profile
    • Email
Re: pysfml2-cython
« Reply #110 on: May 16, 2012, 04:07:28 pm »
It works fine, thank you ;)
Pointilleur professionnel

rojohound

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: pysfml2-cython
« Reply #111 on: May 17, 2012, 08:25:50 pm »
Hi,
I think I found an issue.  When drawing with sfml.RenderStates the transform is ignored.

I modified the sprite.py example to make the sprite be drawn mirrored, but it's drawing as if there is no transform.  I made the equivalent in C++ and it works there.
#! /usr/bin/env python2
# -*- coding: utf-8 -*-

import sfml as sf


def main():
    window = sf.RenderWindow(sf.VideoMode(640, 480), 'Sprite example')
    window.framerate_limit = 60
    running = True
    texture = sf.Texture.load_from_file('python-logo.png')
    sprite = sf.Sprite(texture)
   
    # This should cause a reflection on the x axis.
    render_state = sf.RenderStates(transform=sf.Transform(-1,0,0,
                                                           0,1,0,
                                                           0,0,1))
   
    while running:
        for event in window.iter_events():
            if event.type == sf.Event.CLOSED:
                running = False
       
        window.clear(sf.Color.WHITE)
        window.draw(sprite, render_state)
        window.display()
   
    window.close()


if __name__ == '__main__':
    main()
 
« Last Edit: May 17, 2012, 10:11:52 pm by Laurent »

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #112 on: May 17, 2012, 10:55:51 pm »
I think I fixed it, but now I get a totally white screen. I get the same thing with in C++, however. I also uploaded a bugfix source release (0.1.1). Tell me that works for you.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #113 on: May 17, 2012, 11:15:55 pm »
I also added a tutorial for people who know C++ SFML and want to learn pySFML: http://pysfml2-cython.readthedocs.org/en/latest/cppdev-tutorial.html

As well as a “caveats” page: http://pysfml2-cython.readthedocs.org/en/latest/caveats.html#caveats
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

rojohound

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: pysfml2-cython
« Reply #114 on: May 17, 2012, 11:48:51 pm »
0.1.1 fixed it.  Thanks!
The white screen is my fault, when mirrored the sprite is being drawn off screen, but now I can mess around with the transformation to get it positioned correctly.

One other slight annoyance is sf.Transform() raises an error about needing 9 parameters,  what I'd like it to do is just use an identity matrix.  The workaround I've been using is sf.Transform(1,0,0,0,1,0,0,0,1).
I made a fix to sfml.pyx line 612 so that the Transform __init__ class has default values for it's parameters.
    def __init__(self, float a00=1, float a01=0, float a02=0,
                  float a10=0, float a11=1, float a12=0,
                  float a20=0, float a21=0, float a22=1):
« Last Edit: May 17, 2012, 11:50:25 pm by rojohound »

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #115 on: May 18, 2012, 12:25:51 am »
You can also use Transform.IDENTITY.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

rojohound

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: pysfml2-cython
« Reply #116 on: May 18, 2012, 08:40:04 pm »
Transform.IDENTITY will work, I knew I was missing something.  That makes it more readable as well.

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #117 on: May 20, 2012, 02:47:09 am »
I just noticed now that SFML's default constructor creates an identity transform, so yeah it makes sense to support it in pySFML.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #118 on: May 20, 2012, 02:10:43 pm »
Just noticed that this website has installers for the latest source release, and it supports 2.6 as well as native 64 bits: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pysfml2
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: pysfml2-cython
« Reply #119 on: June 19, 2012, 01:22:04 am »
Just noticed that this website has installers for the latest source release, and it supports 2.6 as well as native 64 bits: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pysfml2

I installed his installer for 32 bits 2.7 for a quick test, and the bug-at-program-exit seems now gone. Can anyone confirm this?
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

 

anything