Setting different sizes for FBO and canvas window?

102 views
Skip to first unread message

Michaël Chelle

unread,
Jul 18, 2014, 6:39:30 AM7/18/14
to vi...@googlegroups.com
Dear all, 

I have just discovered vispy which I find great.

I apologize if it is not the right place for such a question being a newbie in vispy.

I need to make 3D offscreen calculations to generate large-size  images, rendering on screen being of less interest.

I have started from vispy example both cube_v3.py and hello_fbo.py. 

It works well, except I can not change the size of the FBPO to make it larger (different) than the Canvas window size.  

Some ideas?

Thanks in advance. 

Regards,

Michael 

Almar Klein

unread,
Jul 21, 2014, 7:02:07 AM7/21/14
to vi...@googlegroups.com, mche...@gmail.com
Hi Michael,

You should set the size of each buffer. e.g.

fbo.color_buffer.resize(w,h)
fbo.depth_buffer.resize(w,h)

- Almar
> --
> You received this message because you are subscribed to the Google
> Groups "vispy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to vispy+un...@googlegroups.com
> <mailto:vispy+un...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Almar Klein

unread,
Jul 21, 2014, 8:20:08 AM7/21/14
to GooMike, vi...@googlegroups.com
Hi Michael,

You should probably use the latest version from Github. The latest
release is really outdated.

- Almar

On 21-07-14 14:07, GooMike wrote:
> Hi Almar,
>
> Thanks for your prompt answer.
>
> I have not these objects in the FrameBuffer class, and not the function resize()?
> I have put in PS the help(fbo)
>
> I am using /Library/Python/2.7/site-packages/vispy-0.2.1-py2.7.egg/vispy/
>
> In the same spirit I have tried in Canvas::init():
> self.colorBuff = gloo.Texture2D()
> self.colorBuff.set_shape((20,30,3))
> self.depthBuff = gloo.RenderBuffer()
> self.depthBuff.set_shape((20,30))
> self._fbo = gloo.FrameBuffer(self.colorBuff, self.depthBuff)
>
> without success?
>
> Am I using a too old version?
>
> Another point, I would like to quit the application on some events, but it didn't work, it seems that exceptions are blocked or their action
>
> def on_key_press(self, event):
> print('on_key_press: %s' % event.text)
> if event.text == 'x':
> sys.exit()
> elif event.text == 'q':
> app.quit()
>
>>> on_key_press: x
> Traceback (most recent call last):
> File "can.py", line 339, in on_key_press
> sys.exit()
> SystemExit
> Error invoking callback for event: <KeyEvent blocked=False handled=False key=<Key 'X'> modifiers=() native=None source=<__main__.Canvas object at 0x1068728d0> sources=[<__main__.Canvas object at 0x1068728d0>] text=x type=key_press>
>
> If I try to use app.quit(), it crashed with a segmentation fault:
>>> on_key_press: q
> Segmentation fault
>
> Any idea?
>
> Many thanks in advance,
>
> Regards,
>
> Michaël
>
> PS: Help on FrameBuffer in module vispy.gloo.framebuffer object:
>
> class FrameBuffer(vispy.gloo.globject.GLObject)
> | Representation of a frame buffer object (a.k.a. FBO).
> | FrameBuffers allow off-screen rendering instead of to the screen.
> | This is for instance used for special effects and post-processing.
> |
> | Method resolution order:
> | FrameBuffer
> | vispy.gloo.globject.GLObject
> | __builtin__.object
> |
> | Methods defined here:
> |
> | __init__(self, color=None, depth=None, stencil=None)
> |
> | attach_color(self, object, level=0)
> | Attach a RenderBuffer of Texture instance to collect
> | color output for this FrameBuffer. Pass None for object
> | to detach the attachment. If a texture is given,
> | level specifies the mipmap level (default 0).
> |
> | attach_depth(self, object, level=0)
> | Attach a RenderBuffer of Texture instance to collect
> | depth output for this FrameBuffer. Pass None for object
> | to detach the attachment. If a texture is given,
> | level specifies the mipmap level (default 0).
> |
> | attach_stencil(self, object)
> | Attach a RenderBuffer instance to collect stencil output for
> | this FrameBuffer. Pass None for object to detach the
> | attachment.
> |
> | set_size(self, width, height)
> | Convenience function to set the space allocated for all
> | attachments in use.
> |
> | ----------------------------------------------------------------------
> | Data descriptors defined here:
>
> | color_attachment
> | Get the color attachement.
> |
> | depth_attachment
> | Get the depth attachement.
> |
> | stencil_attachment
> | Get the stencil attachement.
> |
> | ----------------------------------------------------------------------
> | Methods inherited from vispy.gloo.globject.GLObject:
> |
> | __del__(self)
> | Delete the object from OpenGl memory.
> |
> | __enter__(self)
> | Entering context
> |
> | __exit__(self, type, value, traceback)
> | Leaving context
> |
> | activate(self)
> | Activate the object (a GL context must be available).
> | Note that the object can also be activated (and automatically
> | deactivated) by using it as a context manager.
> |
> | deactivate(self)
> | Deactivate the object.
> |
> | delete(self)
> | Delete the object from OpenGl memory.
> |
> | ----------------------------------------------------------------------

GooMike

unread,
Jul 22, 2014, 8:37:26 AM7/22/14
to Almar Klein, vi...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages