On 24 February 2012 01:26, Lawson English <lengli...@cox.net> wrote: > I was experimenting a little bit. What is the best way, using code, to put > an GLViewportMorph into a scrollpane? the things I have tried so far seem to > either crash Pharo or not work as I expect. >
By default GLViewportMorph copying a rendered stuff from gl buffer directly to Display form to avoid extra copying. This trick is not fully compatible with morphic, since it ignoring clipping bounds etc. If you want to have full integration with morphic, first turn on "useOwnForm" flag first then viewport will copy rendered pixels into own buffer, which is then can be used for subsequent drawing on morphic canvas. See GLViewportMorph>>drawOn: aCanvas Probably we should add a bounds checking in NBGLDisplay>>updateForm: aForm bounds: aBounds because if you go outside of form's bounds, you have imminent crash due to memory corruption. What can be done, code can be rewritten to take into account a canvas clipping + origin, to get more correct (and safe) copying of rendered pixels, but still avoiding extra copy to intermediate form. Anyways, i don't like the fact that it copying the rendered stuff from video memory back to main memory, and then copying stuff back to video memory (but this time by morphic + VM). But this was a cheap way to get demo working and morphic integration. If i would be making app which using opengl for rendering, i would never copy things like that, because it just a waste of cycles causing a big impact to frame rate. What works for demo, is not really applicable in serious application. :) In serious app, i'd rather copy morphic Display form into separate texture and then render it along with other stuff, which is already in video memory. But this approach needs more time investments, which currently i don't have, and actually heavily depends on what you want from your app. Anyways, if there's someone who having spare time to fix NBGLDisplay>>updateForm:bounds: implementation to make it safer, i would appreciate that. -- Best regards, Igor Stasenko.