Open krychu opened 12 years ago
I currently can't reproduce this bug. Which version pySFML and which platform are you using?
Windows 7 x64, Active Python 2.7 x86, and then prebuild pysfml from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pysfml
this one exactly: pySFML-0.2.1.win32-py2.7.exe [1.5 MB] [Python 2.7] [32 bit] [Aug 18, 2012]
So I guess the last version which one does not have to build from sources. Python crashes and you get the standard windows message 'python.exe has stopped working'.
Thanks for being so prompt.
I can't reproduce the bug with the same version, except I'm on a 64 bits version of Windows/Python. The bug might happen only with specific arguments or when the program is initialized in a certain way. Can you provide a full example that triggers the bug?
This is a minimum setup that reproduces a crash on my machine (just right after starting the script):
import sfml
window = sfml.RenderWindow(sfml.VideoMode(1200, 750, 32), "name", sfml.Style.CLOSE)
window.position = (10,10)
color = sfml.Color.RED
points = [
sfml.Vertex((10,10), color),
sfml.Vertex((500,10), color)
]
running = True
while running:
window.clear(sfml.Color.BLACK)
for event in window.iter_events():
if event.type == sfml.Event.CLOSED:
running = False
window.draw(points, sfml.LINES_STRIP, sfml.RenderStates())
window.display()
and the result: http://snag.gy/0jg1u.jpg
The sample works fine here. I started downloading the 32 bits version of Python to test it, but I got a massive power outage in my village and nearby. :D And now I'm going to have to go to sleep. Sorry for the delay.
I have a few ideas about the bug, though:
RenderStates
object that isn't “empty”?;] Hope the power is back!
I moved sfml.RenderStates() outside the loop:
running = True
render_states = sfml.RenderStates()
while running:
# the rest of the code, and then:
window.draw(points, sfml.LINES_STRIP, render_states)
this resulted in the same crash. So I tried non-empty RenderStates:
render_states = sfml.RenderStates(blend_mode=-1, shader=None, texture=None, transform=sfml.Transform.IDENTITY)
but this also crashed. I'm a bit puzzled, hope you can reconstruct the problem with the 32 bits version. Thanks!
I can reproduce the bug with the 32 bits version. I did some testing and got the same result as you. I'll need to debug on Windows (bleh) to find more information, unless I find a way to reproduce the bug on GNU/Linux.
Thanks! That would be really helpful as this feature is necessary to finalize some important part of the project. I'm sorry you have to use Windows ;)
I've just come across this thread: http://en.sfml-dev.org/forums/index.php?topic=7604.180
perhaps this helps?
I don't think that's related, the problem is about passing a RenderStates
object, not a Shader (or any other type that causes to implicitly invoke RenderStates
' constructor).
The good news is that I'm pretty sure I figured it out, and I hopefully I will have the time to make a new release tomorrow!
Again, sorry for the delay.
I've pushed the changes on Github. Hopefully someone can test it on Windows before I make a new source release, but I understand it's not practical to build the project from source on Windows.
Hi Bastien, Thanks! I tried to build the project on Windows. I downloaded the latest zip of your sources (bastienleonard-pysfml-cython-e0234bd.zip). I had some compilation error regarding the use of BackSpace name - I checked the sfml hpp and found that the name should be Back - so I changed that. Everything compiled well, I overrode the old sfml.pyd with the new one. But then I got an error while trying to run my project:
Traceback (most recent call last):
File "codebase\Tools\LevelEditor\LevelEditor.py", line 1, in
Does this look familiar? Thanks
Well, I guess I managed to fuck up the rc-compatible branch again. This error means that there's another key constant that was wrongly declared. Cython couldn't find the constant in the declkey file, so it assumed it was some kind of Python object, and you get this error at runtime. Maybe you modified the constant in sfml.pyx but not in declkey.pxd? I'll test all that this weekend, probably. I'm also going to consider removing the rc-compatible branch and build source releases from master as needed, since I always manage to mix them up.
Ok, I changed it also in declkey.pxd now, everything compiles nicely, the project run, but there is the same problem as the last time, the app crashes :/
Just did some more testing, and yeah I still get crashes in some cases. I'll try to fix that ASAP, for lack of a more precise estimation...
Thanks Bastien!
Bastien, you left me ;)
Damn, a month already. :( Good thing you reminded me. I found how to fix it, expect a release tomorrow.
Hello,
I just ran into the same bug yesterday I think. I made a tile engine that works with vertex arrays. So then I was trying to use the the tex_coords parameter for the sfml.Vertex constructor, along with a sfml.RenderState holding a texture for the tile atlas. So then when telling the sfml.RenderWindow to draw the vertices (which refer to coordinates on the tile atlas,) I wanted to also pass a sfml.RenderState with the tile atlas texture.
Will your release also include updating the windows installers? :]
If not, then I need some help. With a similar to the above mentioned tile drawing process, I've tried using a sfml.Shader instead of sfml.RenderState with hopes that I can do the same thing I was trying to do before. I set up the most basic fragment Shader I could (I referenced your pysfml-cython / examples / shader / resources / nothing.sfx shader file) and I used it with what I had previously minus the sfml.RenderState. But the tiles that are drawn to the screen are just the colors that I gave the sfml.Vertex constructor color paramter.
Here are the lines of code I've used (from separate functions) for setting up the vertices/shaders and drawing them to the sfml.RenderWindow (this is what I've been referring to in the last paragraph:)
self._mesh[layer].append(sf.Vertex( (tileXPos, tileYPos), sf.Color.RED, (textXPos, textYPos) ))
self._mesh[layer].append(sf.Vertex( (tileXPos+config.TILE_SIZE, tileYPos), sf.Color.WHITE, (textXPos+1, textYPos) ))
self._mesh[layer].append(sf.Vertex( (tileXPos+config.TILE_SIZE, tileYPos+config.TILE_SIZE), sf.Color.BLACK, (textXPos+1, textYPos+1) ))
self._mesh[layer].append(sf.Vertex( (tileXPos, tileYPos+config.TILE_SIZE), sf.Color.WHITE, (textXPos, textYPos+1) ))
shader = sf.Shader.load_from_file("Shaders/pixelShader.txt', sf.Shader.FRAGMENT)
shader.set_parameter('texture', sf.Texture.load_from_file('tileAtlas'+str(layer)+'.jpg'))
tile_Atlas_List.append(shader)
renderWindow.draw(pChunk._mesh[layer], sf.QUADS, tile_Atlas_List[layer])
Any thoughts on what I could be doing wrong? Or is there another way I could go about my task? This is for a Computer Science club at my University too, so I was hoping to get this tool done soon (the semester is going by fast.) This project will likely be going on throughout the next semester too.
I just pushed the fix on both branches. Hopefully someone can test it before I upload a release tomorrow. Otherwise I'll still try to upload it, since it's a pretty big deal and I'm so late on this issue.
@JakeWaffle: I'm not building installers anymore, Christoph does it much better than me: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pysfml I can try to build one, but it's hit or miss (I find a lot of errors that are very difficult to debug can occur when playing with DLLs on Windows). Please create a new issue if you still encounter problems with shaders once this issue is fixed.
Hi Bastien, thanks! I've compiled pyd from master branch and... the bug... seems to be gone! ;]
@JakeWaffle if you wish I can send you my pyd but it is not guaranteed to work on your system. You can give it a try though. I have ActiveState Python 2.7 32bit, windows 7. If you are interested send me your email.
Thanks Bastien, this fix made me really happy ;]
aH! one thing, there was still the problem with the BackSpace name in sfml.pyx and declkey.pxd. Changing BackSpace to Back fixed the problem.
a call:
window.draw(points, sfml.LINES_STRIP, sfml.RenderStates())
crashes the whole app, while the call:
window.draw(points, sfml.LINES_STRIP)
work perfectly. I need to use RenderStates with my own transformation so I need to get the first call working. Is this a known issue? Am I doing something wrong?
Thanks,