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

Author Topic: pysfml-cython  (Read 102877 times)

0 Members and 1 Guest are viewing this topic.

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #30 on: October 13, 2011, 10:51:54 am »
Hello

I would like to make a game using SFML. I've been told that I should not use C++ if I'm not experienced in using this language. As I've done most programming in PHP, it was suggested for me to use Python. I wonder if you could assist me with the following:

1. What functionalities of the C++ SFML have been left out in pysfml2? Is the network package present? If not, is it still possible to make an online game using pysfml2?

2. Would it be problematic to make a multiplatform game using pysfml2? I'm planning to do main coding on Windows, but would like to release linux and OSX versions.

3. What IDE do you recommend for python on Windows? I'd prefer something lightweight.

4. I'm totally new to python. Are programs made in python regular exe files? What is the speed comparison between C++ SFML and pysfml? Will users have to install anything to be able to run my game?

Thanks for your help!

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #31 on: October 13, 2011, 01:02:35 pm »
Hello,

1. Currently streaming isn't available, but it's mainly because I've never needed it personally. Also, I think someone said he was going to write it.
Network features are available in standard Python packages like socket. There are also more complex frameworks like Twisted.

2. Some people have problems building it on Windows. I'll try to upload a Windows binary one of these days, when I have access to Windows.
PySFML is as portable as SFML itself.

3. Emacs and Vim are very popular among Python programmers, but it takes some time to use them efficiently. You don't really need any advanced feature from your editor for Python, so feel free to use whatever editor you're comfortable with, and learn more complex tools later. I've used PyScripter for some time, since it's included with PortablePython.

4. Technically, python programs are .pyc files that are automatically generated when you run e.g. python main.py. Python translates the source to a faster binary language, then executes it.
I expect the speed of SFML and PySFML's classes to be roughly the same, as they are both written in C++ (well, my binding is written in Cython, but it gets translated to C++ before getting compiled and I didn't see any performance problem so far). Your Python code will be slower, and there are also some things that might cause problems for performance-intensive applications. For example, Python objects have to be allocated dynamically, while in C++ you can often create them on the stack.
Users will have to install Python and PySFML, unless you provide them with an installer.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #32 on: October 13, 2011, 07:12:50 pm »
Thanks for a prompt answer. Two comments:

1. Vim? There's a joke: how to generate a random keyboard input? place a user in front of Vim and tell them to exit the program. Vim is waay to hardcore for me. Seriously, there's no good IDE that would have everything in one place?

2. Is there a way to avoid installing Python and still be able to run python applications? For example, the .NET apps require to put a few libraries in the executable folder and that's it.

Geoff

  • Newbie
  • *
  • Posts: 17
    • View Profile
pysfml2-cython
« Reply #33 on: October 14, 2011, 09:37:24 am »
Hello,

1.Personnaly I like to use Eclipse with PyDev plugin. You can benefit of all functionalities of eclipse and it's a multi-platform IDE.
Moreover, pydev debugger works well.

2.PyInstaller is a software that allow to create exe file with all that you need, for multiple target (windows, linux, osx...) so you don't need to have python installed on your computer, but I didn't try.

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #34 on: October 15, 2011, 10:52:58 pm »
Hi Bastien!

I tried to compile the latest PySFML2 from your github page. I have VC++ 2010 Express installed on Windows 7 x64. I've got an error:

Code: [Select]
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


I checked the PATH variable in my command line and I'm sure that C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC was added (this is where the vcvarsall.bat resides).

Going further, I followed a hint on some website to change line 243 of C:\Python27\Lib\distutils\msvc9compiler.py to toolskey = "VS100COMNTOOLS"

This is the result of the compilation:

Code: [Select]
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

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #35 on: October 16, 2011, 07:44:11 pm »
Are you using the latest SFML version from Github? The Texture class is somewhat recent.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

DomtronVox

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
pysfml2-cython
« Reply #36 on: October 16, 2011, 08:56:27 pm »
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

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #37 on: October 16, 2011, 09:55:44 pm »
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.

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #38 on: October 17, 2011, 10:49:41 am »
Quote from: "DomtronVox"
First I'd like to thank you  for creating PYSFML and giving me more display library options :P.


Thanks. ;)

Quote from: "DomtronVox"
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.


With C++ SFML, you can call OpenGL functions if needed.
I chose to not support this currently, mainly because I have very little experience OpenGL. Basically there's no support for the Window package in SFML, you can only use the higher-level classes like RenderWindow.
I think you should look into Pyglet or Pygame. Pyglet is a modern library kind of like SFML, and Pygame is based on SDL.

Quote from: "DomtronVox"
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


On GNU/Linux, it's common to use /usr/local for stuff that you install yourself, so I think it's normal. Otherwise, it may conflict with files installed by the package manager someday. The only problem is that you may need to tell GCC to look for headers in /usr/local/include and the dynamic loader to look for .so in /usr/local/lib. In my case (Arch Linux), I had to add the path in /etc/ld.so.conf.d/.

Quote from: "kolofsson"
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.


I don't really know, there should be a directory in Program Files that contains directories named something like include/headers and lib/libraries.
But from my experience Visual Studio's installation is pretty bloated, I remember it took me some time to find them.
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
pysfml2-cython
« Reply #39 on: October 17, 2011, 05:39:58 pm »
Exceptions now contain the error message with full details (the same message SFML would normally write on the console).
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #40 on: October 17, 2011, 07:17:49 pm »
I'm sorry, this is a little frustrating.

1. I downloaded the fresh SFML from github
2. I compiled Release and Debug in VC++2010.
3. I put all lib files in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
4. I put all dll files in C:\Windows\System32 (no idea if this is right)
5. I downloaded fresh PySFML from girhub
6. I installed cython (no sf.cpp in your newest build)
7. I run setup.py, same list of errors as in the post before.

What am I doing wrong? Has anybody actually compiled this under Windows? As I've got the SFML.NET binding up and running, I'm really considering dumping my Python attempts. It's a shame, cause I really like python after first few looks.

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #41 on: October 17, 2011, 08:12:25 pm »
It looks like you didn't add the headers.
Yes, I think system32 is the right directory for DLLs.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

kolofsson

  • Full Member
  • ***
  • Posts: 100
    • View Profile
pysfml2-cython
« Reply #42 on: October 17, 2011, 11:59:26 pm »
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

DomtronVox

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
pysfml2-cython
« Reply #43 on: October 18, 2011, 03:59:14 am »
Thanks for the quick response.

I have some experience with pygame but I'm not sure of the speed. I have read it's not fast enough to handle projections very well (and it doesn't have native 3d rendering). I have never looked at pyglet. I'll do some research into it.

Thanks for the information!

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
pysfml2-cython
« Reply #44 on: October 18, 2011, 06:51:40 pm »
Quote from: "kolofsson"
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.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython