91
Python / pysfml2-cython
« on: October 24, 2011, 11:56:45 pm »
I keep updating it because people want it, don't hesitate to message me if something needs to be improved.
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.
import glob
import threading
import sf
SPRITES = glob.iglob('/media/winxp/d/images/Textures/2D/TEXTURES/*.BMP')
class ThreadData(object):
def __init__(self, sprites):
self.sprites = sprites
self.join_thread = False
class LoadingThread(threading.Thread):
def __init__(self, data):
threading.Thread.__init__(self)
self.data = data
def run(self):
for i, filename in enumerate(SPRITES):
sprite = sf.Sprite(sf.Texture.load_from_file(filename))
self.data.sprites.append(sprite)
self.data.join_thread = True
print 'Finished loading'
def main():
window = sf.RenderWindow(sf.VideoMode(1280, 1024), 'Title')
window.framerate_limit = 60
sprites = []
thread_data = ThreadData(sprites)
thread = LoadingThread(thread_data)
thread.start()
running = True
while running:
for event in window.iter_events():
if event.type == sf.Event.CLOSED:
running = False
if thread_data.join_thread:
thread.join()
thread_data.join_thread = False
print 'Joined'
window.clear(sf.Color.WHITE)
for sprite in sprites:
window.draw(sprite)
window.display()
if __name__ == '__main__':
main()
import threading
import sf
SPRITES = ['file1.png', 'file2.png']
class LoadingThread(threading.Thread):
def __init__(self, sprites):
threading.Thread.__init__(self)
self.sprites = sprites
def run(self):
for filename in SPRITES:
self.sprites.append(sf.Sprite(sf.Texture.load_from_file(filename)))
def main():
window = sf.RenderWindow(sf.VideoMode(640, 480), 'Title')
window.framerate_limit = 60
sprites = []
thread = LoadingThread(sprites)
thread.start()
# Do some work while the images are being loaded
thread.join()
running = True
while running:
for event in window.iter_events():
if event.type == sf.Event.CLOSED:
running = False
window.clear(sf.Color.WHITE)
for sprite in sprites:
window.draw(sprite)
window.display()
if __name__ == '__main__':
main()
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
First I'd like to thank you for creating PYSFML and giving me more display library options.
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.