picoe / eto.opentk Goto Github PK
View Code? Open in Web Editor NEWEto OpenGL viewport (C#)
License: MIT License
Eto OpenGL viewport (C#)
License: MIT License
No text.
What I'm told was a miscommunication among the OpenTK developers was resolved a few months ago, and since then they've been accepting PRs with bug fixes and minor changes to the 3.0 branch of their project. A few days ago they prepared a release, and version 3.1 has been made available on NuGet.
The fix I think would be most useful regards creating GL contexts in Windows (a bug prevented RenderDoc from connecting properly), but there are several others. I'm not sure what impact any of them will have on Eto.OpenTK, especially since I know you've mentioned it's in use in at least one commercial project, and in the meantime I imagine the rest of us can use binding redirects, but I think it'd be worth considering an upgrade to the latest OpenTK release if the changes seem acceptable.
For a live renderer i use the following code:
private class ContinuousGlSurface : GLSurface
{
private const int FrameDelay = 1000 / 60;
private readonly Stopwatch stopwatch;
public Action RenderLoop;
public ContinuousGlSurface(GraphicsMode graphicsMode, int major, int minor, GraphicsContextFlags graphicsContextFlags)
: base(graphicsMode, major, minor, graphicsContextFlags)
{
this.stopwatch = Stopwatch.StartNew();
}
protected override void OnDraw(EventArgs args)
{
base.OnDraw(args);
if (this.stopwatch.ElapsedMilliseconds >= ContinuousGlSurface.FrameDelay)
{
this.stopwatch.Restart();
this.RenderLoop();
}
this.Invalidate(false);
}
}
This works flawless.. basically, because it only works properly with either single buffering (due to frameswap glitches), or not using the stopwatch because not using it will results in rendering as fast as your pc can.
So this works till suddenly out of nowhere a random (sometimes after seconds, sometimes after minutes) crash appears:
OpenTK.Graphics.GraphicsContextException: Failed to make context 65537 current. Error: 2004
at OpenTK.Platform.Windows.WinGLContext.MakeCurrent(IWindowInfo window)
at OpenTK.Graphics.GraphicsContext.MakeCurrent(IWindowInfo window)
at Eto.OpenTK.WinForms.WinGLUserControl.MakeCurrent()
at Eto.OpenTK.Wpf.WpfWinGLSurfaceHandler.MakeCurrent()
at Eto.OpenTK.Wpf.WpfWinGLSurfaceHandler.UpdateView()
at Eto.OpenTK.Wpf.WpfWinGLSurfaceHandler.<AttachEvent>b__7_2(Object sender, PaintEventArgs e)
at System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
at Eto.OpenTK.WinForms.WinGLUserControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
When searching for that crash, i came across this one: MonoGame/MonoGame#3196
Which looks quite similar.
Draws and updates fine after that, it seems.
We need to add an implementation for Eto.Gtk, which is the preferred platform vs. Eto.Gtk2 or Eto.Gtk3.
Hey @philstopford, I have some things I'd like to discuss regarding this project. I know in the past you have said it would be no problem for me to bring it into the "officially supported" fold, and that's what I'd like to do. Namely, the following:
What are your thoughts? Would you like to keep the official repo here, or does this sound okay to you? I'm also open to other ideas if you or anyone else has any.
I am seeing a black screen appear on the Mac version when I use etoViewport in a complex layout. When exactly the viewport turns black is not clear to me but I think it has something to do with when the viewport has a definite size in the UI when it is first rendered. For example if I make the following small change to TestEtoGl.XamMac/MainForm.cs (running from TestEtoGl.Mac):
I see the following:
But if I remove the Begin/EndVertical it renders fine. Needless to say this unpredictability makes it very difficult to create layouts.
When I trying to install the Eto.OpenTK 0.1.2 package in a .NET Core 3.1 Eto.Forms application, I get a NuGet warning NU1701 Package 'Eto.OpenTK 0.1.2' was restored using '.NETFramework, Version = v4.6.1, .NETFramework, Version = v4.6.2, .NETFramework, Version = v4.7, .NETFramework, Version = v4.7.1, .NETFramework, Version = v4.7.2, .NETFramework, Version = v4.8 'instead of the project target framework '.NETCoreApp, Version = v3.1'. This package may not be fully compatible with your project
.
To eliminate this warning, as well as the application startup error (System.IO.FileNotFoundException: 'Could not load file or assembly' OpenTK, Version = 3.0.1.0, Culture = neutral, PublicKeyToken = ...'
) I tried to update OpenTK to version 4.0.0 in all of projects contained in this repository, having previously changed TargetFramework
property in Eto.OpenTK, Eto.OpenTK.Gtk2, Eto.OpenTK.Mac64, Eto.OpenTK.WinForms, Eto.OpenTK.Wpf projects from net45
to netcoreapp3.1
. After that, throughout the solution, I updated OpenTK to version 4.0.0.
It turned out that version 4.0.0 lacks the GraphicsMode
class (used, for example, in WpfWinGLSurfaceHandler.cs), so the projects could not be rebuilt.
How difficult would it be to move from .NET Framework to .NET Core for this project and move from OpenTK 3.0.1 to 4.0.0 given changes in the new version?
Currently I use Eto.Forms 2.5.6, Eto.Platform.Wpf 2.5.6.
Post-build, within the Debug/Release folder:
cp OpenTK.dll TestEtoGl.XamMac.app/Contents/MonoBundle/
Then the app will run.
Haven't figured out why the OpenTK.dll library in the bin folder isn't packaged in the app properly.
Could not load type of field 'TestEtoGl.TestViewport:polyArray' (6) due to: Could not resolve type with token 01000019 (from typeref, class/assembly OpenTK.Vector3, OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4) assembly:OpenTK, Version=3.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4 type:OpenTK.Vector3 member:<none>
Hello and thank you for your awesome work with Eto.OpenTK. I use it alot.
I found your implementation of panning to be very sluggish. Especially considering zooming works very well. I made the following improvements to the dragHandler function in the TestViewport class:
float new_X = (ovpSettings.cameraPosition.X - (((float)e.Location.X - x_orig) * ovpSettings.zoomFactor));
float new_Y = (ovpSettings.cameraPosition.Y + (((float)e.Location.Y - y_orig) * ovpSettings.zoomFactor));
ovpSettings.cameraPosition = new PointF(new_X, new_Y);
x_orig = e.Location.X;
y_orig = e.Location.Y;
Simply exchanging the arbitray scaling factor in new_X and new_Y for ovpSettings.zoomFactor and updating x_orig and y_orig gives panning a feeling of moving a surface with the mouse. Much more pleasant!
Thank you
When positioning any element on top of a GLSurface, the GLSurface itself is still rendered on top.
Silently fails to complete the launch. Cause not understood yet.
I am currently using the following nuget packages:
I basicaly have my own layout engine attached, which reacts on window size changes and updates all elements in a PixelLayout container. Everything works so far, however when updating GlSurface.Size additional memory is consumed which is not freed anymore. The impact seems larger on larger sizes.
When just commenting out the assignments of the size, the memory leak is gone.
When using any other control, for example a button, this problem is gone too, so its tied to GlSurface only.
When I'm trying to start the project with the lastest VisualStudio for Mac the XamMac part won't work.
The MonoMac project still works perfect.
The exeption raises in MacGLView8.cs
in Line 95: context = new GraphicsContext(mode, windowInfo, major, minor, flags);
It's an OpenTK.Graphics.GraphicsContextException
: The specified window isn't an OpenGL window
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.