Hi,
Out of curiosity is canvas drawing handled by the GPU, be it on Mac or Windows ?
Thanks.
Hi,
Out of curiosity is canvas drawing handled by the GPU, be it on Mac or Windows ?
Thanks.
Hi @Eric_R ,
I am pretty sure that canvas drawing on Windows OS uses the CPU, and the OpenGL control uses the GPU.
@Eugene_Dakin
Is OpenGL surface still useful/available?
I keep hearing that Macs donât support it, in the same discussions as Metal and Vulkan.
If there is a faster way to get graphics on screen cross platform, Iâd be interested in tryingâŠ
It certainly used to be on the Mac and I donât think thatâs changed, but thereâs no guarantee with Apple PJ.
Back in 10.9 and below, it was possible to get a CGLayer, which lived on the GPU. But it got broke with 10.10 and eventually deprecated:( it was furiously fast.
Canvas drawing is all single threaded CPU. There are feedback requests going back years asking for some sort of cross platform GPU accelerated canvas control but there looks to be no interest from Xojo in this.
OpenGL is deprecated on macOS and I wouldnât be surprised if itâs dropped in the next version of macOS.
I see.
To bad canvas isnât GPU accelerated. Maybe someday someone will come with a solution
if Xojo wont.
Well good to know. Thanks.
For workarounds, you can use declares to draw directly to memory pictures and then in the paint event of the canvas just draw those
Plenty of advice in this forum to NOT do that and put all the drawing code into the Paint event instead.
With a complex diagram, Im not sure.
I might expect a Group2D to really perform, but the lack of discussion here about these graphic objects really make me suspect that Xojo may âforget they existâ at any time, like the SpriteSurface as an example.
looks like you are confused. âAll the drawing code into the Paint eventâ could be a simple
g.Drawpicture(BufferPic, 0, 0, g.width, g.height).
But you can draw to the BufferPic from outside the Paint event (either with declares or xojo code) then, to paint the buffer to the canvas just use a:
Canvas.Ivalidate
Also you can use declaraes inside the pait event.
But you can have multiple buffers, for example one for a background, a couple for some regions that dont change or change not so often, then in the paint event draw the background, the not changing regions and then on top of that the changing part.
This is a way to offloading the drawing event.
I do this a lot, I have for example a method âDrawBkgâ that draws the Background picture (outside the paint event of the canvas), I call it at the start of the app and when the canvas is resized.
(The Background is a Picture Variable in the Window)
looks like you are confused.
No, Iâm not.
Drawing to a picture object and then painting that picture is what I do now and have been doing for years.
But there has been advice to not blit big pictures to the screen, and do it in discrete drawing operations during Paint instead.
I havent spent the time trying that to compare the speeds.
Id like to think Group2d was faster, but that would be a big overhaul
There are several reasons as to why I would not recommend this at all.
Below is what I would recommend.
At some point I need to experiment to see if I can gain a boost moving my drawing code over to using graphics paths, my gut tells me I will.
Hi Eric and @Jeff_Tullin
I wrote a book on Xojo and OpenGL at Program OpenGL Core 32-bit with Xojo on Windows and OSX, and just ran a few example programs on Windows 11, Ubunutu 20.04 LTS, and Raspberry Pi OS, and the examples that I tried all worked. I am not sure about Mac though, and here is a link with some information about Mac and OpenGL: https://support.apple.com/en-us/HT202823
I had to install the following OpenGL libraries on Raspberry Pi:
sudo apt-get install libgles2-mesa libgles2-mesa-dev xorg-dev
Edit: Added Jeff
I dont use Mac. Overlaping xojo controls on windows sucks, so⊠worst performance and flicker.
I did a little looking around and on the Mac - at least in the recent past - drawing to an off-screen buffer uses the CPU while drawing to an on-screen context uses GPU acceleration. This should correspond to drawing to a Pictureâs Graphics property versus responding to a Paint event.
For speed, youâre probably best served doing all of your drawing to the Paint eventâs Graphics parameter, and not drawing to a Picture first. However, this is pretty general advice and you should profile both approaches to see which ones best fits your scenario.