NSOpenGLPixelFormat initWithAttributes

LinekerTomazeli.5329LinekerTomazeli.5329 CAMember
edited August 2016 in Xamarin.Mac

Hi there,
I'm trying to convert the following lines of objective c into c# using Xamarin.Mac.

NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPFADoubleBuffer,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAOpenGLProfile,
NSOpenGLProfileVersion3_2Core, //problem 1
0 //problem 2
};
NSOpenGLPixelFormat* pixelFormat =
[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];

The problem occurs on //problem1 and //problem2. Here are the conversion to c#.

var _attribs = new object [] { NSOpenGLPixelFormatAttribute.DoubleBuffer,
NSOpenGLPixelFormatAttribute.DepthSize, 24,
NSOpenGLPixelFormatAttribute.OpenGLProfile,
NSOpenGLProfile.Version3_2Core, 0 };
NSOpenGLPixelFormat pixelFormat = new NSOpenGLPixelFormat (_attribs);

At runtime Xamarin will try to cast my array of objects into NSOpenGLPixelFormatAttribute and because I have a NSOpenGLProfile it will fail with the following message: "Specified cast is invalid"

Stacktrace:

at AppKit.NSOpenGLPixelFormat.ConvertToAttributes (System.Object[] args) [0x0000f] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/src/AppKit/NSOpenGLPixelFormat.cs:61
at AppKit.NSOpenGLPixelFormat..ctor (System.Object[] attribs) [0x00002] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/src/AppKit/NSOpenGLPixelFormat.cs:121
at Stream.RTC.Shared.AppleMediaDevice.CreateVideoRenderer () [0x00047] in /Users/Shared/dev/Stream.RTC.Apple/AppleMediaDevice.cs:69
at Stream.Services.Services.MediaDeviceBO.StartAsync (Boolean createRenderer) [0x00037] in /Users/Shared/dev/Stream.Services/Services/MediaDeviceBO.cs:109
at Stream.End2EndTest.Common.ViewModel.WebCamViewModel`2[T,U].Open (Boolean createDefaultRenderer) [0x0000f] in /Users/Shared/dev/Stream.End2EndTest.Common/ViewModel/WebCamViewModel.cs:32
at Stream.End2EndTest.Common.ViewModel.DeviceViewModel.DeviceEnableChanged () [0x0002e] in /Users/Shared/dev/Stream.End2EndTest.Common/ViewModel/DeviceViewModel.cs:80
at Stream.End2EndTest.Common.ViewModel.DeviceViewModel.set_Enabled (Boolean value) [0x00021] in /Users/Shared/dev/Stream.End2EndTest.Common/ViewModel/DeviceViewModel.cs:42
at Stream.End2EndTest.macOS.ViewController.m__0 () [0x00024] in /Users/Shared/dev/Stream.End2EndTest.macOS/ViewController.cs:50
at Foundation.NSActionDispatcher.Apply () [0x00007] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/src/Foundation/NSAction.cs:57
at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_IntPtr_bool (intptr,intptr,intptr,intptr,bool)
at Foundation.NSObject.InvokeOnMainThread (System.Action action) [0x00025] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/src/Foundation/NSObject2.cs:553
at Stream.End2EndTest.macOS.ViewController.ActivateButton (Foundation.NSObject sender) [0x0000e] in /Users/Shared/dev/Stream.End2EndTest.macOS/ViewController.cs:47
at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
at AppKit.NSApplication.Main (System.String[] args) [0x00041] in /Users/builder/data/lanes/3539/f37444ae/source/maccore/src/AppKit/NSApplication.cs:94
at Stream.End2EndTest.macOS.MainClass.Main (System.String[] args) [0x00007] in /Users/Shared/dev/Stream.End2EndTest.macOS/Main.cs:10

Posts

Sign In or Register to comment.