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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - rojohound

Pages: [1]
1
Python / Re: Question on inheritance
« on: September 22, 2014, 03:45:25 am »
Best I can tell cython calls __cinit__ of the parent class first before __init__ of the inheriting class.
http://stackoverflow.com/questions/18260095/cant-override-init-of-class-from-cython-extension

In the latest from github __init__ is used instead of __cinit__ so I imagine inheritance should work there.  I can't find exactly when it changed though.
https://github.com/Sonkun/python-sfml

2
Ok, I've come up with a solution for python 3.3.  The trick is copying sfml over manually and not letting cxfreeze do it.

My test.py
import sfml
 
My setup.py
import sys
from cx_Freeze import setup, Executable

if sys.platform == "win32":
    base = "Win32GUI"

buildOptions = {"includes":["numbers","re"],
                "excludes":["sfml"]
                }

setup(
        name = "Test",
        version = "1.0",
        description = "pysfml test",
        options = dict(build_exe = buildOptions),
        executables = [Executable("test.py", base=base)])

I then build with cxfreeze and then copy the sfml forder from "C:\Python33\Lib\site-packages" to the build directory.

3
I'd say it's an issue with using cxfreeze and python 3. Python27 works fine from my tests. I also tested python33 and it has the issue, I didn't test other 3x versions.  I've found some slightly similar issues with a google search of cxfreeze and python3, but nothing with solutions.

For reference for anyone digging further all that's needed to reproduce the error is a script that simply imports sfml.

I'd say the next step in debugging this is understanding what cxfreeze does and perhaps making a exe manually with the python c API to compare. For now using python27 could be a possible working option.

4
It's not an issue with pysfml, it's from using pymunk.  Specifically chipmunk.dll is not being copied over.  Copy that file over to the built folder and it works fine.

It actually will tell you it's the issue if you specify "Console" instead of "Win32GUI".
executables = [Executable("test.py", base="Console")]

After that you get a message like this in the console if chipmunk.dll can't be loaded.
Quote
Loading chipmunk for Windows (32bit) [C:\py\build\exe.win32-2.7\chipmunk.dll]

Failed to load pymunk library.

This error usually means that you don't have a compiled version of chipmunk in
the correct spot where pymunk can find it. pymunk does not include precompiled
chipmunk library files for all platforms.
...

5
Python / Re: pysfml-cython
« on: August 25, 2012, 10:50:42 pm »
@kaveldun
The naming is a bit different than the actual SFML api, but it's all in the documentation linked from the first page.  Instead of "setFramerateLimit" you would use "framerate_limit".

@bastien
Everything seem to be working great except I'm getting an error when using the image constructor.
>>> sfml.Image(100,100)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sfml.pyx", line 1833, in sfml.Image.__init__ (src\sfml.cpp:23432)
AttributeError: 'sfml.Image' object has no attribute 'stream'

6
Python / Re: pysfml2-cython
« 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.

7
Python / Re: pysfml2-cython
« 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):

8
Python / Re: pysfml2-cython
« 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()
 

Pages: [1]