These are chat archives for opentk/opentk

3rd
Apr 2018
ThomasD13
@ThomasD13
Apr 03 05:22
image.png
@sourceskyboxer where is your GL.SwapBuffers command?
And a question to all: Is this the correct channel to ask about GTK?
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 09:32
Yes @ThomasD13 I ask because I don't understand why WaveEngine Team has goal Gtk Sharp 2 and OpenTK under Linux and Mac via Change color of GL.ClearColor(); But I don't see where is command of changing color with ColorSelectionDialog . Like I said : alt
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 09:39
ThomasD13
@ThomasD13
Apr 03 11:12
Again I ask: Where is your GL.SwapBuffers command?
Debug your code, if its get executed after you changed your color.
I recommend to use gDebugger. You can see all the executed OpenGL-Commands in their incoming order.
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 11:27
If you don't know than you can check OpenTK's Github GLWidget has SwapPuffers() from override method Render
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 11:48
But why do I need IWindowInfo? How do I understand?
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 12:35
Unhandled Exception: OpenTK.Graphics.GraphicsContextMissingException: No context is current in the calling thread (ThreadId: 1).
   at OpenTK.Graphics.GraphicsContext..ctor(ContextHandle handle, GetAddressDelegate getAddress, GetCurrentContextDelegate getCurrent) in C:\Users\SSB\Downloads\opentk-develop\opentk-develop\src\OpenTK\Graphics\GraphicsContext.cs:line 240
   at PowerEditor.Examples.ChangeTriangleAndBackgroundWindow..ctor() in C:\Users\SSB\Documents\Visual Studio 2017\Projects\PowerEngine\PowerEditor\Examples\ChangeTriangleAndBackgroundWindow.cs:line 108
   at PowerEditor.Program.Main(String[] args) in C:\Users\SSB\Documents\Visual Studio 2017\Projects\PowerEngine\PowerEditor\Program.cs:line 32
The program '[11324] PowerEditor.exe' has exited with code 0 (0x0).
Why does it not work if I want swapPuffers()
ThomasD13
@ThomasD13
Apr 03 13:47
I use GLWidget, therefore I use GL.SwapBuffers(). I don't know what you are using. If you work with GameWindow, I suppose GameWindow.SwapBuffer() sounds not to wrong.
Again, as I'm not a wizard I can only guess what you are doing without complete sourcecode.
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 14:01
Hello @ThomasD13 please open my gist it has 2 souces ChangeTriangleAndBackground.cs and Program.cs
There are sources not using GameWindow
I am using Gtk Sharp 3 like they used Winforms with GLControl... Please understand me correctly
ThomasD13
@ThomasD13
Apr 03 14:58
Okay I understand you now. I'm not sure about RGBA/255, and
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 15:56
okay. No problem you can pack up downloaded WaveEngine Deb package and unpack 7-zip and open WaveEngine.Adapter.dll in ILSpy and you find Graphics.cs ( WaveEngine.OpenGL -> Graphics. )
But where is access to changing color by Gtk's ColorSelectionDialog to GL.ClearColor(). You think I need more advanced coding like WaveEngine.Adapter.dll or MaterialEditor.exe
ThomasD13
@ThomasD13
Apr 03 16:03
RGBA/255 is fine. Values should be [0..1]. I just can you tell about my previous problems. And one was a forgotten GL.SwapBuffers() call. Therefore I highly suggest you to trace which OpenGL-calls your application really does. There you will see, if after Gl.ClearColor will follow a SwapBuffer.
And the reason, why I stress that point (SwapBuffer), is simply cause I had this mistake also in my previous code.
Either you will further debate what should be and can be, or you just trace your application and see WHAT IT REALLY DOES. And fix it afterwards.
I don't have the time to reverse engineer any dlls, which I don't know how they relate to your specific problem.
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 16:09
Yeah it is not hacking just I search like other program WaveEngine because WaveEngine used Gtk Sharp 2.12 - I tried with Gtk Sharp 3.22.x Thank you for explanation. I will add SwapBuffers() I will check ILSpy if you're right about important SwapBuffers()
ThomasD13
@ThomasD13
Apr 03 16:09
At the first glance I see no problem with your code. Except of the SwapBuffers() but I have no time now to investigate this "deeply".
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 16:17
image.png
Found in OpenTKWidget like GLWidget only. SwapBuffers() not outside of classes.
chatbridge
@chatbridge
Apr 03 18:39
(Discord) Hawk: How do I switch between windowed and fullscreen window in opentk?
(Discord) winterhell: this.WindowState = WindowState.Fullscreen;
(Discord) Hawk: Oh lol, I dunno how i didn't see it.. thank you
(Discord) winterhell: no prob
(Discord) winterhell: To go back you might use WindowState.Normal or WindowState.Maximized
(Discord) winterhell: Up to you
chatbridge
@chatbridge
Apr 03 18:45
(Discord) Hawk: yeah I just wasn't finding the property, though it was in native window for a sec
(Discord) winterhell: It is
(Discord) winterhell: GameWindow inherits it from NativeWindow
ThomasD13
@ThomasD13
Apr 03 19:33
@sourceskyboxer , okay. And Render() gets called after you invoke ClearColor() ?
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 21:06

@chatbridge You don't understand what I am using? I am using only Gtk Sharp 3 + OpenTK.

@ThomasD13 Sure I will try...

Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 21:16
@ThomasD13 I already tried:
Marshaling render signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Runtime.InteropServices.Marshal.ReadInt64(IntPtr ptr, Int32 ofs)
   at GLib.GType.ValFromInstancePtr(IntPtr handle)
   at GLib.ObjectManager.GetTypeOrParent(IntPtr obj)
   at GLib.ObjectManager.CreateObject(IntPtr raw)
   at GLib.Object.GetObject(IntPtr o, Boolean owned_ref)
   at Gtk.ColorSelectionDialog.get_ColorSelection()
   at PowerEditor.Examples.ChangeTriangleAndBackgroundWindow.<onChangeBackgroundHandler>b__33_1(Object <p0>, RenderArgs <p1>) in C:\Users\SSB\Documents\Visual Studio 2017\Projects\PowerEngine\PowerEditor\Examples\ChangeTriangleAndBackgroundWindow.cs:line 149
   at Gtk.RenderHandler.Invoke(Object o, RenderArgs args)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.Invoke(ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at GLib.ExceptionManager.RaiseUnhandledException(Exception e, Boolean is_terminal)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at Gtk.Widget.InternalDrawn(Context cr)
   at OpenTK.GLWidget.OnDrawn(Context cr) in C:\Users\SSB\Downloads\opentk-develop\opentk-develop\src\OpenTK.GLWidget\GLWidget.cs:line 242
   at Gtk.Widget.Drawn_cb(IntPtr inst, IntPtr cr)
   at Gtk.Application.gtk_main()
   at Gtk.Application.gtk_main()
   at PowerEditor.Program.Main(String[] args) in C:\Users\SSB\Documents\Visual Studio 2017\Projects\PowerEngine\PowerEditor\Program.cs:line 34

Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

(PowerEditor:8024): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed
The program '[8024] PowerEditor.exe' has exited with code 1 (0x1).
I have tried invoke of Gtk Sharp 3 and OpenTK
Ghost
@ghost~59d9ee50d73408ce4f7916bf
Apr 03 21:23
And this is my code:
        private void onChangeBackgroundHandler(object sender, EventArgs e)
        {
            // Change color of background
            colorDialog = new ColorSelectionDialog("Choose color of background");
            colorDialog.Response += (object o, ResponseArgs resp) =>
            {
                OpenGLView.Render += (s, ev)=>
                {
                    Gdk.Color color = colorDialog.ColorSelection.CurrentColor;
                    OpenGLColor backgroundColor = new OpenGLColor(color.Red / 65535f, color.Green / 65535f, color.Blue / 65535f, 1f);
                    GL.ClearColor(backgroundColor.R / 255f, backgroundColor.G / 255f, backgroundColor.B / 255f, backgroundColor.A / 255f);
                };
            };
            colorDialog.Run();
            colorDialog.Destroy();
        }