On 3/25/2010 8:25 AM, Lawson English wrote:
More than likely, this is way too advanced for moi, but I spent about an hour rummaging through the Lumiere code for Pharo and just couldn't grok how the OpenGL rendering is directed to a morph instead of to raw coordinates on the main window. Is there some special property of Pharo that allows this kind of thing, or is there some relatively simple way in Squeak to direct OGL drawing to a morphic surface/canvas/thingie so it renders inside the boundaries of the morph when moved?
There is absolutely nothing to it. All you need is something like here:
MyMorph>>drawOn: aCanvas
"--- initialize opengl ---" ogl ifNil:[ ogl := OpenGL newIn: self bounds. ogl ifNil:[^super drawOn: aCanvas]. ] ifNotNil:[ ogl bufferRect: self bounds. ].
"--- when not rendering to Display, draw last captured frame ---" aCanvas form == Display ifFalse:[ ^aCanvas drawImage: ogl screenShot at: bounds origin. ].
"--- otherwise do normal scene rendering ---" ^self renderScene: ogl.
Cheers, - Andreas