how to get Croquet?

Andreas Raab andreas.raab at gmx.de
Tue Aug 5 21:43:40 UTC 2003


> Ah, this area is the most mysterious one to me. Maybe you can 
> tell me in a few sentences how the rendered image make it's way
> into the squeak world? I mean in X you have this special OpenGL
> visual where all rendering goes to. But in squeak I don't have
> an extra X window on the screen. 

Oh, but you have (heh, heh). You just don't realize it ;-) On Windows, for
example, we create a native Window for doing the OGL rendering (we don't
have to do this for Direct3D but OGL is a bit more complicated) and I think
it's the same on Unix (Bert would be the person to ask). On the Mac we don't
have to because the OGL rendering can be interleaved in a portion of the
main window which simplifies things.

Using a native window is pretty simple for the most part if there weren't
the two issues of OS window handling and compositing within Squeak. OS
window handling is mostly nasty because we need to make sure that we get the
events in the window into the main Squeak event loop and there are some
situations in which we must carefully look at the window to see if it's
still valid. The B3DHardwareEngine actually does that each frame but since
it's cheap you don't notice unless something really gets invalid and the
visual needs to be recreated. This happens (for example) if you collapse and
expand a hardware accelerated morph.

The other nasty issue is that of compositing. The problem is mostly that we
need to do a bit of overlay rendering so that you can actually drag morphs
over the native OS window (and in some situations we even want to "see
through" the 3D area and have Squeak's background appear). The way this is
done is not nice (but it sure works ;-) - if you are interested check out
the methods #restoreMorphicBackground:under: and
#restoreMorphicForeground:above: in B3DHardwareEngine.

Lastly, there's one problem left which is the issue of synchronizing the
redraw of the 3D scene with the World's display cycle. This is handled by
registering the 3D drawing area with Display and make sure that when we
complete an update operation we also do a buffer swap on the 3D area. This
makes sure we run the 3D stuff nicely in sync with Morphic's display cycle.

> So how and where do you transport the bits from the OGL
> visual into the Morph?

Absolutely nowhere and absolutely never. I would be *way* to slow if we
would have to go through anything like glReadPixels or friends. Been there,
tried that, given up. If you want 3D speed you play by the rules of the
hardware and NOT vice versa.

BTW, if you know where and how to look you can even see this ;-) Try the
following: Open a Wonderland and turn on the hardware acceleration. Make it
nice and large. Then take some morph and put it on top of the 3D area. To
see what Squeak's Display _really_ looks like at that point do something
like:

	BMPReadWriter putForm: Display onFileNamed: 'display.bmp'.

Then close the wonderland and look at that "screenshot" ;-)

Cheers,
  - Andreas




More information about the Squeak-dev mailing list