mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-08-04 05:01:21 +00:00
Added loading of Glx extensions. Added vsync support.
This commit is contained in:
parent
67e8097865
commit
d6e2caf54f
|
@ -20,12 +20,14 @@ namespace OpenTK.Platform.X11
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class X11GLContext : IGLContext, IGLContextInternal, IGLContextCreationHack
|
internal sealed class X11GLContext : IGLContext, IGLContextInternal, IGLContextCreationHack
|
||||||
{
|
{
|
||||||
private IntPtr context;
|
IntPtr context;
|
||||||
private DisplayMode mode;
|
DisplayMode mode;
|
||||||
private WindowInfo windowInfo = new WindowInfo();
|
WindowInfo windowInfo = new WindowInfo();
|
||||||
private IntPtr visual;
|
IntPtr visual;
|
||||||
|
bool vsync_supported;
|
||||||
|
int vsync_interval;
|
||||||
|
|
||||||
private bool disposed;
|
bool disposed;
|
||||||
|
|
||||||
#region --- Constructors ---
|
#region --- Constructors ---
|
||||||
|
|
||||||
|
@ -164,6 +166,7 @@ namespace OpenTK.Platform.X11
|
||||||
this.MakeCurrent();
|
this.MakeCurrent();
|
||||||
GL.LoadAll();
|
GL.LoadAll();
|
||||||
Glu.LoadAll();
|
Glu.LoadAll();
|
||||||
|
Glx.LoadAll();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -179,10 +182,13 @@ namespace OpenTK.Platform.X11
|
||||||
this.MakeCurrent();
|
this.MakeCurrent();
|
||||||
GL.LoadAll();
|
GL.LoadAll();
|
||||||
Glu.LoadAll();
|
Glu.LoadAll();
|
||||||
|
Glx.LoadAll();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vsync_supported = Glx.SupportsExtension("glxSwapControlSGI");
|
||||||
|
|
||||||
throw new ApplicationException("Glx.CreateContext call failed (returned 0).");
|
throw new ApplicationException("Glx.CreateContext call failed (returned 0).");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -239,6 +245,28 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region public bool VSync
|
||||||
|
|
||||||
|
public bool VSync
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return vsync_supported && vsync_interval > 0;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (vsync_supported)
|
||||||
|
{
|
||||||
|
int error_code = Glx.Sgi.SwapInterval(value ? 1 : 0);
|
||||||
|
if (error_code != 0)
|
||||||
|
throw new GraphicsException(String.Format("Could not set vsync, error code: {0}", error_code));
|
||||||
|
vsync_interval = value ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public event DestroyEvent<IGLContext> Destroy;
|
public event DestroyEvent<IGLContext> Destroy;
|
||||||
|
|
||||||
#region public IntPtr GetAddress(string function)
|
#region public IntPtr GetAddress(string function)
|
||||||
|
@ -265,18 +293,6 @@ namespace OpenTK.Platform.X11
|
||||||
throw new Exception("The method or operation is not implemented.");
|
throw new Exception("The method or operation is not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool VSync
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- IGLContextInternal Members ---
|
#region --- IGLContextInternal Members ---
|
||||||
|
|
Loading…
Reference in a new issue