it could help to make an announcement on the first page like you did for rbSFML
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&)’
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.
File "sf.pyx", line 1773, in sf.Sprite.__cinit__ (sf.cpp:19704)
TypeError: Argument 'texture' has incorrect type (expected sf.Texture, got sf.Image)
self.sprite.set_image(image, True)
self.sprite.texture = texture
self.sprite.resize(texture.width, texture.height)
Ah, sorry. It should work now, except that it's set_texture().
I will change Sprite to keep a reference to the texture, and I will probably also change all classes where it's possible. I want to avoid problems if SFML changes the C++ object internally, but maybe I'm just paranoid. :?
Ah, sorry. It should work now, except that it's set_texture().
I will change Sprite to keep a reference to the texture, and I will probably also change all classes where it's possible. I want to avoid problems if SFML changes the C++ object internally, but maybe I'm just paranoid. :?
C:\Users\Przemek\Downloads\PySFML 2-0.0.1\PySFML 2-0.0.1>setup.py build_ext
running build_ext
building 'sf' extension
error: Unable to find vcvarsall.bat
running build_ext
building 'sf' extension
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tpsf.cpp /Fobuild\temp.win32-2.7\Release\sf.obj
sf.cpp
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xlocale(323) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
sf.cpp(560) : error C2039: 'Texture' : is not a member of 'sf'
sf.cpp(560) : error C2143: syntax error : missing ';' before '*'
sf.cpp(560) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
sf.cpp(560) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
sf.cpp(705) : error C2039: 'RenderTexture' : is not a member of 'sf'
sf.cpp(705) : error C2143: syntax error : missing ';' before '*'
sf.cpp(705) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
sf.cpp(705) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
sf.cpp(1003) : error C2039: 'Texture' : is not a member of 'sf'
sf.cpp(1003) : error C2065: 'Texture' : undeclared identifier
sf.cpp(1003) : error C2059: syntax error : ','
sf.cpp(1798) : error C2039: 'IsButtonPressed' : is not a member of 'sf::Mouse'
sf.cpp(1798) : error C3861: 'IsButtonPressed': identifier not found
sf.cpp(1896) : error C2039: 'GetPosition' : is not a member of 'sf::Mouse'
sf.cpp(1896) : error C3861: 'GetPosition': identifier not found
sf.cpp(1908) : error C2039: 'GetPosition' : is not a member of 'sf::Mouse'
sf.cpp(1908) : error C3861: 'GetPosition': identifier not found
sf.cpp(2069) : error C2039: 'SetPosition' : is not a member of 'sf::Mouse'
sf.cpp(2069) : error C3861: 'SetPosition': identifier not found
sf.cpp(2081) : error C2039: 'SetPosition' : is not a member of 'sf::Mouse'
sf.cpp(2081) : error C3861: 'SetPosition': identifier not found
sf.cpp(2134) : error C3083: 'Joystick': the symbol to the left of a '::' must be a type
sf.cpp(2134) : error C2039: 'IsConnected' : is not a member of 'sf'
sf.cpp(2134) : error C3861: 'IsConnected': identifier not found
sf.cpp(2188) : error C3083: 'Joystick': the symbol to the left of a '::' must be a type
sf.cpp(2188) : error C2039: 'GetButtonCount' : is not a member of 'sf'
sf.cpp(2188) : error C3861: 'GetButtonCount': identifier not found
sf.cpp(2278) : error C3083: 'Joystick': the symbol to the left of a '::' must be a type
sf.cpp(2278) : error C2039: 'HasAxis' : is not a member of 'sf'
sf.cpp(2278) : error C3083: 'Joystick': the symbol to the left of a '::' must be a type
sf.cpp(2278) : error C2039: 'Axis' : is not a member of 'sf'
sf.cpp(2278) : error C2065: 'Axis' : undeclared identifier
sf.cpp(2278) : error C2146: syntax error : missing ')' before identifier '__pyx_v_axis'
sf.cpp(2278) : error C2059: syntax error : ')'
sf.cpp(2278) : error C3861: 'HasAxis': identifier not found
sf.cpp(2368) : error C3083: 'Joystick': the symbol to the left of a '::' must be a type
sf.cpp(2368) : error C2039: 'IsButtonPressed' : is not a member of 'sf'
sf.cpp(2368) : error C3861: 'IsButtonPressed': identifier not found
sf.cpp(2458) : error C3083: 'Joystick': the symbol to the left of a '::' must be a type
sf.cpp(2458) : error C2039: 'GetAxisPosition' : is not a member of 'sf'
sf.cpp(2458) : error C3083: 'Joystick': the symbol to the left of a '::' must be a type
sf.cpp(2458) : error C2039: 'Axis' : is not a member of 'sf'
sf.cpp(2458) : error C2065: 'Axis' : undeclared identifier
sf.cpp(2458) : error C2146: syntax error : missing ')' before identifier '__pyx_v_axis'
sf.cpp(2458) : error C2059: syntax error : ')'
sf.cpp(2458) : error C3861: 'GetAxisPosition': identifier not found
sf.cpp(2512) : error C3083: 'Keyboard': the symbol to the left of a '::' must be a type
sf.cpp(2512) : error C2039: 'IsKeyPressed' : is not a member of 'sf'
sf.cpp(2512) : error C3083: 'Keyboard': the symbol to the left of a '::' must be a type
sf.cpp(2512) : error C2882: 'Key' : illegal use of namespace identifier in expression
sf.cpp(2512) : fatal error C1903: unable to recover from previous error(s); stopping compilation
First I'd like to thank you for creating PYSFML and giving me more display library options :P.
Second, I have some questions and wanted to point out something that I and maybe other people have a problem with.
Does PYSFML have native functions for render 3d or would I need to create a projection class/algorithm(I have no clue how 3D works in SFML). I'm looking for a well maintained display library for both 2d and 3d rendering and works with python. I looked at pyopengl but saw a number of complaints that it wasn't maintained.
I built SFML and PYSFML yesterday and ran into an odd problem. SMFL "sudo make install" (a little bump was forgetting the sudo and not reading the big error msg >.<) installed the SFML .so's in the wrong directory. I'm on Ubuntu 10.4 LTS and for some reason "make install" placed the .so's in /usr/local/lib instead of /usr/lib. When I ran the PYSMFL examples sf.so couldn't find the needed libraries. So I had to manually copy all the SFML .so's over to the correct directory. Would this just be a problem with my computer?
Anyway I hope this helps someone in the same predicament.
Thanks
Um, sorry, you mean the latest SFML no PySFML :oops:
Tell me please, where should I put the headers and libraries of SFML so that the MSVC compiler sees them? I guess this is what I'm doing wrong.
It looks like you didn't add the headers.
Yes, I think system32 is the right directory for DLLs.
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript
exec codeObject in __main__.__dict__
File "E:\pysfml2\bastienleonard-pysfml2-cython-ca7f88f\examples\pong\main.py", line 9, in <module>
import sf
ImportError: DLL load failed: File not found
Quote from: "bastien"It looks like you didn't add the headers.
Yes, I think system32 is the right directory for DLLs.
Ok I added the includes. Now it gives me this error:
"failed to load and parse the manifest, file not found"
EDIT: Now I edited the python the way I found on some web page (adding /MANIFEST to args of some program) and the compilation finished, I guess. When I try to run a program made with SFML, I get this error:Code: [Select]Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript
exec codeObject in __main__.__dict__
File "E:\pysfml2\bastienleonard-pysfml2-cython-ca7f88f\examples\pong\main.py", line 9, in <module>
import sf
ImportError: DLL load failed: File not found
sf.dll needs to be in the Python path. The simplest way is to put it the current directory just before you execute the program. Or you can modify the PYTHONPATH environment variable.
Or you can run python setup.py install, and it should be available for all the programs. But I would do this only after testing the binding.
You're right, it's .pyd on Windows apparently. What happens if you open a command prompt, go to the path where sf.pyd is, type “python”, and then type “import sf” interactively?
E:\pysfml2\bastienleonard-pysfml2-cython-ca7f88f\build\lib.win32-2.7>c:\Python27\python.exe
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: Nie mo┐na odnalečŠ okreťlonego modu│u.
>>>
That's strange. Last try: did you also copy the DLLs that are in SFML/extlibs? (I don't see a “DLL loaded failed” message when importing a non-existing module, so my guess is that a dependency can't be loaded.)
I just compiled something that looks like a Win32 module, but I can't get it to work with Wine (it tells it can't find dependent DLLs, even when they are in the current directory).
Can someone test it on Windows and tell me if it works? Here is the direct link: https://github.com/downloads/bastienleonard/pysfml2-cython/sf.pyd
err:module:import_dll Library libgcc_s_sjlj-1.dll (which is needed by L"Z:\\home\\bastien\\Desktop\\pong\\sf.pyd") not found
err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\bastien\\Desktop\\pong\\sf.pyd") not found
Traceback (most recent call last):
File "main.py", line 9, in <module>
import sf
When I try your Pong example with my sf.pyd, I get this:Code: [Select]err:module:import_dll Library libgcc_s_sjlj-1.dll (which is needed by L"Z:\\home\\bastien\\Desktop\\pong\\sf.pyd") not found
err:module:import_dll Library libstdc++-6.dll (which is needed by L"Z:\\home\\bastien\\Desktop\\pong\\sf.pyd") not found
Traceback (most recent call last):
File "main.py", line 9, in <module>
import sf
Could you copy-paste here the command-lines that are issued when you build the binding? I guess I missed something to include the standard libraries.
Also, for some reason the SFML libs I cross-compiled aren't even detected by Wine.
Hey Bastien I've got a question. When I run PySFML apps I have 2 windows - the black console window and the proper app window. Is there a way to get rid of the console window? In SFML there was a special library for that, it would initialize the main function so that the console window does not appear.
Also, I can't find the implementation of sf::Window::EnableVerticalSync. Is it possible to enable vertical sync in PySFML? I see it's only possible to limit the framerate to a fixed value, but how should I know the refresh rate of a given display mode? If I set it to 60, it will be incorrect for those who have 75 of 100 Hz.
CLOSED: 'Closed',
RESIZED: 'Resized',
LOST_FOCUS: 'Lost focus',
GAINED_FOCUS: 'Gained focus',
TEXT_ENTERED: 'Text entered',
KEY_PRESSED: 'Key pressed',
KEY_RELEASED: 'Key released',
MOUSE_WHEEL_MOVED: 'Mouse wheel moved',
MOUSE_BUTTON_PRESSED: 'Mouse button pressed',
MOUSE_BUTTON_RELEASED: 'Mouse button released',
MOUSE_MOVED: 'Mouse moved',
MOUSE_ENTERED: 'Mouse entered',
MOUSE_LEFT: 'Mouse left',
JOYSTICK_BUTTON_PRESSED: 'Joystick button pressed',
JOYSTICK_BUTTON_RELEASED: 'Joystick button released',
JOYSTICK_MOVED: 'Joystick moved',
JOYSTICK_CONNECTED: 'Joystick connected',
JOYSTICK_DISCONNECTED: 'Joystick disconnected'
cdef class Obj:
def python_method(self):
#operations
pass
cpdef cpython_method(self):
#operations
pass
import time
cdef Obj obj = Obj()
i = time.clock()
#cdef int x
for x in range(1000000):
obj.python_method()
f = time.clock()
print "python_method %f" % (f-i)
i = time.clock()
for x in range(1000000):
obj.cpython_method()
f = time.clock()
print "cpython_method %f" % (f-i)
Well, I try this:
(in a pyx file)Code: [Select]
cdef class Obj:
def python_method(self):
#operations
pass
cpdef cpython_method(self):
#operations
pass
import time
cdef Obj obj = Obj()
i = time.clock()
#cdef int x
for x in range(1000000):
obj.python_method()
f = time.clock()
print "python_method %f" % (f-i)
i = time.clock()
for x in range(1000000):
obj.cpython_method()
f = time.clock()
print "cpython_method %f" % (f-i)
I expected a fast loop with cpython_method, but there was only a little speed up. Then uncomment this "#cdef int x" and Voilá. Great speed up!(At least here, hundred of times faster).
I think this is nice i.e. for things like moving the main draw loop (that use Sprite.Draw) in a cython 'for loop'.( Or any other loop that use a lot of python (slow)method calls)
__PYX_EXTERN_C DL_IMPORT(struct __pyx_obj_2sf_RenderStates) *wrap_render_states_instance(sf::RenderStates *);
...tons and tons of warnings...
363 warnings generated.
/Developer/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c hacks.cpp -o build/temp.macosx-10.7-x86_64-2.7/hacks.o
/Developer/usr/bin/clang++ -bundle -undefined dynamic_lookup -L/opt/local/lib build/temp.macosx-10.7-x86_64-2.7/sf.o build/temp.macosx-10.7-x86_64-2.7/hacks.o -L/Users/cdimara/Development/SFML/build-release/lib/sfml-graphics.framework -lsfml-graphics -lsfml-window -lsfml-audio -lsfml-system -o /Users/cdimara/Development/pysfml2-cython/sf.so
ld: library not found for -lsfml-graphics
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/Developer/usr/bin/clang++' failed with exit status 1
Full error log (http://pastebin.com/fedX4Lsr)Ok, for now i can just use the prebuilt version all im using now is clock window and event. I will need the Audio streaming stuff later on though. Will soon be looking into keyboard and joysticks too. Network would be useful at some point down the road but its not really needed for a while.
I found something that would probably be good to fix
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Clock.php
In the documentation for SFML 2 it says Clock.restart() should return the time since the clock was started.
Can you make this return that time also? It should be a pretty quick fix.
Figured it out.
Though its not really detailed on the either the SFML2 or the PySFML2 install page, you need to make sure you uncheck the box saying build frameworks when you generate your unix make files in cmake for SFML2.
After that things work fine.
CMAKE_INSTALL_FRAMEWORK_PREFIX (Mac OS X only)
This is the install path for frameworks. By default, it is defined to the root library, i.e. /Library/Frameworks folder. As stated for CMAKE_INSTALL_PREFIX it is not mandatory to install files after compiling, but it is cleaner to install them.
This path is used to install on your system sndfile.framework (a required dependency not provided by Apple) and SFML as frameworks if BUILD_FRAMEWORKS is selected.
Ok so i have built it in MinGW this time it builds, and i think it runs fine.
The newer version doesn't seem to want to play nicely with another cython module im using for speeding up openGL some. The older build worked fine with it. Any idea's?
Excuse me, but do this binding works with python3?
I'm just confused by the 'cython' word.
AFAIK Cython is just different interpreter for python, isn't it? or it provides a bit different syntax too?
Is there anything in pySFML 2.0 that doesn't map nicely to the C++ version? I am wanting to test it out, but the documentation is a bit lacking in specificity.
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
>>>
__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);
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 (http://www.lfd.uci.edu/~gohlke/pythonlibs/#pysfml2)
@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'
Does this binding work fully with python 3.3? Or only python 2?
Any chance for network module? I know that python itself has socketing library but sfml sockets are much more convenient. For example python-sfml2 has network bindings.
Any chance for network module? I know that python itself has socketing library but sfml sockets are much more convenient. For example python-sfml2 has network bindings.
Which feature would you like, for example? Currently, my opinion is that if you want more than bare sockets, you'll probably be better off using a network-centric Python library like Twisted.