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

Lawson English lenglish5 at cox.net
Thu Feb 11 15:45:27 UTC 2010


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 
> asPointerType.
>
> "Call glReadPixels"
> ogl
>     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.
>
> Cheers,
>   - Andreas
>
>




More information about the Squeak-dev mailing list