Fastest Way to Draw in Windows?

Over the past couple of releases there has been significant changes to the drawing system in Windows. I have a client app that uses straight canvas drawing via the Paint event and also has the option of using OpenGL. So my questions are thus:

  1. Has the new drawing affected OpenGL in Windows negatively?

  2. What are the recommended best practices to make graphics drawing the fastest it can be?

  3. Is there some other drawing ‘system’ that might be faster? Thinking possibly HTMLViewer? Something else?

Thanks!

Oh, and having a good, steady, frame rate is important on this project. OpenGL on some Windows machines will ‘stutter’ as it starts up.

I have been working on a replacement for moving dozens of custom canvas controls into one control using classes to manage drawing their own parts of the screen. This is being done to combat major display issues on windows when moving controls around and windows firing of repaint events when I don’t want them. Locking and unlocking can only get you so far.

Anyways I have been able to create a system that can animate contol movements smoothly on 5k retina and windows machines in hidpi. The main key is using the invalidate(rect) and only drawing what has to be updated to the window. Now this might not work for you, but we have a custom gui and only small parts change when the user interacts with it.

Basic workflow is during a event ( mouse ,key , timer) store areas as dirty as you process the event. Once the event has completed then look to see if you have any dirty areas and invalidate them using the invalidate rect method. I have a class for each area so before telling canvas it is dirty I can prepare anything for render outside the paint event. After all the dirty areas are invalidated the paint event will contain a nice list of texts to draw into.

This workflow works well on windows when moving the window offscreen and back on as the dirty texts array informs you of the areas that were offscreen.

The fastest rendering of pictures at hidpi is storing a singled layered image at 2x size and scale down in the paint event. Creating and storing 1x and 2x sized images has no speed improvements on windows and is slower on Mac OS.

With this I was able to get 40 - 40 fps on 5k monitor on OSX and slightly faster on windows as the screen was smaller res (surface pro 4)

I haven’t looked into full screen animarions, eg ken burns effects, through a canvas as xojo only added double precision to rendering in last release. It might be able to render that now. I use OpenGL for that currently for the smooth movements.

Since the Xojo updates to drawing on Windows in the last year or so, smooth drawing in the canvas (little/no studdering) is by drawing directly in the paint event. I have not measured much of a speed difference. Frames per second on the canvas have maybe changed from 60 frames per second to 62 FPS.

OpenGLSurface on Windows has seen a significant increase in FPS since the updates in Xojo about a year ago. Depending on the number and size of objects, FPS has increased from about 70 FPS to a range of 90-210 FPS for the exact same program. Studdering is an issue when trying to program windows graphics like Mac graphics. The two timing-draw philosophies are completely different. Timing compensation is necessary on Windows and your programs are rewarded with smooth drawing and exceptionally high frame rates on Windows.

Awesome. Thanks for the info.