2009-02-22 11:43:35 +01:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// AglContext.cs
|
|
|
|
//
|
|
|
|
// Created by Erik Ylvisaker on 3/17/08.
|
|
|
|
// Copyright 2008. All rights reserved.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using Control = System.Windows.Forms.Control;
|
|
|
|
|
|
|
|
namespace OpenTK.Platform.MacOS
|
|
|
|
{
|
|
|
|
using Carbon;
|
|
|
|
using Graphics;
|
|
|
|
|
|
|
|
using AGLRendererInfo = IntPtr;
|
|
|
|
using AGLPixelFormat = IntPtr;
|
|
|
|
using AGLContext = IntPtr;
|
|
|
|
using AGLPbuffer = IntPtr;
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
class AglContext : DesktopGraphicsContext
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
bool mVSync = false;
|
2009-03-25 22:53:12 +01:00
|
|
|
// Todo: keep track of which display adapter was specified when the context was created.
|
|
|
|
// IntPtr displayID;
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2009-03-23 12:41:11 +01:00
|
|
|
GraphicsMode graphics_mode;
|
|
|
|
CarbonWindowInfo carbonWindow;
|
|
|
|
IntPtr shareContextRef;
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
public AglContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext)
|
|
|
|
{
|
|
|
|
Debug.Print("Context Type: {0}", shareContext);
|
|
|
|
Debug.Print("Window info: {0}", window);
|
|
|
|
|
2009-03-23 12:41:11 +01:00
|
|
|
this.graphics_mode = mode;
|
|
|
|
this.carbonWindow = (CarbonWindowInfo)window;
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
if (shareContext is AglContext)
|
2009-08-17 12:23:16 +02:00
|
|
|
shareContextRef = ((AglContext)shareContext).Handle.Handle;
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2009-03-23 12:41:11 +01:00
|
|
|
CreateContext(mode, carbonWindow, shareContextRef, true);
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddPixelAttrib(List<int> aglAttributes, Agl.PixelFormatAttribute pixelFormatAttribute)
|
|
|
|
{
|
|
|
|
Debug.Print(pixelFormatAttribute.ToString());
|
|
|
|
|
|
|
|
aglAttributes.Add((int)pixelFormatAttribute);
|
|
|
|
}
|
|
|
|
private void AddPixelAttrib(List<int> aglAttributes, Agl.PixelFormatAttribute pixelFormatAttribute, int value)
|
|
|
|
{
|
|
|
|
Debug.Print("{0} : {1}", pixelFormatAttribute, value);
|
|
|
|
|
|
|
|
aglAttributes.Add((int)pixelFormatAttribute);
|
|
|
|
aglAttributes.Add(value);
|
|
|
|
}
|
|
|
|
void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow,
|
|
|
|
IntPtr shareContextRef, bool fullscreen)
|
|
|
|
{
|
|
|
|
List<int> aglAttributes = new List<int>();
|
2009-03-23 12:41:11 +01:00
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
Debug.Print("AGL pixel format attributes:");
|
|
|
|
Debug.Indent();
|
|
|
|
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_RGBA);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_DOUBLEBUFFER);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_RED_SIZE, mode.ColorFormat.Red);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_GREEN_SIZE, mode.ColorFormat.Green);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_BLUE_SIZE, mode.ColorFormat.Blue);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ALPHA_SIZE, mode.ColorFormat.Alpha);
|
|
|
|
|
|
|
|
if (mode.Depth > 0)
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_DEPTH_SIZE, mode.Depth);
|
|
|
|
|
|
|
|
if (mode.Stencil > 0)
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_STENCIL_SIZE, mode.Stencil);
|
|
|
|
|
|
|
|
if (mode.AccumulatorFormat.BitsPerPixel > 0)
|
|
|
|
{
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_RED_SIZE, mode.AccumulatorFormat.Red);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_GREEN_SIZE, mode.AccumulatorFormat.Green);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_BLUE_SIZE, mode.AccumulatorFormat.Blue);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_ACCUM_ALPHA_SIZE, mode.AccumulatorFormat.Alpha);
|
|
|
|
}
|
2009-07-19 19:50:41 +02:00
|
|
|
|
|
|
|
if (mode.Samples > 0)
|
|
|
|
{
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_SAMPLE_BUFFERS_ARB, 1);
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_SAMPLES_ARB, mode.Samples);
|
|
|
|
}
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2009-03-23 12:41:11 +01:00
|
|
|
if (fullscreen)
|
|
|
|
{
|
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_FULLSCREEN);
|
|
|
|
}
|
2009-02-22 11:43:35 +01:00
|
|
|
AddPixelAttrib(aglAttributes, Agl.PixelFormatAttribute.AGL_NONE);
|
|
|
|
|
|
|
|
Debug.Unindent();
|
|
|
|
|
|
|
|
Debug.Write("Attribute array: ");
|
|
|
|
for (int i = 0; i < aglAttributes.Count; i++)
|
|
|
|
Debug.Write(aglAttributes[i].ToString() + " ");
|
|
|
|
Debug.WriteLine("");
|
|
|
|
|
|
|
|
AGLPixelFormat myAGLPixelFormat;
|
|
|
|
|
|
|
|
// Choose a pixel format with the attributes we specified.
|
2009-03-23 12:41:11 +01:00
|
|
|
if (fullscreen)
|
|
|
|
{
|
|
|
|
IntPtr gdevice;
|
|
|
|
|
|
|
|
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(
|
|
|
|
QuartzDisplayDeviceDriver.MainDisplay, out gdevice, false);
|
|
|
|
|
|
|
|
if (status != OSStatus.NoError)
|
|
|
|
throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
|
|
|
|
|
|
|
|
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
|
|
|
ref gdevice, 1,
|
|
|
|
aglAttributes.ToArray());
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
Agl.AglError err = Agl.GetError();
|
|
|
|
|
|
|
|
if (err == Agl.AglError.BadPixelFormat)
|
|
|
|
{
|
|
|
|
Debug.Print("Failed to create full screen pixel format.");
|
|
|
|
Debug.Print("Trying again to create a non-fullscreen pixel format.");
|
|
|
|
|
|
|
|
CreateContext(mode, carbonWindow, shareContextRef, false);
|
|
|
|
return;
|
|
|
|
}
|
2009-03-23 12:41:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
|
|
|
IntPtr.Zero, 0,
|
|
|
|
aglAttributes.ToArray());
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
MyAGLReportError("aglChoosePixelFormat");
|
2009-03-23 12:41:11 +01:00
|
|
|
}
|
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
// create the context and share it with the share reference.
|
2009-08-17 12:23:16 +02:00
|
|
|
Handle = new ContextHandle( Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
|
2009-02-22 11:43:35 +01:00
|
|
|
MyAGLReportError("aglCreateContext");
|
|
|
|
|
|
|
|
// Free the pixel format from memory.
|
|
|
|
Agl.aglDestroyPixelFormat(myAGLPixelFormat);
|
|
|
|
MyAGLReportError("aglDestroyPixelFormat");
|
|
|
|
|
|
|
|
Debug.Print("IsControl: {0}", carbonWindow.IsControl);
|
|
|
|
|
|
|
|
SetDrawable(carbonWindow);
|
|
|
|
SetBufferRect(carbonWindow);
|
2009-03-23 12:41:11 +01:00
|
|
|
Update(carbonWindow);
|
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
MakeCurrent(carbonWindow);
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
Debug.Print("context: {0}", Handle.Handle);
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetBufferRect(CarbonWindowInfo carbonWindow)
|
|
|
|
{
|
|
|
|
if (carbonWindow.IsControl == false)
|
2009-03-23 12:41:11 +01:00
|
|
|
return;
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
System.Windows.Forms.Control ctrl = Control.FromHandle(carbonWindow.WindowRef);
|
2009-03-23 12:41:11 +01:00
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
if (ctrl.TopLevelControl == null)
|
2009-03-23 12:41:11 +01:00
|
|
|
return;
|
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
Rect rect = API.GetControlBounds(carbonWindow.WindowRef);
|
2009-05-07 18:32:15 +02:00
|
|
|
System.Windows.Forms.Form frm = (System.Windows.Forms.Form) ctrl.TopLevelControl;
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2009-05-07 18:32:15 +02:00
|
|
|
System.Drawing.Point loc =
|
|
|
|
frm.PointToClient(ctrl.PointToScreen(System.Drawing.Point.Empty));
|
|
|
|
|
|
|
|
rect.X = (short)loc.X;
|
|
|
|
rect.Y = (short)loc.Y;
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
Debug.Print("Setting buffer_rect for control.");
|
|
|
|
Debug.Print("MacOS Coordinate Rect: {0}", rect);
|
|
|
|
|
|
|
|
rect.Y = (short)(ctrl.TopLevelControl.ClientSize.Height - rect.Y - rect.Height);
|
|
|
|
Debug.Print(" AGL Coordinate Rect: {0}", rect);
|
|
|
|
|
|
|
|
int[] glrect = new int[4];
|
|
|
|
|
|
|
|
glrect[0] = rect.X;
|
|
|
|
glrect[1] = rect.Y;
|
|
|
|
glrect[2] = rect.Width;
|
|
|
|
glrect[3] = rect.Height;
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
Agl.aglSetInteger(Handle.Handle, Agl.ParameterNames.AGL_BUFFER_RECT, glrect);
|
2009-02-22 11:43:35 +01:00
|
|
|
MyAGLReportError("aglSetInteger");
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
Agl.aglEnable(Handle.Handle, Agl.ParameterNames.AGL_BUFFER_RECT);
|
2009-02-22 11:43:35 +01:00
|
|
|
MyAGLReportError("aglEnable");
|
|
|
|
|
|
|
|
}
|
2009-03-23 12:41:11 +01:00
|
|
|
void SetDrawable(CarbonWindowInfo carbonWindow)
|
|
|
|
{
|
|
|
|
IntPtr windowPort = GetWindowPortForWindowInfo(carbonWindow);
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
Agl.aglSetDrawable(Handle.Handle, windowPort);
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
MyAGLReportError("aglSetDrawable");
|
2009-03-23 12:41:11 +01:00
|
|
|
|
|
|
|
}
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
private static IntPtr GetWindowPortForWindowInfo(CarbonWindowInfo carbonWindow)
|
|
|
|
{
|
|
|
|
IntPtr windowPort;
|
|
|
|
if (carbonWindow.IsControl)
|
|
|
|
{
|
|
|
|
IntPtr controlOwner = API.GetControlOwner(carbonWindow.WindowRef);
|
2009-05-07 18:32:15 +02:00
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
windowPort = API.GetWindowPort(controlOwner);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
windowPort = API.GetWindowPort(carbonWindow.WindowRef);
|
|
|
|
return windowPort;
|
|
|
|
}
|
2009-08-19 16:17:47 +02:00
|
|
|
public override void Update(IWindowInfo window)
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window;
|
|
|
|
|
|
|
|
SetDrawable(carbonWindow);
|
2009-03-23 12:41:11 +01:00
|
|
|
SetBufferRect(carbonWindow);
|
2009-08-17 12:23:16 +02:00
|
|
|
|
|
|
|
Agl.aglUpdateContext(Handle.Handle);
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyAGLReportError(string function)
|
|
|
|
{
|
|
|
|
Agl.AglError err = Agl.GetError();
|
|
|
|
|
|
|
|
if (err != Agl.AglError.NoError)
|
|
|
|
throw new MacOSException((OSStatus)err, string.Format(
|
|
|
|
"AGL Error from function {0}: {1} {2}",
|
|
|
|
function, err, Agl.ErrorString(err)));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool firstFullScreen = false;
|
|
|
|
|
|
|
|
internal void SetFullScreen(CarbonWindowInfo info)
|
|
|
|
{
|
2009-08-17 12:23:16 +02:00
|
|
|
Agl.aglSetFullScreen(Handle.Handle, 0, 0, 0, 0);
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
// This is a weird hack to workaround a bug where the first time a context
|
|
|
|
// is made fullscreen, we just end up with a blank screen. So we undo it as fullscreen
|
|
|
|
// and redo it as fullscreen.
|
|
|
|
if (firstFullScreen == false)
|
|
|
|
{
|
|
|
|
firstFullScreen = true;
|
|
|
|
UnsetFullScreen(info);
|
|
|
|
SetFullScreen(info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
internal void UnsetFullScreen(CarbonWindowInfo windowInfo)
|
|
|
|
{
|
2009-08-17 12:23:16 +02:00
|
|
|
Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero);
|
2009-02-22 11:43:35 +01:00
|
|
|
SetDrawable(windowInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region IGraphicsContext Members
|
|
|
|
|
2009-03-23 12:41:11 +01:00
|
|
|
bool firstSwap = false;
|
2009-08-17 12:23:16 +02:00
|
|
|
public override void SwapBuffers()
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
// this is part of the hack to avoid dropping the first frame when
|
|
|
|
// using multiple GLControls.
|
2009-03-23 12:41:11 +01:00
|
|
|
if (firstSwap == false && carbonWindow.IsControl)
|
|
|
|
{
|
|
|
|
Debug.WriteLine("--> Resetting drawable. <--");
|
|
|
|
firstSwap = true;
|
|
|
|
SetDrawable(carbonWindow);
|
2009-02-22 11:43:35 +01:00
|
|
|
Update(carbonWindow);
|
2009-08-17 12:23:16 +02:00
|
|
|
}
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
Agl.aglSwapBuffers(Handle.Handle);
|
2009-02-22 11:43:35 +01:00
|
|
|
MyAGLReportError("aglSwapBuffers");
|
|
|
|
}
|
2009-03-23 12:41:11 +01:00
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
public override void MakeCurrent(IWindowInfo window)
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
2009-08-17 12:23:16 +02:00
|
|
|
if (Agl.aglSetCurrentContext(Handle.Handle) == false)
|
2009-02-22 11:43:35 +01:00
|
|
|
MyAGLReportError("aglSetCurrentContext");
|
|
|
|
}
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
public override bool IsCurrent
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2009-08-17 12:23:16 +02:00
|
|
|
return (Handle.Handle == Agl.aglGetCurrentContext());
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
public override bool VSync
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return mVSync;
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
int intVal = value ? 1 : 0;
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
Agl.aglSetInteger(Handle.Handle, Agl.ParameterNames.AGL_SWAP_INTERVAL, ref intVal);
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
mVSync = value;
|
|
|
|
}
|
|
|
|
}
|
2009-03-29 23:41:30 +02:00
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region IDisposable Members
|
|
|
|
~AglContext()
|
|
|
|
{
|
|
|
|
Dispose(false);
|
|
|
|
}
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
public override void Dispose()
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
Dispose(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dispose(bool disposing)
|
|
|
|
{
|
2009-09-03 14:23:11 +02:00
|
|
|
if (IsDisposed || Handle.Handle == IntPtr.Zero)
|
2009-02-22 11:43:35 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
Debug.Print("Disposing of AGL context.");
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
Debug.WriteLine(e.StackTrace);
|
|
|
|
}
|
|
|
|
|
|
|
|
Agl.aglSetCurrentContext(IntPtr.Zero);
|
2009-08-17 12:23:16 +02:00
|
|
|
Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero);
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
Debug.Print("Set drawable to null for context {0}.", Handle.Handle);
|
2009-02-22 11:43:35 +01:00
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
if (Agl.aglDestroyContext(Handle.Handle) == true)
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
2009-08-17 12:23:16 +02:00
|
|
|
Handle = ContextHandle.Zero;
|
2009-02-22 11:43:35 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// failed to destroy context.
|
|
|
|
Debug.WriteLine("Failed to destroy context.");
|
|
|
|
Debug.WriteLine(Agl.ErrorString(Agl.GetError()));
|
|
|
|
|
|
|
|
// don't throw an exception from the finalizer thread.
|
|
|
|
if (disposing)
|
|
|
|
{
|
|
|
|
throw new MacOSException((OSStatus)Agl.GetError(), Agl.ErrorString(Agl.GetError()));
|
|
|
|
}
|
2009-09-03 14:23:11 +02:00
|
|
|
|
|
|
|
IsDisposed = true;
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region IGraphicsContextInternal Members
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
public override void LoadAll()
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
2009-08-17 12:23:16 +02:00
|
|
|
new OpenTK.Graphics.OpenGL.GL().LoadAll();
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
private const string Library = "libdl.dylib";
|
2009-08-15 18:44:43 +02:00
|
|
|
|
|
|
|
[DllImport(Library, EntryPoint = "NSIsSymbolNameDefined")]
|
|
|
|
private static extern bool NSIsSymbolNameDefined(string s);
|
|
|
|
[DllImport(Library, EntryPoint = "NSLookupAndBindSymbol")]
|
|
|
|
private static extern IntPtr NSLookupAndBindSymbol(string s);
|
|
|
|
[DllImport(Library, EntryPoint = "NSAddressOfSymbol")]
|
|
|
|
private static extern IntPtr NSAddressOfSymbol(IntPtr symbol);
|
|
|
|
|
2009-08-17 12:23:16 +02:00
|
|
|
public override IntPtr GetAddress(string function)
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
2009-08-15 18:44:43 +02:00
|
|
|
string fname = "_" + function;
|
|
|
|
if (!NSIsSymbolNameDefined(fname))
|
|
|
|
return IntPtr.Zero;
|
|
|
|
|
|
|
|
IntPtr symbol = NSLookupAndBindSymbol(fname);
|
|
|
|
if (symbol != IntPtr.Zero)
|
|
|
|
symbol = NSAddressOfSymbol(symbol);
|
|
|
|
|
|
|
|
return symbol;
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|