Is it possible to implement a control with ability enable/disable OpenGL drawing ? #1647
Replies: 2 comments
-
I do this by adding the control to another view. The control fills the whole view. With a static flag you could set the type of control to use before you create it. On Xamarin.Forms this looks like
Then you have to create two paint surface functions
which go into one drawing function. I hope, this helps. |
Beta Was this translation helpful? Give feedback.
-
I implemented my own class using custom interface Some Canvas implementation class CanvasView : ICanvasControl { DrawShapes(); } Some GL implementation class GlView : ICanvasControl { DrawShapes(); } Then in your code, whenever you want to use acceleration you switch to second implementation, otherwise use the original one. Your app public ICanvasControl GetView() => enableAcceleration ? new GLView() : new CanvasView(); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using SkiaSharp on a work project that involves drawing to a viewport in a windows forms desktop application. The main control that I am drawing to is a custom class that inherits from the SkiaSharp SKControl class. At one point during this project, I changed this class to inherit from SKGLControl in order to introduce hardware acceleration and improve performance. I had a few people test this and it worked fine for most, but some users experienced errors and it seemed like their computer could not properly get an OpenGL context for whatever reason.
With that in mind, I want to attempt to implement a configuration in the application to enable/disable hardware accelerated drawing. However, I can't really think of a way to do that without duplicating my main control class, with one inheriting from SKControl, and the other inheriting from SKGLControl.
Can anyone think of any obvious solutions to this that I might be missing?
Beta Was this translation helpful? Give feedback.
All reactions