Is there a way to use this from C# to draw into a GL or Vulkan area? #1021
Replies: 3 comments 1 reply
-
In case you wonder if you can activate the GTK renderers it totally depends on your GTK installation as this project is just a binding for GTK and calls given C functions from C#. As far as I read the news the new renderers will probably be part of GTK 4.14 which is not yet released. If you build your own set of GTK development binaries including the new renderers there is a chance that the binaries do not have the same name as the ones from the officially supported sources (gnome SDK, msys2, brew). This results in exceptions that the binary can't be found. So it is recommended to build your own set of GirCore binaries. Details can be found in #963. Alternatively you can just wait for the official release and the updated nuget packages. |
Beta Was this translation helpful? Give feedback.
-
Thanks @badcel . At its simplest, my question is really what does GLArea usage via gircore look like? That's what, I think, would help me the most to understand capabilities here. I'm asking because I have some projects running via Eto.Forms which maps to GTK3; it doesn't seem likely they will support GTK4 and I'm looking at options. |
Beta Was this translation helpful? Give feedback.
-
For a test a while back I used OpenTK to import the native OpenGL functions on the respective platform. Of course this isn't using any GTK renderers, it's simply making the GLArea the current GL context for you to write your own renderer. The using Gtk;
public class DrawingArea : GLArea
{
public DrawingArea()
{
CanFocus = true;
SetRequiredVersion(3, 3);
HasDepthBuffer = true;
HasStencilBuffer = true;
}
} using Gtk;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System;
internal class Program
{
class GLBindingsContext : IBindingsContext
{
public IntPtr GetProcAddress(string procName)
{
const string libName = "opengl32.dll";
return FuncLoader.GetProcAddress(FuncLoader.LoadLibrary(libName), procName);
}
}
private static int Main(string[] args)
{
var application = Application.New("org.test", Gio.ApplicationFlags.FlagsNone);
application.OnActivate += (sender, args) =>
{
var window = ApplicationWindow.New((Application)sender);
var drawingArea = new DrawingArea();
// Left click
var gesture = GestureClick.New();
gesture.Button = 1;
gesture.OnPressed += (sender, args) =>
{
drawingArea.QueueRender();
};
drawingArea.AddController(gesture);
window.Child = drawingArea;
window.Show();
// Load GL binding
drawingArea.Context.MakeCurrent();
GL.LoadBindings(new GLBindingsContext());
drawingArea.OnRender += OnRender;
};
return application.Run();
}
private static bool OnRender(GLArea sender, GLArea.RenderSignalArgs args)
{
var rnd = new Random();
GL.ClearColor(rnd.NextSingle(), rnd.NextSingle(), rnd.NextSingle(), rnd.NextSingle());
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
return true;
}
} |
Beta Was this translation helpful? Give feedback.
-
I'm curious whether this has support for the unified renderer, or GL, or Vulkan areas. I didn't see anything obvious, so wanted to ask.
Beta Was this translation helpful? Give feedback.
All reactions