mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-04-18 04:51:49 +00:00
Make context current on loading thread and be more defensive when retrieving unmanaged entry points. Resolves issue [#1378]: "OpenGL Extensions test fails".
This commit is contained in:
parent
d5175d1d9c
commit
3c0787c6a9
|
@ -55,9 +55,15 @@ namespace Examples.WinForms
|
||||||
{
|
{
|
||||||
Application.Idle -= StartAsync;
|
Application.Idle -= StartAsync;
|
||||||
|
|
||||||
// Create a context in order to load all GL methods (GL.LoadAll() is called automatically.)
|
// Create a context to load all GL entry points.
|
||||||
using (GLControl control = new GLControl(GraphicsMode.Default, 3, 0, GraphicsContextFlags.Default))
|
// The loading part is handled automatically by OpenTK.
|
||||||
|
using (INativeWindow window = new OpenTK.NativeWindow())
|
||||||
|
using (IGraphicsContext context = new GraphicsContext(GraphicsMode.Default, window.WindowInfo, 3, 0, GraphicsContextFlags.Default))
|
||||||
{
|
{
|
||||||
|
window.ProcessEvents();
|
||||||
|
context.MakeCurrent(window.WindowInfo);
|
||||||
|
(context as IGraphicsContextInternal).LoadAll();
|
||||||
|
|
||||||
TextBoxVendor.Text = GL.GetString(StringName.Vendor);
|
TextBoxVendor.Text = GL.GetString(StringName.Vendor);
|
||||||
TextBoxRenderer.Text = GL.GetString(StringName.Renderer);
|
TextBoxRenderer.Text = GL.GetString(StringName.Renderer);
|
||||||
TextBoxVersion.Text = GL.GetString(StringName.Version);
|
TextBoxVersion.Text = GL.GetString(StringName.Version);
|
||||||
|
@ -73,11 +79,14 @@ namespace Examples.WinForms
|
||||||
|
|
||||||
foreach (Function f in LoadFunctionsFromType(typeof(GL)))
|
foreach (Function f in LoadFunctionsFromType(typeof(GL)))
|
||||||
{
|
{
|
||||||
|
FieldInfo @delegate = delegates.GetField(f.EntryPoint,
|
||||||
|
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
|
||||||
|
|
||||||
// Only show a function as supported when all relevant overloads are supported.
|
// Only show a function as supported when all relevant overloads are supported.
|
||||||
if (!functions.ContainsKey(f))
|
if (!functions.ContainsKey(f))
|
||||||
functions.Add(f, (bool)delegates.GetField(f.EntryPoint).GetValue(null));
|
functions.Add(f, @delegate != null && @delegate.GetValue(null) != null);
|
||||||
else
|
else
|
||||||
functions[f] &= (bool)delegates.GetField(f.EntryPoint).GetValue(null);
|
functions[f] &= @delegate != null && @delegate.GetValue(null) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count supported functions using the delegates directly.
|
// Count supported functions using the delegates directly.
|
||||||
|
|
Loading…
Reference in a new issue