From 1168904c1c83ad1958a4bc2e39447e7f0732ad28 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 21 Feb 2017 04:20:12 +0200 Subject: [PATCH] Tweak the wgl test context --- tests/Tests/GlContexts/Wgl/Wgl.cs | 25 ++++++++++++++++++------ tests/Tests/GlContexts/Wgl/WglContext.cs | 4 ++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/Tests/GlContexts/Wgl/Wgl.cs b/tests/Tests/GlContexts/Wgl/Wgl.cs index c601df8b..d036f163 100644 --- a/tests/Tests/GlContexts/Wgl/Wgl.cs +++ b/tests/Tests/GlContexts/Wgl/Wgl.cs @@ -12,6 +12,9 @@ namespace SkiaSharp.Tests public const int FALSE = 0; public const int TRUE = 1; + public const int GL_VERSION = 0x1F02; + public const int GL_EXTENSIONS = 0x1F03; + public const int WGL_NUMBER_PIXEL_FORMATS_ARB = 0x2000; public const int WGL_DRAW_TO_WINDOW_ARB = 0x2001; public const int WGL_DRAW_TO_BITMAP_ARB = 0x2002; @@ -138,10 +141,6 @@ namespace SkiaSharp.Tests wglGetPbufferDCARB = Wgl.wglGetProcAddress("wglGetPbufferDCARB"); wglReleasePbufferDCARB = Wgl.wglGetProcAddress("wglReleasePbufferDCARB"); wglSwapIntervalEXT = Wgl.wglGetProcAddress("wglSwapIntervalEXT"); - // GET_PROC(ChoosePixelFormat, ARB); - // GET_PROC(GetPixelFormatAttribiv, ARB); - // GET_PROC(GetPixelFormatAttribfv, ARB); - // GET_PROC(CreateContextAttribs, ARB); // destroy the dummy GL context Wgl.wglMakeCurrent(dummyDC, IntPtr.Zero); @@ -154,9 +153,14 @@ namespace SkiaSharp.Tests // reset the initial GL context Wgl.wglMakeCurrent(prevDC, prevGLRC); } - + public static bool HasExtension(IntPtr dc, string ext) { + if (wglGetExtensionsStringARB == null) + { + return false; + } + if (ext == "WGL_ARB_extensions_string") { return true; @@ -211,10 +215,19 @@ namespace SkiaSharp.Tests var ptr = wglGetProcAddress(lpszProc); if (ptr == IntPtr.Zero) { - throw new Exception("Unable to load proc: " + lpszProc); + return default(T); } return (T)(object)Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)); } + + [DllImport(opengl32, CallingConvention = CallingConvention.Winapi)] + public static extern IntPtr glGetString(uint value); + + public static string GetString(uint value) + { + var intPtr = glGetString(value); + return Marshal.PtrToStringAnsi(intPtr); + } } [UnmanagedFunctionPointer(CallingConvention.Winapi)] diff --git a/tests/Tests/GlContexts/Wgl/WglContext.cs b/tests/Tests/GlContexts/Wgl/WglContext.cs index 3a3e5889..748921ce 100644 --- a/tests/Tests/GlContexts/Wgl/WglContext.cs +++ b/tests/Tests/GlContexts/Wgl/WglContext.cs @@ -141,9 +141,9 @@ namespace SkiaSharp.Tests Wgl.wglDeleteContext(fPbufferGlContext); - Wgl.wglReleasePbufferDCARB(fPbuffer, fPbufferDC); + Wgl.wglReleasePbufferDCARB?.Invoke(fPbuffer, fPbufferDC); - Wgl.wglDestroyPbufferARB(fPbuffer); + Wgl.wglDestroyPbufferARB?.Invoke(fPbuffer); if (fWindow != IntPtr.Zero) {