private void DestroyContext() { if (ContextHandle == IntPtr.Zero) { return; } try { // This will fail if the user calls Dispose() on thread X when the context is current on thread Y. if (!Wgl.wglDeleteContext(ContextHandle)) { Debug.Print("Failed to destroy OpenGL context {0}. Error: {1}", ContextHandle.ToString(), Marshal.GetLastWin32Error()); } } catch (AccessViolationException e) { Debug.Print("An access violation occured while destroying the OpenGL context. Please report at http://www.opentk.com."); Debug.Print("Marshal.GetLastWin32Error(): {0}", Marshal.GetLastWin32Error().ToString()); Debug.Print(e.ToString()); } ContextHandle = IntPtr.Zero; }
internal void LoadEntryPoints() { lock (SyncRoot) { if (Wgl.GetCurrentContext() != IntPtr.Zero) { for (int i = 0; i < EntryPointNames.Length; i++) { EntryPoints[i] = GetAddress(EntryPointNames[i]); } extensions.Clear(); wglSwapIntervalEXT = GetProcAddress <SwapIntervalEXT>("wglSwapIntervalEXT"); wglGetSwapIntervalEXT = GetProcAddress <GetSwapIntervalEXT>("wglGetSwapIntervalEXT"); wglGetExtensionsStringARB = GetProcAddress <GetExtensionsStringARBDelegate>("wglGetExtensionsStringARB"); wglGetExtensionsStringEXT = GetProcAddress <GetExtensionsStringEXTDelegate>("wglGetExtensionsStringEXT"); wglCreateContextAttribs = GetProcAddress <CreateContextAttribsARBDelegate>("wglCreateContextAttribsARB"); wglChoosePixelFormatARB = GetProcAddress <ChoosePixelFormatARB>("wglChoosePixelFormatARB"); WglGetPixelFormatAttribivARB = GetProcAddress <GetPixelFormatAttribivARB>("wglGetPixelFormatAttribivARB"); } } }
private void DestroyContext() { if (Handle != ContextHandle.Zero) { try { // This will fail if the user calls Dispose() on thread X when the context is current on thread Y. if (!Wgl.DeleteContext(Handle.Handle)) { Debug.Print("Failed to destroy OpenGL context {0}. Error: {1}", Handle.ToString(), Marshal.GetLastWin32Error()); } } catch (AccessViolationException e) { Debug.WriteLine("An access violation occured while destroying the OpenGL context. Please report at https://github.com/opentk/opentk/issues"); Debug.Indent(); Debug.Print("Marshal.GetLastWin32Error(): {0}", Marshal.GetLastWin32Error().ToString()); Debug.WriteLine(e.ToString()); Debug.Unindent(); } Handle = ContextHandle.Zero; } }
GraphicsMode DescribePixelFormatARB(IntPtr device, int pixelformat) { GraphicsMode created_mode = null; // See http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt for more details if (Wgl.SupportsFunction("wglGetPixelFormatAttribivARB")) { // Define the list of attributes we are interested in. // The results will be stored in the 'values' array below. int[] attribs = new int[] { (int)WGL_ARB_pixel_format.AccelerationArb, (int)WGL_ARB_pixel_format.RedBitsArb, (int)WGL_ARB_pixel_format.GreenBitsArb, (int)WGL_ARB_pixel_format.BlueBitsArb, (int)WGL_ARB_pixel_format.AlphaBitsArb, (int)WGL_ARB_pixel_format.ColorBitsArb, (int)WGL_ARB_pixel_format.DepthBitsArb, (int)WGL_ARB_pixel_format.StencilBitsArb, (int)WGL_ARB_multisample.SampleBuffersArb, (int)WGL_ARB_multisample.SamplesArb, (int)WGL_ARB_pixel_format.AccumRedBitsArb, (int)WGL_ARB_pixel_format.AccumGreenBitsArb, (int)WGL_ARB_pixel_format.AccumBlueBitsArb, (int)WGL_ARB_pixel_format.AccumAlphaBitsArb, (int)WGL_ARB_pixel_format.AccumBitsArb, (int)WGL_ARB_pixel_format.DoubleBufferArb, (int)WGL_ARB_pixel_format.StereoArb, 0 }; // Allocate storage for the results of GetPixelFormatAttrib queries int[] values = new int[attribs.Length]; // Get the format attributes for this pixel format if (!Wgl.Arb.GetPixelFormatAttrib(device, pixelformat, 0, attribs.Length - 1, attribs, values)) { Debug.Print("[Warning] Failed to detect attributes for PixelFormat: {0}.", pixelformat); } // Skip formats that don't offer full hardware acceleration WGL_ARB_pixel_format acceleration = (WGL_ARB_pixel_format)values[0]; if (acceleration == WGL_ARB_pixel_format.FullAccelerationArb) { // Construct a new GraphicsMode to describe this format created_mode = new GraphicsMode(new IntPtr(pixelformat), new ColorFormat(values[1], values[2], values[3], values[4]), values[6], values[7], values[8] != 0 ? values[9] : 0, new ColorFormat(values[10], values[11], values[12], values[13]), values[15] == 1 ? 2 : 1, values[16] == 1 ? true : false); } } return(created_mode); }
// Queries pixel formats through the WGL_ARB_pixel_format extension // This method only returns accelerated formats. If no format offers // hardware acceleration (e.g. we are running in a VM or in a remote desktop // connection), this method will return 0 formats and we will fall back to // ChoosePixelFormatPFD. GraphicsMode ChoosePixelFormatARB(IntPtr device, GraphicsMode desired_mode) { GraphicsMode created_mode = null; GraphicsMode mode = new GraphicsMode(desired_mode); if (Wgl.SupportsExtension("WGL_ARB_pixel_format") && Wgl.SupportsFunction("wglChoosePixelFormatARB")) { int[] format = new int[1]; int count; List <int> attributes = new List <int>(); bool retry = false; do { attributes.Clear(); attributes.Add((int)WGL_ARB_pixel_format.AccelerationArb); attributes.Add((int)WGL_ARB_pixel_format.FullAccelerationArb); attributes.Add((int)WGL_ARB_pixel_format.DrawToWindowArb); attributes.Add(1); if (mode.ColorFormat.Red > 0) { attributes.Add((int)WGL_ARB_pixel_format.RedBitsArb); attributes.Add(mode.ColorFormat.Red); } if (mode.ColorFormat.Green > 0) { attributes.Add((int)WGL_ARB_pixel_format.GreenBitsArb); attributes.Add(mode.ColorFormat.Green); } if (mode.ColorFormat.Blue > 0) { attributes.Add((int)WGL_ARB_pixel_format.BlueBitsArb); attributes.Add(mode.ColorFormat.Blue); } if (mode.ColorFormat.Alpha > 0) { attributes.Add((int)WGL_ARB_pixel_format.AlphaBitsArb); attributes.Add(mode.ColorFormat.Alpha); } if (mode.Depth > 0) { attributes.Add((int)WGL_ARB_pixel_format.DepthBitsArb); attributes.Add(mode.Depth); } if (mode.Stencil > 0) { attributes.Add((int)WGL_ARB_pixel_format.StencilBitsArb); attributes.Add(mode.Stencil); } if (mode.AccumulatorFormat.Red > 0) { attributes.Add((int)WGL_ARB_pixel_format.AccumRedBitsArb); attributes.Add(mode.AccumulatorFormat.Red); } if (mode.AccumulatorFormat.Green > 0) { attributes.Add((int)WGL_ARB_pixel_format.AccumGreenBitsArb); attributes.Add(mode.AccumulatorFormat.Green); } if (mode.AccumulatorFormat.Blue > 0) { attributes.Add((int)WGL_ARB_pixel_format.AccumBlueBitsArb); attributes.Add(mode.AccumulatorFormat.Blue); } if (mode.AccumulatorFormat.Alpha > 0) { attributes.Add((int)WGL_ARB_pixel_format.AccumAlphaBitsArb); attributes.Add(mode.AccumulatorFormat.Alpha); } if (mode.Samples > 0 && Wgl.SupportsExtension("WGL_ARB_multisample")) { attributes.Add((int)WGL_ARB_multisample.SampleBuffersArb); attributes.Add(1); attributes.Add((int)WGL_ARB_multisample.SamplesArb); attributes.Add(mode.Samples); } if (mode.Buffers > 0) { attributes.Add((int)WGL_ARB_pixel_format.DoubleBufferArb); attributes.Add(mode.Buffers > 1 ? 1 : 0); } if (mode.Stereo) { attributes.Add((int)WGL_ARB_pixel_format.StereoArb); attributes.Add(1); } attributes.Add(0); attributes.Add(0); if (Wgl.Arb.ChoosePixelFormat(device, attributes.ToArray(), null, format.Length, format, out count) && count > 0) { created_mode = DescribePixelFormatARB(device, format[0]); retry = false; } else { Debug.Print("[WGL] ChoosePixelFormatARB failed with {0}", Marshal.GetLastWin32Error()); retry = Utilities.RelaxGraphicsMode(ref mode); } }while (retry); } else { Debug.WriteLine("[WGL] ChoosePixelFormatARB not supported on this context"); } return(created_mode); }
public WinGLContext(GraphicsMode format, WinWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags) { // There are many ways this code can break when accessed by multiple threads. The biggest offender is // the sharedContext stuff, which will only become valid *after* this constructor returns. // The easiest solution is to serialize all context construction - hence the big lock, below. lock (LoadLock) { if (window == null) { throw new ArgumentNullException("window", "Must point to a valid window."); } if (window.Handle == IntPtr.Zero) { throw new ArgumentException("window", "Must be a valid window."); } IntPtr current_context = Wgl.GetCurrentContext(); INativeWindow temp_window = null; TemporaryContext temp_context = null; try { if (current_context == IntPtr.Zero) { // Create temporary context to load WGL extensions temp_window = new NativeWindow(); temp_context = new TemporaryContext(temp_window); current_context = Wgl.GetCurrentContext(); if (current_context != IntPtr.Zero && current_context == temp_context.Context.Handle) { new Wgl().LoadEntryPoints(); } } Debug.Print("OpenGL will be bound to window:{0} on thread:{1}", window.Handle, System.Threading.Thread.CurrentThread.ManagedThreadId); ModeSelector = new WinGraphicsMode(window.DeviceContext); Mode = SetGraphicsModePFD(ModeSelector, format, (WinWindowInfo)window); if (Wgl.SupportsFunction("wglCreateContextAttribsARB")) { try { Debug.Write("Using WGL_ARB_create_context... "); List <int> attributes = new List <int>(); attributes.Add((int)ArbCreateContext.MajorVersion); attributes.Add(major); attributes.Add((int)ArbCreateContext.MinorVersion); attributes.Add(minor); if (flags != 0) { attributes.Add((int)ArbCreateContext.ContextFlags); attributes.Add((int)GetARBContextFlags(flags)); attributes.Add((int)ArbCreateContext.ProfileMask); attributes.Add((int)GetARBContextProfile(flags)); } // According to the docs, " <attribList> specifies a list of attributes for the context. // The list consists of a sequence of <name,value> pairs terminated by the // value 0. [...]" // Is this a single 0, or a <0, 0> pair? (Defensive coding: add two zeroes just in case). attributes.Add(0); attributes.Add(0); Handle = new ContextHandle( Wgl.Arb.CreateContextAttribs( window.DeviceContext, sharedContext != null ? (sharedContext as IGraphicsContextInternal).Context.Handle : IntPtr.Zero, attributes.ToArray())); if (Handle == ContextHandle.Zero) { Debug.Print("failed. (Error: {0})", Marshal.GetLastWin32Error()); } } catch (Exception e) { Debug.Print(e.ToString()); } } if (Handle == ContextHandle.Zero) { // Failed to create GL3-level context, fall back to GL2. Debug.Write("Falling back to GL2... "); Handle = new ContextHandle(Wgl.CreateContext(window.DeviceContext)); if (Handle == ContextHandle.Zero) { Handle = new ContextHandle(Wgl.CreateContext(window.DeviceContext)); } if (Handle == ContextHandle.Zero) { throw new GraphicsContextException( String.Format("Context creation failed. Wgl.CreateContext() error: {0}.", Marshal.GetLastWin32Error())); } } Debug.WriteLine(String.Format("success! (id: {0})", Handle)); } finally { if (temp_context != null) { temp_context.Dispose(); temp_context = null; } if (temp_window != null) { temp_window.Dispose(); temp_window = null; } } } // Todo: is this comment still true? // On intel drivers, wgl entry points appear to change // when creating multiple contexts. As a workaround, // we reload Wgl entry points every time we create a // new context - this solves the issue without any apparent // side-effects (i.e. the old contexts can still be handled // using the new entry points.) // Sigh... MakeCurrent(window); new Wgl().LoadEntryPoints(); if (sharedContext != null) { Marshal.GetLastWin32Error(); Debug.Write(String.Format("Sharing state with context {0}: ", sharedContext)); bool result = Wgl.ShareLists((sharedContext as IGraphicsContextInternal).Context.Handle, Handle.Handle); Debug.WriteLine(result ? "success!" : "failed with win32 error " + Marshal.GetLastWin32Error()); } }
static WinGLContext() { lock (LoadLock) { // Dynamically load opengl32.dll in order to use the extension loading capabilities of Wgl. if (opengl32Handle == IntPtr.Zero) { opengl32Handle = Functions.LoadLibrary(opengl32Name); if (opengl32Handle == IntPtr.Zero) { throw new ApplicationException(String.Format("LoadLibrary(\"{0}\") call failed with code {1}", opengl32Name, Marshal.GetLastWin32Error())); } Debug.WriteLine(String.Format("Loaded opengl32.dll: {0}", opengl32Handle)); } // We need to create a temp context in order to load // wgl extensions (e.g. for multisampling or GL3). // We cannot rely on OpenTK.Platform.Wgl until we // create the context and call Wgl.LoadAll(). Debug.Print("Creating temporary context for wgl extensions."); using (INativeWindow native = new NativeWindow()) { // Create temporary context and load WGL entry points // First, set a compatible pixel format to the device context // of the temp window WinWindowInfo window = native.WindowInfo as WinWindowInfo; WinGraphicsMode selector = new WinGraphicsMode(window.DeviceContext); SetGraphicsModePFD(selector, GraphicsMode.Default, window); // Then, construct a temporary context and load all wgl extensions ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); if (temp_context != ContextHandle.Zero) { // Make the context current. // Note: on some video cards and on some virtual machines, wglMakeCurrent // may fail with an errorcode of 6 (INVALID_HANDLE). The suggested workaround // is to call wglMakeCurrent in a loop until it succeeds. // See https://www.opengl.org/discussion_boards/showthread.php/171058-nVidia-wglMakeCurrent()-multiple-threads // Sigh... for (int retry = 0; retry < 5; retry++) { bool success = Wgl.Imports.MakeCurrent(window.DeviceContext, temp_context.Handle); if (!success) { Debug.Print("wglMakeCurrent failed with error: {0}. Retrying", Marshal.GetLastWin32Error()); System.Threading.Thread.Sleep(10); } else { // wglMakeCurrent succeeded, we are done here! break; } } // Load wgl extensions and destroy temporary context Wgl.LoadAll(); Wgl.Imports.MakeCurrent(IntPtr.Zero, IntPtr.Zero); Wgl.Imports.DeleteContext(temp_context.Handle); } else { Debug.Print("wglCreateContext failed with error: {0}", Marshal.GetLastWin32Error()); } } } }
public WinGLContext(GraphicsMode format, WinWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags) { if (window == null) { throw new ArgumentNullException("window", "Must point to a valid window."); } if (window.WindowHandle == IntPtr.Zero) { throw new ArgumentException("window", "Must be a valid window."); } Mode = format; Debug.Print("OpenGL will be bound to handle: {0}", window.WindowHandle); Debug.Write("Setting pixel format... "); this.SetGraphicsModePFD(format, (WinWindowInfo)window); if (!wgl_loaded) { // We need to create a temp context in order to load wgl extensions (e.g. for multisampling or GL3). // We cannot rely on OpenTK.Platform.Wgl until we create the context and call Wgl.LoadAll(). Debug.Print("Creating temporary context for wgl extensions."); ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); Wgl.Imports.MakeCurrent(window.DeviceContext, temp_context.Handle); Wgl.LoadAll(); Wgl.MakeCurrent(IntPtr.Zero, IntPtr.Zero); Wgl.DeleteContext(temp_context.Handle); wgl_loaded = true; } if (Wgl.Delegates.wglCreateContextAttribsARB != null) { try { Debug.Write("Using WGL_ARB_create_context... "); List <int> attributes = new List <int>(); attributes.Add((int)ArbCreateContext.MajorVersion); attributes.Add(major); attributes.Add((int)ArbCreateContext.MinorVersion); attributes.Add(minor); if (flags != 0) { attributes.Add((int)ArbCreateContext.Flags); attributes.Add((int)flags); } attributes.Add(0); Handle = new ContextHandle( Wgl.Arb.CreateContextAttribs( window.DeviceContext, sharedContext != null ? (sharedContext as IGraphicsContextInternal).Context.Handle : IntPtr.Zero, attributes.ToArray())); if (Handle == ContextHandle.Zero) { Debug.Print("failed. (Error: {0})", Marshal.GetLastWin32Error()); } else { Debug.Print("success!"); } } catch (EntryPointNotFoundException e) { Debug.Print(e.ToString()); } catch (NullReferenceException e) { Debug.Print(e.ToString()); } } if (Handle == ContextHandle.Zero) { // Failed to create GL3-level context, fall back to GL2. Debug.Write("Falling back to GL2... "); Handle = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); if (Handle == ContextHandle.Zero) { Handle = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); } if (Handle == ContextHandle.Zero) { throw new GraphicsContextException( String.Format("Context creation failed. Wgl.CreateContext() error: {0}.", Marshal.GetLastWin32Error())); } } Debug.WriteLine(String.Format("success! (id: {0})", Handle)); if (sharedContext != null) { Debug.Print("Sharing state with context {0}", sharedContext.ToString()); Wgl.Imports.ShareLists((sharedContext as IGraphicsContextInternal).Context.Handle, Handle.Handle); } }
public WinGLContext(GraphicsMode format, WinWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags) { // There are many ways this code can break when accessed by multiple threads. The biggest offender is // the sharedContext stuff, which will only become valid *after* this constructor returns. // The easiest solution is to serialize all context construction - hence the big lock, below. lock (SyncRoot) { if (window == null) { throw new ArgumentNullException("window", "Must point to a valid window."); } if (window.WindowHandle == IntPtr.Zero) { throw new ArgumentException("window", "Must be a valid window."); } Mode = format; Debug.Print("OpenGL will be bound to handle: {0}", window.WindowHandle); Debug.Write("Setting pixel format... "); this.SetGraphicsModePFD(format, (WinWindowInfo)window); if (!wgl_loaded) { // We need to create a temp context in order to load wgl extensions (e.g. for multisampling or GL3). // We cannot rely on OpenTK.Platform.Wgl until we create the context and call Wgl.LoadAll(). Debug.Print("Creating temporary context for wgl extensions."); ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); Wgl.Imports.MakeCurrent(window.DeviceContext, temp_context.Handle); Wgl.LoadAll(); Wgl.MakeCurrent(IntPtr.Zero, IntPtr.Zero); Wgl.DeleteContext(temp_context.Handle); wgl_loaded = true; } if (Wgl.Delegates.wglCreateContextAttribsARB != null) { try { Debug.Write("Using WGL_ARB_create_context... "); List <int> attributes = new List <int>(); attributes.Add((int)ArbCreateContext.MajorVersion); attributes.Add(major); attributes.Add((int)ArbCreateContext.MinorVersion); attributes.Add(minor); if (flags != 0) { attributes.Add((int)ArbCreateContext.Flags); #warning "This is not entirely correct: Embedded is not a valid flag! We need to add a GetARBContextFlags(GraphicsContextFlags) method." attributes.Add((int)flags); } // According to the docs, " <attribList> specifies a list of attributes for the context. // The list consists of a sequence of <name,value> pairs terminated by the // value 0. [...]" // Is this a single 0, or a <0, 0> pair? (Defensive coding: add two zeroes just in case). attributes.Add(0); attributes.Add(0); Handle = new ContextHandle( Wgl.Arb.CreateContextAttribs( window.DeviceContext, sharedContext != null ? (sharedContext as IGraphicsContextInternal).Context.Handle : IntPtr.Zero, attributes.ToArray())); if (Handle == ContextHandle.Zero) { Debug.Print("failed. (Error: {0})", Marshal.GetLastWin32Error()); } else { Debug.Print("success!"); } } catch (EntryPointNotFoundException e) { Debug.Print(e.ToString()); } catch (NullReferenceException e) { Debug.Print(e.ToString()); } } if (Handle == ContextHandle.Zero) { // Failed to create GL3-level context, fall back to GL2. Debug.Write("Falling back to GL2... "); Handle = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); if (Handle == ContextHandle.Zero) { Handle = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); } if (Handle == ContextHandle.Zero) { throw new GraphicsContextException( String.Format("Context creation failed. Wgl.CreateContext() error: {0}.", Marshal.GetLastWin32Error())); } } Debug.WriteLine(String.Format("success! (id: {0})", Handle)); if (sharedContext != null) { Marshal.GetLastWin32Error(); Debug.Write("Sharing state with context {0}: ", sharedContext.ToString()); bool result = Wgl.Imports.ShareLists((sharedContext as IGraphicsContextInternal).Context.Handle, Handle.Handle); Debug.WriteLine(result ? "success!" : "failed with win32 error " + Marshal.GetLastWin32Error()); } } }
public virtual GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext() { return((GraphicsContext.GetCurrentContextDelegate)(() => new ContextHandle(Wgl.GetCurrentContext()))); }
protected override IntPtr GetAddress(string funcname) { return(Wgl.wglGetProcAddress(funcname)); }
public static bool SupportsExtension(string name) { return(SupportsExtension(Wgl.GetCurrentDC(), name)); }
public WinGLContext(GraphicsMode format, WinWindowInfo window, IGraphicsContext sharedContext, int major, int minor, GraphicsContextFlags flags) { lock (WinGLContext.SyncRoot) { if (window == null) { throw new ArgumentNullException("window", "Must point to a valid window."); } if (window.WindowHandle == IntPtr.Zero) { throw new ArgumentException("window", "Must be a valid window."); } this.Mode = format; this.SetGraphicsModePFD(format, window); lock (WinGLContext.LoadLock) { if (!WinGLContext.wgl_loaded) { ContextHandle local_0 = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); Wgl.Imports.MakeCurrent(window.DeviceContext, local_0.Handle); Wgl.LoadAll(); Wgl.Imports.MakeCurrent(IntPtr.Zero, IntPtr.Zero); Wgl.Imports.DeleteContext(local_0.Handle); WinGLContext.wgl_loaded = true; } if (Wgl.Delegates.wglCreateContextAttribsARB != null) { try { List <int> local_1 = new List <int>(); local_1.Add(8337); local_1.Add(major); local_1.Add(8338); local_1.Add(minor); if (flags != GraphicsContextFlags.Default) { local_1.Add(8340); local_1.Add((int)flags); } local_1.Add(0); local_1.Add(0); this.Handle = new ContextHandle(Wgl.Arb.CreateContextAttribs(window.DeviceContext, sharedContext != null ? (sharedContext as IGraphicsContextInternal).Context.Handle : IntPtr.Zero, local_1.ToArray())); int temp_84 = this.Handle == ContextHandle.Zero ? 1 : 0; } catch (EntryPointNotFoundException exception_0) { } catch (NullReferenceException exception_1) { } } } if (this.Handle == ContextHandle.Zero) { this.Handle = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); if (this.Handle == ContextHandle.Zero) { this.Handle = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext)); } if (this.Handle == ContextHandle.Zero) { throw new GraphicsContextException(string.Format("Context creation failed. Wgl.CreateContext() error: {0}.", (object)Marshal.GetLastWin32Error())); } } if (sharedContext == null) { return; } Marshal.GetLastWin32Error(); Wgl.Imports.ShareLists((sharedContext as IGraphicsContextInternal).Context.Handle, this.Handle.Handle); } }
public override void LoadAll() { lock (WinGLContext.LoadLock) { Wgl.LoadAll(); this.vsync_supported = Wgl.Arb.SupportsExtension(this, "WGL_EXT_swap_control") && Wgl.Load("wglGetSwapIntervalEXT") && Wgl.Load("wglSwapIntervalEXT"); } base.LoadAll(); }
public override GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext() { return(delegate { return new ContextHandle(Wgl.GetCurrentContext()); }); }