Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Adding new Backend

Hey all,

I'm attempting to set-up a new backend that expands pygame for 3D object creation (cubes/spheres/etc.). What files are necessary to add/edit in the source for that? I played around with it last night on a copy of the source code from github and really just want to add a file to the _canvas folder for taking rect/circle parameters and converting them to PyOpenGL 3D objects for testing purposes. Any guidance is much appreciated!

Thanks,
Josh

Comments

  • Hi Josh,

    I'm attempting to set-up a new backend that expands pygame for 3D object creation (cubes/spheres/etc.).

    The way that the legacy backend and Expyriment use PyGame doesn't allow for 3D objects. So I think you will have to re-implement things from scratch (right @fladd?).

    I played around with it last night on a copy of the source code from github and really just want to add a file to the _canvas folder for taking rect/circle parameters and converting them to PyOpenGL 3D objects for testing purposes.

    I would take https://github.com/smathot/OpenSesame/blob/master/openexp/_canvas/legacy.py as a template, copy it to (say) my_backend.py, remove all the legacy-specific content, and re-implement all the functions.

    Then, you can edit the general script of the experiment, and simply set canvas_backend to my_backend.

    Creating a new back-end is not terribly complicated (or at least not the connection with OpenSesame), but it may not be completely self-explanatory either. I'll see if I find time to add a simple page about this to the documentation site.

    For now, the most important thing to know is that the @configurable decorator captures all the style keywords and uses them to set object properties. That's why the style keywords are not actually keywords to the functions in the backend. Does that make sense?

    Cheers!
    Sebastiaan

  • @sebastiaan @imnotamember

    Yes, that is correct. Although we would love to have a native 3D stimulus type in Expyriment that directly operates on OpenGL enabled surfaces! Having this in Expyriment would directly benefit OpenSesame of course.

    Right now we have a base visual stimulus class that operates on PyGame surfaces and has the option to copy surface data to an OpenGL texture.
    My basic plan for the future is to have an additional base stimulus class OpenGLVisual that direcly operates on OpenGL enabled surfaces. Instead of using PyGame's drawing primitives, it would rely on OpenGL drawing primitives (but abstracted of course) - it would, however, still draw on an OpenGL enabled PyGame surface/window. This new base stimulus could support both 2D and 3D objects (based on camera view). From this new base stimulus other stimulus classes could then be inherited (just like all our stimuli now do inherit from Visual), and implement stimulus specific features (e.g. Cube, Sphere, etc.).

    The reasons we haven't started working on this yet are (1) time, and (2) no deep knowledge/experience with OpenGL (I have some - enough to implement what is there right now, but my knowledge in this area is limited).

    So if you are planning to implement a 3D OpenGL stimulus, please also consider for a moment to implement it on the lower Expyriment level, as it would (a) benefit two projects at the same time (i.e. Sebastiaan can wrap it in the xpyriment backend) and (b) would not introduce yet another backend into OpenSesame.

    Please get in touch with us, if you are interested.

Sign In or Register to comment.