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 - gaulois94

Pages: 1 [2] 3
16
Python / Re: Somes problems with sf.Event
« on: June 02, 2013, 10:57:03 am »
#!/usr/bin/python3
#-*-coding:utf-8-*-

import sfml as sf

class Window(sf.RenderWindow):
    def __init__(self, MODE, STRING):
        sf.RenderWindow.__init__(self, MODE, STRING)

window = Window(sf.VideoMode(800,600,32),"teste")
window.framerate_limit = 60

check = sf.CircleShape(20)
check.position = sf.Vector2()

while window.is_open:
    for event in window.events:
        pass

    window.clear()
    window.draw(check)
    window.display()

Sorry, I created a EventManager but don't use it. Maybe is my last sfml version the problem (I used the official 2.0).

Sorry again :) .

17
Python / Re: Somes problems with sf.Event
« on: June 01, 2013, 10:00:28 pm »
Sorry for insisting, but can you fix this problem soon ?

18
Python / Re: Somes problems with sf.Event
« on: May 06, 2013, 11:23:45 pm »
Maybe. I have a little script who realize the same problem !

#!/usr/bin/python3
#-*-coding:utf-8-*-

import sfml as sf

class Window(sf.RenderWindow):
        def __init__(self, MODE, STRING):
                sf.RenderWindow.__init__(self, MODE, STRING)

window = Window(sf.VideoMode(800,600,32),"teste")
window.framerate_limit = 60
event = EventManager(window)

check = sf.CircleShape(20)
check.position = sf.Vector2()

while window.is_open:
        for event in window.events:
                pass
        window.clear()
        window.draw(check)
        window.display()

note that if you resize the window, the view is not resize correctly (see where de Circle is and where it should be)

Thank you :) .

19
Python / Re: Somes problems with sf.Event
« on: May 05, 2013, 08:09:11 pm »
test2.py works fine (it don't use others modules). The problem is test.py : it yield a segmentation fault 1 test all of 2 tests, and I don't know why... And yes I use python3.3

20
Python / [Solved] Somes problems with sf.Event
« on: May 04, 2013, 07:00:39 pm »
It's me again :D

Well, today I have fix somes of my problems and only one survive. When I launch my script (test.py : see src.zip), only one time on two the script doesn't throw a segmentation fault. After many and many test, I found the problem :

TypeError: 'sfml.window.ResizeEvent' object is not iterable

When I do (on EventManager.update() ) :

for event in window.events:
    some code....

At the beginning, the window is resize. If the first test doesn't yield an error, I can resize my window, here isn't the problem : the problem is that an event can't be a sf.ResizeEvent for the first (and only the first) test I think (I'm not sur for 100% ).

with GDB, I have this errors on the traceback (always one time on two) :

Program received signal SIGSEGV, Segmentation fault.
PyObject_GetAttrString (v=0x6d00000005750000, name=0x7ffff1d244c8 "on_resize") at Objects/object.c:819
819     Objects/object.c: Aucun fichier ou dossier de ce type.
 

You can find the source on the attachment (the most importante in this sources are the property and the updates functions only). Maybe the problem is that my guiml.Window inherite from sf.RenderWindow, I don't know... (Indeed, with a sf.RenderWindow, I don't have this problem).

Thank you and sorry for desagrements :) .

[attachment deleted by admin]

21
Python / Re: python-sfml
« on: May 04, 2013, 11:02:38 am »
The sources were in attachments x) (src.zip...).
Well sorry for the desagrements and for my bad english (I post here because this forum is more active than the french forum ;) ).
I will open a new topic :)

22
Python / Re: python-sfml
« on: May 03, 2013, 06:49:06 pm »
But I nead this inheritance... Indeed, in the "Render" class, I write on the sf.RenderTarget.view, and if the Windows doesn't have the same view of sf.RenderTarget....

But the Leonard binding have this inheritance, why ?

And sorry for this question but what are the differences between pur and extension python classes

edit : Ah.... Leonard choose the sf.RenderTarget as root class for sf.RenderWindow. I think is better  (because  sf.Window is only useful for sf.RenderWindow (when sf.RenderTarget is useful for sf.RenderTexture and Window). And the script for archlinux is good : it take the last source, compile it and install.

edit2 : you can let this way for inheritance : I find a way with super :) .

Please, can you teste this code for me ? The script is "test.py" writing with python3 . Thank you :)



[attachment deleted by admin]

23
Python / Re: python-sfml
« on: May 03, 2013, 04:48:23 pm »
I'm on archlinux and then I use the package python-sfml-git .
Please, see my last edit :)
And for the error, with a sf.RenderWindow basic (without inheritance) I don't have this error.

My code :
mport sfml as sf
from Render import Render
from EventManager import EventManager
from Image import Image

class Window(Render, sf.RenderWindow):
        """This class create a window
        Cette classe créé une fenêtre"""


        def __init__(self, videoMode, title, parent=0, framerateLimit=60,\
                        backgroundColor = sf.Color.BLACK, backgroundImage = Image()):

                sf.RenderWindow.__init__(self, videoMode, title)
                Render.__init__(self, parent, sf.Rectangle(sf.Vector2(),\
                                videoMode.size), backgroundColor, backgroundImage)

                self._isStaticToView = False
                self.position = (0,0)
                self.framerate_limit = framerateLimit
                self._event = EventManager(self)
                #self.resetView()
                #self.clear(backgroundColor)

        def updateFocus(self):
                return;

        def update(self):
                """Update the Window. It Update all event, and update framerate.
                It Draw and display also all widgets child"""

                if self.isDrawing:
                        self._event.update()
                        self._framerate = 1/(self.event.elapsedTime*10**-6)

                        if self.event.isResize:
                                Widget.resizeWidget(self.event.defaultWindowSize,\
                                                self.event.newWindowSize)
       
                        Widget.widgetFocus =  None
                        Updatable._focusIsChecked = False

                        self.clear(self.backgroundColor)

                        if self.event.isMouseInRect(self.rectOnScreen):
                                Updatable.updateFocus(self)
                        Widget.update(self, self)
                        self.display()

       #It's not the most importante

        def getEventFromRootParent(self):
                return self._event

        def _setSize(self, size):
                Widget.size = size
                sf.RenderWindow.size = size
                self._imageBackground.scale = sf.Vector2f(\
                                size.x/self._imageBackground.local_bounds,\
                                size.y/self._imageBackground.local_bounds)

        def getPosOnScreen(self, *args):
                return sf.Vector2f(0,0)

        def setPos(self, position, *args):
                Widget.setPos(position, False)
                self.position = position

        def _setView(self,view):
                sf.RenderWindow.view.__set__(self, view)
                Render._setView(self,view)
       
        def _resizeWidget(self, pos, size):
                self._size = size
       
        size = Widget.size
        event = property(lambda self:self._event)
        framerate = property(lambda self:1/self._event.elapsedTime*0.001)
        setPosOnScreen = setPos

and Render (abstrate class)
import sfml as sf
from Image import Image
from Widget import Widget
from copy import copy
import functions

class Render(Widget):
        """Basic virtual class for all Render's class"""

        def __init__(self, parent, rect, backgroundColor=sf.Color.BLACK,\
                        title=str(), backgroundImage=Image()):
                Widget.__init__(self,parent, rect)
                self.canFocus = False
                self.backgroundColor = backgroundColor

        def show(self, render):
                raise NotImplementedError

        def moveView(self, move):
                newView = self.view
                newView.move(move.x, move.y)
                self.view = newView

        def zoomView(self,zoom):
                newView = self.view
                newView.zoom(zoom)
                self.view = newView

        def resizeView(self, size):
                self.view.size(size)
                self.view = self.view

        def resetView(self):
                self.view = self.default_view

        def setViewSize(self, size):
                newView = self.view
                newView.size = size
                self.view = newView

        def setViewPosition(self, pos):
                viewCopy = self.view
                viewCopy.center = sf.Vector2(pos - self.view.size / 2)
                self.view = viewCopy

        def setViewport(self, viewport):
                viewCopy = self.view
                viewCopy.viewport = viewport
                self.view = viewCopy

        def getViewPosition(self):
                return sf.Vector2(self.view.center[0],self.view.center[1]) + \
                                sf.Vector2(self.view.size[0],self.view.size[1]) / 2

        def getSommeViewPosition(self):
                render = Widget.getRender()
                rect = self.getViewRectWithZoom()
                if isinstance(render,Render):
                        return sf.Vector2(render.getSommeViewPosition() +\
                                        sf.Vector2(rect.left, rect.top))
                else:
                        return sf.Vector2(rect.left, rect.top)

        def getViewRect(self):
                return sf.Rectangle(self.getViewPosition(), self.view.size)

        def getViewRectWithZoom(self):
                viewRect = self.getViewRect()
                scale = self.getViewScale()
                return sf.Rectangle(\
                                sf.Vector2(viewRect.left*scale.left, viewRect.top*scale.top),\
                                sf.Vector2(viewRect.width * scale.width,\
                                        viewRect.height * scale.height))

        def getRender(self):
                return self

        def isInView(self,rect):
                return functions.rectCollision(rect,self.view.viewport)

        def getViewScale(self):
                return sf.Rectangle(sf.Vector2(self.viewport.left*self.view.size.x+1,\
                                self.viewport.top * self.view.size.y + 1),\
                                sf.Vector2(self.viewport.width / \
                                        (self.view.size.x / self.size.x),\
                                        self.viewport.height / (self.view.size.y / self.size.y)))

        def _setBackgroundImage(self, backgroundImage):
                self._backgroundImage = backgroundImage
                self._backgroundImage.pos = sf.Vector2(0,0)
                self._backgroundImage.size = self.size
                self._backgroundImage.setParent(self.parent, 0)
       
        def _setView(self, view):
                back = self.getViewRectWithZoom()
                back = sf.Vector2(back.left, back.top)
                sf.RenderTarget.view.__set__(self,view)

                for child in self._child:
                        if isinstance(child,Widget) and child.isStaticToView:
                                child.setPos(child.pos - back)

        def _setViewport(self, rect):
                newView = copy(self.view)
                newView.viewport = rect
                self.view = newView

        def _setTitle(self, title):
                self._title  = title

        size = Widget.size
        backgroundImage = property(lambda self:self._backgroundImage,\
                        lambda self,image: self._setBackgroundImage(image))
        viewport = property(\
                        lambda self:sf.RenderTarget.view.__get__(self).viewport,\
                        lambda self,rect : self._setViewport(rect))
        title = property(lambda self:self._title,\
                        lambda self,title : self._setTitle(title))
       
        view = property(lambda self:sf.RenderTarget.view.__get__(self),\
                        lambda self,view : self._setView(view))
 

The most importante here are : constructors, updates functions and properties.

24
Python / Re: python-sfml
« on: May 03, 2013, 04:19:37 pm »
Hi again,

I have an error when I want to iterate on sf.RenderWindow.events :
AttributeError: 'code' object has no attribute 'on_resize'
I use the last source update...

Thank you.

édit : Sorry again, but in the source, why sf.RenderWindow isn't inheritate from sf.RenderTarget ?  I need this... Thank you again :)

25
Python / Re: python-sfml
« on: May 02, 2013, 10:37:46 pm »
Hi, please, why can't we create a sprite without a texture ? (with a default constructor like sfml) ? I want to create by default a sprite without a texture... We can't also create a default Texture without source...

26
Python / sfml.View.viewport ? (pysfml-cython)
« on: May 02, 2013, 09:49:44 pm »
Hello,

Well I'm training and working with bastien's pysfml2.0 and I test what doing the sfml.View.viewport. When I do this :

window.view.viewport = sf.FloatRect(0,0,0.5,0.5)

It's the same thing than if I tried to zoom of 2 my view. But, if I correctly understood the documentation, It have to zoom of 0.5, right ? (here,, my drawables are tiny and their position (in the window) near to the center, instead of they are big and far of the center of my view).

Oh, and a last thing : why the center and the size of a view is a tuple and not a sf.Vector2f ?

Well, thank you :) .

27
Python / Re: Compilations errors
« on: January 23, 2013, 08:36:15 pm »
OK, I will wait then. Thank you for your answer.

28
Python / Compilations errors
« on: January 22, 2013, 08:30:01 pm »
Hello,

First, sorry for my bad english, as you can see, I'm not english. Well, I have a problem when I want to compile pysfml. I'm on archlinux, and my sfml version is update.

Well, the errors are the followings :

running build
running build_ext
cythoning src/sfml.pyx to src/sfml.cpp
building 'sfml' extension
creating build
creating build/temp.linux-x86_64-3.3
creating build/temp.linux-x86_64-3.3/src
gcc -pthread -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.3m -c src/sfml.cpp -o build/temp.linux-x86_64-3.3/src/sfml.o
cc1plus: attention : command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_7Texture_12bind(__pyx_obj_4sfml_Texture*, int)’:
src/sfml.cpp:27247:84: erreur: no matching function for call to ‘sf::Texture::bind(sf::Texture::CoordinateType)’
src/sfml.cpp:27247:84: note: candidate is:
In file included from /usr/include/SFML/Graphics/Font.hpp:33:0,
                 from /usr/include/SFML/Graphics.hpp:35,
                 from src/sfml.cpp:264:
/usr/include/SFML/Graphics/Texture.hpp:454:17: note: static void sf::Texture::bind(const sf::Texture*, sf::Texture::CoordinateType)
/usr/include/SFML/Graphics/Texture.hpp:454:17: note:   no known conversion for argument 1 from ‘sf::Texture::CoordinateType’ to ‘const sf::Texture*’
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_6Shader_16bind(__pyx_obj_4sfml_Shader*)’:
src/sfml.cpp:39040:30: erreur: no matching function for call to ‘sf::Shader::bind()’
src/sfml.cpp:39040:30: note: candidate is:
In file included from /usr/include/SFML/Graphics.hpp:41:0,
                 from src/sfml.cpp:264:
/usr/include/SFML/Graphics/Shader.hpp:471:17: note: static void sf::Shader::bind(const sf::Shader*)
/usr/include/SFML/Graphics/Shader.hpp:471:17: note:   candidate expects 1 argument, 0 provided
src/sfml.cpp: At global scope:
src/sfml.cpp:34929:39: attention : ‘__pyx_obj_4sfml_Vertex* __pyx_f_4sfml_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
error: command 'gcc' failed with exit status 1
 

Thank you for your attention.

29
Python / Re: Compilation failed : sf::Shader::unbind doesn't exist
« on: November 04, 2012, 10:40:32 pm »
OK, thank you. I will wait the update.

Just to know, why did you remove this function ?

30
Python / Compilation failed : sf::Shader::unbind doesn't exist
« on: November 04, 2012, 10:04:00 pm »
Hi everybody,

First, sorry for my bad english, I'm not used to writing in english. Why I post here and not in the french forum ? Because here is more active and I try to perform my english.

Well, I have a problem with de pysfml compilation : gcc can not find the member unbind in sf::Shader class. I have tried to launch patch.py but it didn't work. I use the latest sfml source (from git) and use python3 too.

Here it's the exact error :

If the build fails, run patch.py and try again
----------------------------------------------

running build
running build_ext
building 'sfml' extension
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.3m -c src/sfml.cpp -o build/temp.linux-x86_64-3.3/src/sfml.o
cc1plus: attention : command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
src/sfml.cpp: In function ‘PyObject* __pyx_pf_4sfml_6Shader_20unbind(__pyx_obj_4sfml_Shader*)’:
src/sfml.cpp:39367:25: erreur: ‘class sf::Shader’ has no member named ‘unbind’
src/sfml.cpp: At global scope:
src/sfml.cpp:34862:39: attention : ‘__pyx_obj_4sfml_Vertex* __pyx_f_4sfml_wrap_vertex_instance(sf::Vertex*)’ defined but not used [-Wunused-function]
error: command 'gcc' failed with exit status 1
 

Thank you in advance.

Pages: 1 [2] 3