I am working on a project using OpenTK and ImGui.NET, and I'm trying to render a framebuffer to an ImGui image.
my current code: ` protected override void OnLoad() { base.OnLoad();
FBO = GL.GenFramebuffer();
GL.BindFramebuffer(FramebufferTarget.Framebuffer, FBO);
framebufferTexture = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, framebufferTexture);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, ClientSize.X, ClientSize.Y, 0, PixelFormat.Rgb, PixelType.UnsignedByte, IntPtr.Zero);
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, framebufferTexture, 0);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
}
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.BindFramebuffer(FramebufferTarget.Framebuffer, FBO);
GL.ClearColor(new Color4(255, 255, 255, 255));
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
ImGui.DockSpaceOverViewport();
ImGui.Begin("Editor");
ImGui.Image((IntPtr)framebufferTexture,
new System.Numerics.Vector2(CameraWidth, CameraHeight),
new System.Numerics.Vector2(0, 0),
new System.Numerics.Vector2(1, 0),
new System.Numerics.Vector4(1.0f),
new System.Numerics.Vector4(1, 1, 1, 0f));
ImGui.End();
_controller.Render();
SwapBuffers();
base.OnRenderFrame(e);
}
}
}`
I have already set up a framebuffer and associated texture in the OnLoad() and OnResize() methods. The framebuffer is properly bound and cleared in the OnRenderFrame() method. The ImGui controller is also initialized correctly.
I suspect that there might be an issue with the parameters passed to ImGui.Image(), but I'm not sure. Can someone help me figure out how to properly render the framebuffer to the ImGui image?
I've already tryed looking online for a documentation on the opentk framebuffer but I haven't found any.