How to use glReadPixels with CanvasGadget ?
Posted: Thu Jun 24, 2021 6:55 pm
I'd like to use glReadPizels to draw the contents of the gl framebuffer to a CanvasGadget. I have tried DraingBuffer(), CanvasOutput() and DrawImage() in various combinations
but with no luck. Any suggestions ? This does not work:
P.S. I can successfully show the contents of the frame buffer on the window's background with eglSwapBuffers().

Code: Select all
CanvasGadget(#Canvas,20,20,500,200)
CreateImage(#Image, GadgetWidth(#Canvas), GadgetHeight(#Canvas), 24)
Code: Select all
If StartDrawing(CanvasOutput(#Canvas))
;buf = DrawingBuffer()
;glReadPixels (0, 0, GadgetWidth(#Canvas), GadgetHeight(#Canvas), #GL_BGR, #GL_UNSIGNED_BYTE, buf)
;glReadPixels (0, 0, GadgetWidth(#Canvas), GadgetHeight(#Canvas), #GL_BGR, #GL_UNSIGNED_BYTE, GetGadgetAttribute(#Canvas, #PB_Canvas_Image))
glReadPixels (0, 0, GadgetWidth(#Canvas), GadgetHeight(#Canvas), #GL_BGR, #GL_UNSIGNED_BYTE, ImageID(#Image))
DrawImage(ImageID(#Image),0,0)
StopDrawing()
EndIf