[squeak-dev] Re: Still pounding head against wall over glReadPixels => external buffer

Andreas Raab andreas.raab at gmx.de
Wed Feb 10 16:58:09 UTC 2010

Lawson English wrote:
> I'm still having problems with my external shared memory thingie. I can 
> evoke the unix shm* calls and obtain a reference to a shared memory 
> buffer and attach it to squeak's heap. I can write into it and read 
> back. I can even attach the same shared memory to two different 
> instances of squeak and write to the buffer in one and read it with the 
> other. What I still cannot figure out is how to take that external 
> buffer and direct the OpenGL>>glReadPixels call to it so that I can draw 
> using squeak and have it become a bitmap for a different application.

Post your code. Using glReadPixels is straightforward, so there must be 
something simple in your code that goes wrong. Simply speaking the 
following should work fine:

"Allocate or obtain shared memory buffer"
xHandle := ExternalHandle allocate: rect width * rect height * 4.

"Convert it to ExternalData"
xData := ExternalData fromHandle: xHandle type: ExternalType void 

"Call glReadPixels"
	glReadPixels: rect left
	with: ogl extent y - rect bottom
	with: rect width
	with: rect height
	with: ogl imagePixelFormat32
	with: ogl imagePixelType32
	with: xData.

This should be all there is to it.

   - Andreas

More information about the Squeak-dev mailing list