[squeak-dev] Re: Still pounding head against wall over
glReadPixels => external buffer
doconnel at gmail.com
Thu Feb 11 16:53:48 UTC 2010
Lawson, I have not been following this thread closely so I'm probably
wrong but should you be using "xData byteAt:..."? xHandle doesn't make
sense to me.
On 11/02/2010 15:45, Lawson English wrote:
> Hi Andreas. Even if I use a normally allocated bit of memory, I can't
> get it to work:
> xHandle := ExternalAddress allocate: 100 * 100 * 4. "create external
> buffer handle"
> xData := ExternalData fromHandle: xHandle type: ExternalType void
> asPointerType. "convert for use with glReadPixels"
> ogl := OpenGL newIn: (0 at 0 extent:100 at 100). "create ogl context"
> ogl glClearColor(0.2, 0.9, 0.7, 0.5). "set clear color"
> ogl glClear(16r4000). "clear backbuffer"
> ogl swapBuffers. "draw to screen"
> ogl "read pixels into my buffer"
> glReadPixels: 0
> with: -100
> with: 100
> with: 100
> with: ogl imagePixelFormat32
> with: ogl imagePixelType32
> with: xData.
> xHandle byteAt: 1000=> 0 "print byte value in my buffer???"
> xHandle byteAt: 1000 put: 10 "manually set byte value in my buffer"
> xHandle byteAt: 1000 => 10 "print byte value in my buffer???????"
> Andreas Raab wrote:
>> 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