ddst's picture

Wgl Accessibility and extra functions

Hello

Since there is a new version of OpenTK (great job by the way) we felt the need to update. This helped us to sort out some issues we had in the past.

However in the implementation of 2010 we set the Wgl public because we used 2 fuctions for text drawing (OpenTK.Platform.Windows.Wgl.GetCurrentDC and OpenTK.Platform.Windows.Wgl.UseFontBitmapsW). Is it possible to add these functions again? or is it possible that we can do this ourselves?

Thanks in advance!


Comments

Comment viewing options

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

OpenTK does not expose any platform-specific code (i.e. anything under OpenTK.Platform.*). This is a conscious design decision.

In this case, the best solution by far would be to add these two functions directly to your codebase:

using System;
using System.Runtime.InteropServices;
 
// Feel free to change the namespace to suit your project
namespace OpenTK.Platform.Windows
{
    static class Wgl
    {
        const string Library = "opengl32.dll";
 
        [DllImport(Wgl.Library, EntryPoint = "wglGetCurrentDC", ExactSpelling = true, SetLastError = true)]
        public extern static IntPtr GetCurrentDC();
 
        [DllImport(Wgl.Library, EntryPoint = "wglUseFontBitmapsW", CharSet = CharSet.Unicode)]
        public extern static Boolean UseFontBitmapsW(IntPtr hDC, Int32 first, Int32 count, Int32 listBase);
    }
}

And that's all you need!

As a bonus, you don't need to modify OpenTK so you can update to newer versions (for bugfixes / features) without unnecessary complications.

Edit: fixed charset for Wgl.UseFontBitmapsW.