VeliV's picture

Mac OSX applications fail when setting up GLControl

Project:The Open Toolkit library
Category:bug report

The line 4th line on the following code causes a crash on Mac OSX

using System;
using System.Windows.Forms;
public class HelloWorld : Form
  OpenTK.GLControl glControl = new OpenTK.GLControl();
  static public void Main()
    Application.Run(new HelloWorld());
  public HelloWorld()
    Text = "Hello World";

Here is the output:

System.InvalidCastException: Cannot cast from source type to destination type.
  at OpenTK.Platform.MacOS.AglContext..ctor (OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext) [0x00000] 
  at OpenTK.Platform.MacOS.MacOSFactory.CreateGLContext (OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, Boolean directRendering, Int32 major, Int32 minor, GraphicsContextFlags flags) [0x00000] 
  at OpenTK.Graphics.GraphicsContext..ctor (OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, Int32 major, Int32 minor, GraphicsContextFlags flags) [0x00000] 
  at OpenTK.CarbonGLControl.CreateContext (Int32 major, Int32 minor, GraphicsContextFlags flags) [0x00000] 
  at OpenTK.GLControl.OnHandleCreated (System.EventArgs e) [0x00000] 
  at System.Windows.Forms.Control.WmCreate (System.Windows.Forms.Message& m) [0x00000] in /private/tmp/monobuild/build/BUILD/mono- 
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x001e4] in /private/tmp/monobuild/build/BUILD/mono- 
  at System.Windows.Forms.ScrollableControl.WndProc (System.Windows.Forms.Message& m) [0x00000] in /private/tmp/monobuild/build/BUILD/mono- 
  at System.Windows.Forms.ContainerControl.WndProc (System.Windows.Forms.Message& m) [0x0003d] in /private/tmp/monobuild/build/BUILD/mono- 
  at System.Windows.Forms.UserControl.WndProc (System.Windows.Forms.Message& m) [0x00037] in /private/tmp/monobuild/build/BUILD/mono- 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in /private/tmp/monobuild/build/BUILD/mono- 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in /private/tmp/monobuild/build/BUILD/mono- 
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x00085] in /private/tmp/monobuild/build/BUILD/mono-

Using Mac OSX Snow Leopard, latest mono and revision 2465 from the SVN.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
VeliV's picture


Yeh. works now. On to finding the next issue :P

the Fiddler's picture


Status:in progress (review)» fixed


@kanato: this was the main issue indeed. Simply changing the order in the factory constructor set things right.

the Fiddler's picture


Version:0.9.x-dev» 1.0-beta-1
Status:fixed» closed

Closing issues fixed in 1.0 beta-1.