Added setter to GLContext.CurrentContext and all implementations, so that the user can clear the context of any thread.
Updated GameWindow and its implementations to use GraphicsFormat instead of the obsolete DisplayMode. Updated license. Updated some docs. Fixed CLSCopmliant warnings in XRamExtension.cs
This commit is contained in:
parent
d2b453e4c1
commit
56cbbb8cbb
14 changed files with 247 additions and 287 deletions
|
@ -1,6 +1,8 @@
|
|||
#region --- License ---
|
||||
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
||||
* See license.txt for license info
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
@ -17,6 +19,7 @@ namespace OpenTK
|
|||
using OpenTK.Graphics;
|
||||
|
||||
/// <summary>Defines the display mode for a render window.</summary>
|
||||
[Obsolete]
|
||||
public sealed class DisplayMode
|
||||
{
|
||||
#region --- Private Variables ---
|
||||
|
@ -36,72 +39,11 @@ namespace OpenTK
|
|||
|
||||
#region --- Constructors ---
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new DisplayMode from the given DisplayMode.
|
||||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
public DisplayMode(DisplayMode mode)
|
||||
: this(mode.ColorFormat, mode.Depth, mode.Stencil, mode.AuxilliaryColorFormat, mode.Buffers, mode.Stereo) { }
|
||||
: this(mode.width, mode.height, mode.color_format, mode.depthBits, mode.stencilBits, mode.auxilliary_color_format.BitsPerPixel,
|
||||
mode.buffers, mode.fullscreen, mode.stereo, mode.vsync, mode.refreshRate) { }
|
||||
|
||||
/// <summary>Constructs a new DisplayMode with sensible default parameters.</summary>
|
||||
public DisplayMode()
|
||||
: this(DisplayDevice.PrimaryDisplay.BitsPerPixel, 16, 0, 0, 2, false)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Constructs a new DisplayMode with the specified parameters.</summary>
|
||||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
public DisplayMode(ColorMode color)
|
||||
: this(color, 16, 0, 0, 2, false) { }
|
||||
|
||||
/// <summary>Constructs a new DisplayMode with the specified parameters.</summary>
|
||||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
/// <param name="depth">The number of bits in the depth buffer.</param>
|
||||
public DisplayMode(ColorMode color, int depth)
|
||||
: this(color, depth, 0, 0, 2, false) { }
|
||||
|
||||
/// <summary>Constructs a new DisplayMode with the specified parameters.</summary>
|
||||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
/// <param name="depth">The number of bits in the depth buffer.</param>
|
||||
/// <param name="stencil">The number of bits in the stencil buffer.</param>
|
||||
public DisplayMode(ColorMode color, int depth, int stencil)
|
||||
: this(color, depth, stencil, 0, 2, false) { }
|
||||
|
||||
/// <summary>Constructs a new DisplayMode with the specified parameters.</summary>
|
||||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
/// <param name="depth">The number of bits in the depth buffer.</param>
|
||||
/// <param name="stencil">The number of bits in the stencil buffer.</param>
|
||||
/// <param name="aux">The ColorMode of the auxilliary buffer.</param>
|
||||
public DisplayMode(ColorMode color, int depth, int stencil, ColorMode aux)
|
||||
: this(color, depth, stencil, aux, 2, false) { }
|
||||
|
||||
/// <summary>Constructs a new DisplayMode with the specified parameters.</summary>
|
||||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
/// <param name="depth">The number of bits in the depth buffer.</param>
|
||||
/// <param name="stencil">The number of bits in the stencil buffer.</param>
|
||||
/// <param name="aux">The ColorMode of the auxilliary buffer.</param>
|
||||
/// <param name="buffers">The number of render buffers. Typical values include one (single-), two (double-) or three (triple-buffering).</param>
|
||||
public DisplayMode(ColorMode color, int depth, int stencil, ColorMode aux, int buffers)
|
||||
: this(color, depth, stencil, aux, buffers, false) { }
|
||||
|
||||
/// <summary>Constructs a new DisplayMode with the specified parameters.</summary>
|
||||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
/// <param name="depth">The number of bits in the depth buffer.</param>
|
||||
/// <param name="stencil">The number of bits in the stencil buffer.</param>
|
||||
/// <param name="aux">The ColorMode of the auxilliary buffer.</param>
|
||||
/// <param name="stereo">Set to true for a DisplayMode with stereographic capabilities.</param>
|
||||
/// <param name="buffers">The number of render buffers. Typical values include one (single-), two (double-) or three (triple-buffering).</param>
|
||||
public DisplayMode(ColorMode color, int depth, int stencil, ColorMode aux, int buffers, bool stereo)
|
||||
{
|
||||
this.ColorFormat = color;
|
||||
this.Depth = depth;
|
||||
this.Stencil = stencil;
|
||||
this.AuxilliaryColorFormat = aux;
|
||||
this.Buffers = buffers;
|
||||
this.Stereo = stereo;
|
||||
}
|
||||
|
||||
#region Obsolete Constructors
|
||||
public DisplayMode() : this(640, 480) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new DisplayMode from the specified parameters.
|
||||
|
@ -117,7 +59,6 @@ namespace OpenTK
|
|||
/// <param name="buffers">The number of render buffers. Typical values include one (single-), two (double-) or three (triple-buffering).</param>
|
||||
/// <param name="vsync">Set to true to sync the updates to the screen refresh rate.</param>
|
||||
/// <param name="refresh">The desired RefreshRate. Taken into account only for Fullscreen DisplayModes.</param>
|
||||
[Obsolete]
|
||||
public DisplayMode(int width, int height, ColorMode color, int depth, int stencil, int aux, int buffers,
|
||||
bool fullscreen, bool stereo, bool vsync, float refresh)
|
||||
{
|
||||
|
@ -139,7 +80,6 @@ namespace OpenTK
|
|||
/// </summary>
|
||||
/// <param name="width">The Width of the DisplayMode in pixels.</param>
|
||||
/// <param name="height">The Height of the DisplayMode in pixels.</param>
|
||||
[Obsolete]
|
||||
public DisplayMode(int width, int height)
|
||||
: this(width, height, DisplayDevice.PrimaryDisplay.BitsPerPixel, 16, 0, 0, 0, false, false, false, 0.0f)
|
||||
{
|
||||
|
@ -151,7 +91,6 @@ namespace OpenTK
|
|||
/// <param name="width">The Width of the DisplayMode in pixels.</param>
|
||||
/// <param name="height">The Height of the DisplayMode in pixels.</param>
|
||||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
[Obsolete]
|
||||
public DisplayMode(int width, int height, ColorMode color)
|
||||
: this(width, height, color, 16, 0, 0, 0, false, false, false, 0.0f)
|
||||
{
|
||||
|
@ -164,7 +103,6 @@ namespace OpenTK
|
|||
/// <param name="height">The Height of the DisplayMode in pixels.</param>
|
||||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
/// <param name="depth">The number of bits in the depth buffer.</param>
|
||||
[Obsolete]
|
||||
public DisplayMode(int width, int height, ColorMode color, int depth)
|
||||
: this(width, height, color, depth, 0, 0, 0, false, false, false, 0.0f)
|
||||
{
|
||||
|
@ -178,7 +116,6 @@ namespace OpenTK
|
|||
/// <param name="color">The ColorMode of the color buffer.</param>
|
||||
/// <param name="depth">The number of bits in the depth buffer.</param>
|
||||
/// <param name="fullscreen">True for a fullscreen DisplayMode, false otherwise.</param>
|
||||
[Obsolete]
|
||||
public DisplayMode(int width, int height, ColorMode color, int depth, bool fullscreen)
|
||||
: this(width, height, color, depth, 0, 0, 0, fullscreen, false, false, 0.0f)
|
||||
{
|
||||
|
@ -186,10 +123,8 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- Public Properties ---
|
||||
|
||||
#if false
|
||||
#region public int ColorFormat
|
||||
|
||||
/// <summary>
|
||||
|
@ -243,12 +178,15 @@ namespace OpenTK
|
|||
}
|
||||
|
||||
#endregion
|
||||
#endif
|
||||
#region Obsolete Properties
|
||||
|
||||
#region public bool Stereo
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Boolean indicating whether this DisplayMode is stereoscopic.
|
||||
/// </summary>
|
||||
[Obsolete("Use GraphicsFormat.Stereo instead.")]
|
||||
public bool Stereo
|
||||
{
|
||||
get { return this.stereo; }
|
||||
|
@ -263,6 +201,7 @@ namespace OpenTK
|
|||
/// Gets a System.Int32 containing the number of buffers associated with this
|
||||
/// DisplayMode.
|
||||
/// </summary>
|
||||
[Obsolete("Use GraphicsFormat.Buffers instead.")]
|
||||
public int Buffers
|
||||
{
|
||||
get { return this.buffers; }
|
||||
|
@ -271,8 +210,6 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#region Obsolete Properties
|
||||
|
||||
[Obsolete("Use GameWindow.Fullscreen instead.")]
|
||||
public bool Fullscreen
|
||||
{
|
||||
|
@ -287,7 +224,7 @@ namespace OpenTK
|
|||
internal set { this.vsync = value; }
|
||||
}
|
||||
|
||||
[Obsolete("Use OpenTK.Graphics.Display.RefreshRate instead.")]
|
||||
[Obsolete("Use OpenTK.Graphics.DisplayDevice.RefreshRate instead.")]
|
||||
public float RefreshRate
|
||||
{
|
||||
get { return this.refreshRate; }
|
||||
|
@ -296,7 +233,7 @@ namespace OpenTK
|
|||
|
||||
#region public ColorDepth Color
|
||||
|
||||
[Obsolete("Use DisplayMode.ColorFormat instead.")]
|
||||
[Obsolete("Use GraphicsFormat.Color instead.")]
|
||||
public ColorMode Color
|
||||
{
|
||||
get { return this.color_format; }
|
||||
|
@ -345,31 +282,36 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
[Obsolete("Use DisplayMode.Depth instead.")]
|
||||
[Obsolete("Use GraphicsFormat.Depth instead.")]
|
||||
public int DepthBits
|
||||
{
|
||||
get { return this.depthBits; }
|
||||
internal set { this.depthBits = value; }
|
||||
}
|
||||
|
||||
[Obsolete("Use DisplayMode.Stencil instead.")]
|
||||
[Obsolete("Use GraphicsFormat.Stencil instead.")]
|
||||
public int StencilBits
|
||||
{
|
||||
get { return this.stencilBits; }
|
||||
internal set { this.stencilBits = value; }
|
||||
}
|
||||
|
||||
[Obsolete("Use DisplayMode.AuxilliaryColorFormat instead.")]
|
||||
[Obsolete("Use GraphicsFormat.AuxilliaryColorFormat instead.")]
|
||||
public int AuxBits
|
||||
{
|
||||
get { return this.AuxilliaryColorFormat.BitsPerPixel; }
|
||||
internal set { this.AuxilliaryColorFormat = value; }
|
||||
get { return this.auxilliary_color_format.BitsPerPixel; }
|
||||
internal set { this.auxilliary_color_format = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
internal GraphicsFormat ToGraphicsFormat()
|
||||
{
|
||||
return new GraphicsFormat(this.Color, this.DepthBits, this.StencilBits, this.AuxBits, this.Buffers, this.Stereo);
|
||||
}
|
||||
|
||||
#region --- Overrides ---
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace OpenTK
|
|||
internal static GetCurrentContextDelegate GetCurrentContext;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the context which is current in the calling thread.
|
||||
/// Gets or sets the current GraphicsContext in the calling thread.
|
||||
/// </summary>
|
||||
public static GLContext CurrentContext
|
||||
{
|
||||
|
@ -112,6 +112,13 @@ namespace OpenTK
|
|||
return null;
|
||||
//return (GLContext)available_contexts[StaticGetCurrentContext().ToInt64()].Target;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
value.MakeCurrent();
|
||||
else if (CurrentContext != null)
|
||||
CurrentContext.IsCurrent = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -204,6 +211,7 @@ namespace OpenTK
|
|||
public bool IsCurrent
|
||||
{
|
||||
get { return implementation.IsCurrent; }
|
||||
set { implementation.IsCurrent = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -253,15 +261,15 @@ namespace OpenTK
|
|||
get { return (implementation as IGLContextInternal).Mode; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the
|
||||
/// calling thread, or IntPtr.Zero if no OpenGL context is current.
|
||||
/// </summary>
|
||||
/// <returns>A System.IntPtr that holds the handle to the current OpenGL context.</returns>
|
||||
ContextHandle IGLContextInternal.GetCurrentContext()
|
||||
{
|
||||
return (implementation as IGLContextInternal).GetCurrentContext();
|
||||
}
|
||||
///// <summary>
|
||||
///// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the
|
||||
///// calling thread, or IntPtr.Zero if no OpenGL context is current.
|
||||
///// </summary>
|
||||
///// <returns>A System.IntPtr that holds the handle to the current OpenGL context.</returns>
|
||||
//ContextHandle IGLContextInternal.GetCurrentContext()
|
||||
//{
|
||||
// return (implementation as IGLContextInternal).GetCurrentContext();
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an OpenGL resource for disposal.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#region --- License ---
|
||||
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
||||
* See license.txt for license info
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
@ -8,12 +10,13 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
using OpenTK.Platform;
|
||||
using OpenTK.Input;
|
||||
using System.Threading;
|
||||
using OpenTK.OpenGL;
|
||||
using OpenTK.OpenGL.Enums;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
|
@ -86,25 +89,23 @@ namespace OpenTK
|
|||
|
||||
#region --- Contructors ---
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new GameWindow using a safe DisplayMode.
|
||||
/// </summary>
|
||||
public GameWindow() : this(new DisplayMode(640, 480, 0, 16, false), "OpenTK game window")
|
||||
{ }
|
||||
public GameWindow() : this("OpenTK Game Window", 640, 480, null, GraphicsFormat.Default) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new GameWindow, and opens a render window with the specified DisplayMode.
|
||||
/// </summary>
|
||||
/// <param name="mode">The DisplayMode of the GameWindow.</param>
|
||||
public GameWindow(DisplayMode mode) : this(mode, "OpenTK game window") { }
|
||||
public GameWindow(string title) : this(title, 640, 480, null, GraphicsFormat.Default) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new GameWindow with the specified title, and opens a render window with the
|
||||
/// specified DisplayMode.
|
||||
/// </summary>
|
||||
/// <param name="mode">The DisplayMode of the GameWindow.</param>
|
||||
/// <param name="title">The Title of the GameWindow.</param>
|
||||
public GameWindow(DisplayMode mode, string title)
|
||||
public GameWindow(string title, int width, int height)
|
||||
: this(title, width, height, null, GraphicsFormat.Default) { }
|
||||
|
||||
public GameWindow(string title, int width, int height, GraphicsFormat format)
|
||||
: this(title, width, height, null, format) { }
|
||||
|
||||
public GameWindow(string title, DisplayResolution resolution)
|
||||
: this(title, resolution.Width, resolution.Height, resolution, GraphicsFormat.Default) { }
|
||||
|
||||
public GameWindow(string title, DisplayResolution resolution, GraphicsFormat format)
|
||||
: this(title, resolution.Width, resolution.Height, resolution, format) { }
|
||||
|
||||
GameWindow(string title, int width, int height, DisplayResolution resolution, GraphicsFormat format)
|
||||
{
|
||||
switch (Environment.OSVersion.Platform)
|
||||
{
|
||||
|
@ -122,15 +123,43 @@ namespace OpenTK
|
|||
|
||||
default:
|
||||
throw new PlatformNotSupportedException(
|
||||
"Your platform is not supported currently. Please, refer to http://opentk.sourceforge.net for more information.");
|
||||
"Your platform is not supported currently. Please, refer to http://www.opentk.com for more information.");
|
||||
}
|
||||
|
||||
glWindow.Destroy += glWindow_Destroy;
|
||||
|
||||
CreateWindow(mode, title);
|
||||
// TODO: GLContext is created inside this call.
|
||||
glWindow.CreateWindow(width, height, format, out glContext);
|
||||
this.Title = title;
|
||||
|
||||
//this.vsync = VSyncMode.Adaptive;
|
||||
this.VSync = VSyncMode.On;
|
||||
if (resolution != null)
|
||||
{
|
||||
DisplayDevice.PrimaryDisplay.ChangeResolution(resolution);
|
||||
this.Fullscreen = true;
|
||||
}
|
||||
|
||||
this.VSync = VSyncMode.On; //VSyncMode.Adaptive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new GameWindow, and opens a render window with the specified DisplayMode.
|
||||
/// </summary>
|
||||
/// <param name="mode">The DisplayMode of the GameWindow.</param>
|
||||
[Obsolete]
|
||||
public GameWindow(DisplayMode mode)
|
||||
: this("OpenTK Game Window", mode.Width, mode.Height,
|
||||
mode.Fullscreen ? DisplayDevice.PrimaryDisplay.SelectResolution(
|
||||
mode.Width, mode.Height, mode.Color.BitsPerPixel, 0) : null, mode.ToGraphicsFormat()) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new GameWindow with the specified title, and opens a render window with the
|
||||
/// specified DisplayMode.
|
||||
/// </summary>
|
||||
/// <param name="mode">The DisplayMode of the GameWindow.</param>
|
||||
/// <param name="title">The Title of the GameWindow.</param>
|
||||
[Obsolete]
|
||||
public GameWindow(DisplayMode mode, string title)
|
||||
{
|
||||
}
|
||||
|
||||
void glWindow_Destroy(object sender, EventArgs e)
|
||||
|
@ -215,17 +244,7 @@ namespace OpenTK
|
|||
/// </summary>
|
||||
public IGLContext Context
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.Exists && !this.IsExiting)
|
||||
{
|
||||
Debug.WriteLine("WARNING: OpenGL Context accessed before creating a render window. This may indicate a programming error. Force-creating a render window.");
|
||||
mode = new DisplayMode(640, 480);
|
||||
this.CreateWindow(mode);
|
||||
}
|
||||
//return glWindow.Context;
|
||||
return glContext;
|
||||
}
|
||||
get { return glContext; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -311,38 +330,6 @@ namespace OpenTK
|
|||
|
||||
#endif
|
||||
|
||||
#region public void CreateWindow(DisplayMode mode)
|
||||
|
||||
/// <summary>
|
||||
/// Creates a render window for the calling GameWindow.
|
||||
/// </summary>
|
||||
/// <param name="mode">The DisplayMode of the render window.</param>
|
||||
/// <remarks>
|
||||
/// It is an error to call this function when a render window already exists.
|
||||
/// <para>Call DestroyWindow to close the render window.</para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ApplicationException">Occurs when a render window already exists.</exception>
|
||||
public void CreateWindow(DisplayMode mode)
|
||||
{
|
||||
if (!Exists)
|
||||
{
|
||||
try
|
||||
{
|
||||
glWindow.CreateWindow(mode.Width, mode.Height, mode, out glContext);
|
||||
}
|
||||
catch (ApplicationException expt)
|
||||
{
|
||||
Debug.Print(expt.ToString());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ApplicationException("A render window already exists for this GameWindow.");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public void DestroyWindow()
|
||||
|
||||
|
@ -362,34 +349,7 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#region --- GameWindow Methods ---
|
||||
|
||||
#region public void CreateWindow(DisplayMode mode, string title)
|
||||
|
||||
/// <summary>
|
||||
/// Creates a render window for the calling GameWindow, with the specified DisplayMode and Title.
|
||||
/// </summary>
|
||||
/// <param name="mode">The DisplayMode of the render window.</param>
|
||||
/// <param name="title">The Title of the render window.</param>
|
||||
/// <remarks>
|
||||
/// It is an error to call this function when a render window already exists.
|
||||
/// <para>Call DestroyWindow to close the render window.</para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ApplicationException">Occurs when a render window already exists.</exception>
|
||||
private void CreateWindow(DisplayMode mode, string title)
|
||||
{
|
||||
if (!Exists)
|
||||
{
|
||||
// TODO: This is a hack - reslove in 0.3.15 once and for all!
|
||||
// GLContext is created inside the CreateWindow call.
|
||||
glWindow.CreateWindow(mode.Width, mode.Height, mode, out glContext);
|
||||
this.Title = title;
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException("A render window already exists for this GameWindow.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region --- Public Methods ---
|
||||
|
||||
#region void Run()
|
||||
|
||||
|
@ -519,7 +479,7 @@ namespace OpenTK
|
|||
if (VSync == VSyncMode.Adaptive)
|
||||
{
|
||||
// Check if we have enough time for a vsync
|
||||
if (RenderTime > 2.0 * TargetRenderPeriod)
|
||||
if (TargetRenderPeriod != 0 && RenderTime > 2.0 * TargetRenderPeriod)
|
||||
Context.VSync = false;
|
||||
else
|
||||
Context.VSync = true;
|
||||
|
@ -609,12 +569,6 @@ namespace OpenTK
|
|||
/// <param name="e"></param>
|
||||
private void OnRenderFrameInternal(RenderFrameEventArgs e)
|
||||
{
|
||||
if (!this.Exists && !this.IsExiting)
|
||||
{
|
||||
Debug.Print("WARNING: RenderFrame event raised, without a valid render window. This may indicate a programming error. Creating render window.");
|
||||
mode = new DisplayMode(640, 480);
|
||||
this.CreateWindow(mode);
|
||||
}
|
||||
if (RenderFrame != null)
|
||||
RenderFrame(this, e);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace OpenTK.OpenAL
|
|||
|
||||
#region X-RAM Function pointer definitions
|
||||
|
||||
[CLSCompliant( false )]
|
||||
//[CLSCompliant(false)]
|
||||
private delegate bool Delegate_SetBufferMode( int n, ref uint buffers, int value );
|
||||
//typedef ALboolean (__cdecl *EAXSetBufferMode)(ALsizei n, ALuint *buffers, ALint value);
|
||||
|
||||
|
@ -159,4 +159,4 @@ namespace OpenTK.OpenAL
|
|||
#endregion Public Methods
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace OpenTK.Platform
|
|||
|
||||
public void SwapBuffers() { }
|
||||
public void MakeCurrent() { }
|
||||
public bool IsCurrent { get { return true; } }
|
||||
public bool IsCurrent { get { return true; } set { } }
|
||||
public IntPtr GetCurrentContext() { return IntPtr.Zero; }
|
||||
|
||||
public event DestroyEvent<IGLContext> Destroy;
|
||||
|
|
|
@ -24,20 +24,20 @@ namespace OpenTK.Platform
|
|||
/// <seealso cref="CreateContext(bool)"/>
|
||||
void CreateContext(bool direct, IGLContext source);
|
||||
|
||||
/// <summary>
|
||||
/// Swaps buffers, presenting the rendered scene to the user.
|
||||
/// </summary>
|
||||
/// <summary>Swaps buffers, presenting the rendered scene to the user.</summary>
|
||||
void SwapBuffers();
|
||||
|
||||
/// <summary>
|
||||
/// Makes the Context current in the calling thread, i.e. future OpenGL commands will affect this Context.
|
||||
/// </summary>
|
||||
/// <summary>Makes the GraphicsContext current in the calling thread.</summary>
|
||||
/// <remarks>
|
||||
/// <para>OpenGL commands in one thread, affect the GraphicsContext which is current in that thread.</para>
|
||||
/// <para>It is an error to issue an OpenGL command in a thread without a current GraphicsContext.</para>
|
||||
/// </remarks>
|
||||
void MakeCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Boolean indicating whether this Context is current in the calling thread.
|
||||
/// Gets or sets a System.Boolean indicating whether the GraphicsContext is current in the calling thread.
|
||||
/// </summary>
|
||||
bool IsCurrent { get; }
|
||||
bool IsCurrent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a Context is destroyed.
|
||||
|
@ -79,12 +79,12 @@ namespace OpenTK.Platform
|
|||
/// </summary>
|
||||
DisplayMode Mode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the
|
||||
/// calling thread, or IntPtr.Zero if no OpenGL context is current.
|
||||
/// </summary>
|
||||
/// <returns>A System.IntPtr that holds the handle to the current OpenGL context.</returns>
|
||||
ContextHandle GetCurrentContext();
|
||||
///// <summary>
|
||||
///// Gets a System.IntPtr containing the handle to the OpenGL context which is current in the
|
||||
///// calling thread, or IntPtr.Zero if no OpenGL context is current.
|
||||
///// </summary>
|
||||
///// <returns>A System.IntPtr that holds the handle to the current OpenGL context.</returns>
|
||||
//ContextHandle GetCurrentContext();
|
||||
|
||||
/// <summary>
|
||||
/// Registers an OpenGL resource for disposal.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#region --- License ---
|
||||
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
||||
* See license.txt for license info
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
|
@ -9,15 +11,17 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
|
||||
using OpenTK.Input;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK.Platform
|
||||
{
|
||||
/// <summary>
|
||||
/// This interface supports OpenTK, and is not intended for use by OpenTK programs.
|
||||
/// </summary>
|
||||
interface INativeGLWindow : IResizable, IDisposable
|
||||
internal interface INativeGLWindow : IResizable, IDisposable
|
||||
{
|
||||
void CreateWindow(int width, int height, DisplayMode mode, out IGLContext context);
|
||||
//void CreateWindow(int width, int height, DisplayMode mode, out IGLContext context);
|
||||
void CreateWindow(int width, int height, GraphicsFormat mode, out IGLContext context);
|
||||
void DestroyWindow();
|
||||
void ProcessEvents();
|
||||
void PointToClient(ref System.Drawing.Point p);
|
||||
|
|
|
@ -38,13 +38,15 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region --- Contructors ---
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new WinGLContext object.
|
||||
/// </summary>
|
||||
static WinGLContext()
|
||||
{
|
||||
// Set the GetCurrentContext implementation.
|
||||
if (GLContext.GetCurrentContext == null)
|
||||
GLContext.GetCurrentContext = WinGLContext.GetCurrentContext;
|
||||
}
|
||||
|
||||
public WinGLContext()
|
||||
{
|
||||
if (GLContext.GetCurrentContext == null)
|
||||
GLContext.GetCurrentContext = this.GetCurrentContext;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -127,15 +129,14 @@ namespace OpenTK.Platform.Windows
|
|||
public bool IsCurrent
|
||||
{
|
||||
get { return Wgl.GetCurrentContext() == this.renderContext; }
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
Wgl.MakeCurrent(this.deviceContext, this.renderContext);
|
||||
else
|
||||
Wgl.MakeCurrent(IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public ContextHandle GetCurrentContext()
|
||||
|
||||
public ContextHandle GetCurrentContext()
|
||||
{
|
||||
return Wgl.GetCurrentContext();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -292,10 +293,10 @@ namespace OpenTK.Platform.Windows
|
|||
pixelFormat.AccumAlphaBits = (byte)accum.Alpha;
|
||||
}
|
||||
*/
|
||||
pixelFormat.DepthBits = (byte)mode.Depth;
|
||||
pixelFormat.StencilBits = (byte)mode.Stencil;
|
||||
pixelFormat.DepthBits = (byte)mode.DepthBits;
|
||||
pixelFormat.StencilBits = (byte)mode.StencilBits;
|
||||
|
||||
if (mode.Depth <= 0)
|
||||
if (mode.DepthBits <= 0)
|
||||
{
|
||||
pixelFormat.Flags |= PixelFormatDescriptorFlags.DEPTH_DONTCARE;
|
||||
}
|
||||
|
@ -348,7 +349,7 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region --- Internal Members ---
|
||||
#region --- Methods ---
|
||||
|
||||
#region internal IntPtr Device
|
||||
|
||||
|
@ -356,6 +357,15 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region static ContextHandle GetCurrentContext()
|
||||
|
||||
static ContextHandle GetCurrentContext()
|
||||
{
|
||||
return Wgl.GetCurrentContext();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- IDisposable Members ---
|
||||
|
|
|
@ -14,6 +14,7 @@ using System.Windows.Forms;
|
|||
using System.Diagnostics;
|
||||
using OpenTK.OpenGL;
|
||||
using OpenTK.Input;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -306,12 +307,13 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region public void CreateWindow(DisplayMode mode, out IGLContext context)
|
||||
#region public void CreateWindow(int width, int height, GraphicsFormat format, out IGLContext context)
|
||||
|
||||
public void CreateWindow(int width, int height, DisplayMode windowMode, out IGLContext context)
|
||||
public void CreateWindow(int width, int height, GraphicsFormat format, out IGLContext context)
|
||||
{
|
||||
Debug.Print("Creating native window with mode: {0}", windowMode.ToString());
|
||||
Debug.Print("Creating native window.");
|
||||
Debug.Indent();
|
||||
Debug.Print("GraphicsFormat: {0}", format.ToString());
|
||||
|
||||
CreateParams cp = new CreateParams();
|
||||
cp.ClassStyle =
|
||||
|
@ -346,7 +348,7 @@ namespace OpenTK.Platform.Windows
|
|||
cp.Width = rect.right - rect.left;
|
||||
cp.Height = rect.bottom - rect.top;
|
||||
cp.Caption = "OpenTK Game Window";
|
||||
|
||||
|
||||
// Keep in mind that some construction code runs in WM_CREATE,
|
||||
// which is raised CreateHandle()
|
||||
CreateHandle(cp);
|
||||
|
|
|
@ -679,16 +679,22 @@ XF86VidModeGetGammaRampSize(
|
|||
|
||||
#region internal struct XRRScreenSize
|
||||
|
||||
#pragma warning disable 0169, 0649
|
||||
|
||||
internal struct XRRScreenSize
|
||||
{
|
||||
internal int Width, Height;
|
||||
internal int MWidth, MHeight;
|
||||
};
|
||||
|
||||
#pragma warning restore 0169, 0649
|
||||
|
||||
#endregion
|
||||
|
||||
#region unsafe internal struct Screen
|
||||
|
||||
#pragma warning disable 0169
|
||||
|
||||
unsafe internal struct Screen
|
||||
{
|
||||
XExtData ext_data; /* hook for extension to hang data */
|
||||
|
@ -710,10 +716,14 @@ XF86VidModeGetGammaRampSize(
|
|||
long root_input_mask; /* initial root input mask */
|
||||
}
|
||||
|
||||
#pragma warning restore 0169
|
||||
|
||||
#endregion
|
||||
|
||||
#region unsafe internal class XExtData
|
||||
|
||||
#pragma warning disable 0169
|
||||
|
||||
unsafe internal class XExtData
|
||||
{
|
||||
int number; /* number returned by XRegisterExtension */
|
||||
|
@ -723,6 +733,8 @@ XF86VidModeGetGammaRampSize(
|
|||
XPointer private_data; /* data private to this extension. */
|
||||
};
|
||||
|
||||
#pragma warning restore 0169
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
@ -1263,7 +1275,7 @@ XF86VidModeGetGammaRampSize(
|
|||
/// <para>The XCreateSimpleWindow function creates an unmapped InputOutput subwindow for a specified parent window, returns the window ID of the created window, and causes the X server to generate a CreateNotify event. The created window is placed on top in the stacking order with respect to siblings. Any part of the window that extends outside its parent window is clipped. The border_width for an InputOnly window must be zero, or a BadMatch error results. XCreateSimpleWindow inherits its depth, class, and visual from its parent. All other window attributes, except background and border, have their default values. </para>
|
||||
/// <para>XCreateSimpleWindow can generate BadAlloc, BadMatch, BadValue, and BadWindow errors.</para>
|
||||
/// </remarks>
|
||||
[DllImport(X11Library, EntryPoint = "XCreateWindow"), CLSCompliant(false)]
|
||||
[DllImport(X11Library, EntryPoint = "XCreateWindow")]//, CLSCompliant(false)]
|
||||
public extern static Window XCreateWindow(Display display, Window parent,
|
||||
int x, int y, int width, int height, int border_width, int depth,
|
||||
int @class, IntPtr visual, UIntPtr valuemask, ref XSetWindowAttributes attributes);
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace OpenTK.Platform.X11
|
|||
[DllImport("libX11", EntryPoint = "XCreateWindow")]
|
||||
public extern static IntPtr XCreateWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, int depth, int xclass, IntPtr visual, IntPtr valuemask, ref XSetWindowAttributes attributes);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XCreateSimpleWindow"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XCreateSimpleWindow")]//, CLSCompliant(false)]
|
||||
public extern static IntPtr XCreateSimpleWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, UIntPtr border, UIntPtr background);
|
||||
[DllImport("libX11", EntryPoint = "XCreateSimpleWindow")]
|
||||
public extern static IntPtr XCreateSimpleWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, IntPtr border, IntPtr background);
|
||||
|
@ -81,10 +81,10 @@ namespace OpenTK.Platform.X11
|
|||
[DllImport("libX11", EntryPoint = "XRaiseWindow")]
|
||||
public extern static int XRaiseWindow(IntPtr display, IntPtr window);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XLowerWindow"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XLowerWindow")]//, CLSCompliant(false)]
|
||||
public extern static uint XLowerWindow(IntPtr display, IntPtr window);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XConfigureWindow"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XConfigureWindow")]//, CLSCompliant(false)]
|
||||
public extern static uint XConfigureWindow(IntPtr display, IntPtr window, ChangeWindowAttributes value_mask, ref XWindowChanges values);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XInternAtom")]
|
||||
|
@ -120,7 +120,7 @@ namespace OpenTK.Platform.X11
|
|||
[DllImport("libX11", EntryPoint = "XGetGeometry")]
|
||||
public extern static bool XGetGeometry(IntPtr display, IntPtr window, IntPtr root, IntPtr x, IntPtr y, out int width, out int height, IntPtr border_width, IntPtr depth);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XWarpPointer"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XWarpPointer")]//, CLSCompliant(false)]
|
||||
public extern static uint XWarpPointer(IntPtr display, IntPtr src_w, IntPtr dest_w, int src_x, int src_y, uint src_width, uint src_height, int dest_x, int dest_y);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XClearWindow")]
|
||||
|
@ -139,7 +139,7 @@ namespace OpenTK.Platform.X11
|
|||
[DllImport("libX11", EntryPoint = "XDefaultVisual")]
|
||||
public extern static IntPtr XDefaultVisual(IntPtr display, int screen_number);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XDefaultDepth"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XDefaultDepth")]//, CLSCompliant(false)]
|
||||
public extern static uint XDefaultDepth(IntPtr display, int screen_number);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XDefaultScreen")]
|
||||
|
@ -148,10 +148,10 @@ namespace OpenTK.Platform.X11
|
|||
[DllImport("libX11", EntryPoint = "XDefaultColormap")]
|
||||
public extern static IntPtr XDefaultColormap(IntPtr display, int screen_number);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XLookupColor"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XLookupColor")]//, CLSCompliant(false)]
|
||||
public extern static int XLookupColor(IntPtr display, IntPtr Colormap, string Coloranem, ref XColor exact_def_color, ref XColor screen_def_color);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XAllocColor"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XAllocColor")]//, CLSCompliant(false)]
|
||||
public extern static int XAllocColor(IntPtr display, IntPtr Colormap, ref XColor colorcell_def);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XSetTransientForHint")]
|
||||
|
@ -160,15 +160,15 @@ namespace OpenTK.Platform.X11
|
|||
[DllImport("libX11", EntryPoint = "XChangeProperty")]
|
||||
public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref MotifWmHints data, int nelements);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XChangeProperty"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XChangeProperty")]//, CLSCompliant(false)]
|
||||
public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref uint value, int nelements);
|
||||
[DllImport("libX11", EntryPoint = "XChangeProperty")]
|
||||
public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref int value, int nelements);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XChangeProperty"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XChangeProperty")]//, CLSCompliant(false)]
|
||||
public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref IntPtr value, int nelements);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XChangeProperty"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XChangeProperty")]//, CLSCompliant(false)]
|
||||
public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, uint[] data, int nelements);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XChangeProperty")]
|
||||
|
@ -235,7 +235,7 @@ namespace OpenTK.Platform.X11
|
|||
[DllImport("libX11", EntryPoint = "XCreateFontCursor")]
|
||||
public extern static IntPtr XCreateFontCursor(IntPtr display, CursorFontShape shape);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XCreatePixmapCursor"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XCreatePixmapCursor")]//, CLSCompliant(false)]
|
||||
public extern static IntPtr XCreatePixmapCursor(IntPtr display, IntPtr source, IntPtr mask, ref XColor foreground_color, ref XColor background_color, int x_hot, int y_hot);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XCreatePixmapFromBitmapData")]
|
||||
|
@ -301,12 +301,12 @@ namespace OpenTK.Platform.X11
|
|||
[DllImport("libX11", EntryPoint = "XSetPlaneMask")]
|
||||
public extern static int XSetPlaneMask(IntPtr display, IntPtr gc, IntPtr mask);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XSetForeground"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XSetForeground")]//, CLSCompliant(false)]
|
||||
public extern static int XSetForeground(IntPtr display, IntPtr gc, UIntPtr foreground);
|
||||
[DllImport("libX11", EntryPoint = "XSetForeground")]
|
||||
public extern static int XSetForeground(IntPtr display, IntPtr gc, IntPtr foreground);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XSetBackground"), CLSCompliant(false)]
|
||||
[DllImport("libX11", EntryPoint = "XSetBackground")]//, CLSCompliant(false)]
|
||||
public extern static int XSetBackground(IntPtr display, IntPtr gc, UIntPtr background);
|
||||
[DllImport("libX11", EntryPoint = "XSetBackground")]
|
||||
public extern static int XSetBackground(IntPtr display, IntPtr gc, IntPtr background);
|
||||
|
|
|
@ -31,9 +31,15 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
#region --- Constructors ---
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new X11GLContext object.
|
||||
/// </summary>
|
||||
static X11GLContext()
|
||||
{
|
||||
// Set the GetCurrentContext implementation.
|
||||
if (GLContext.GetCurrentContext == null)
|
||||
GLContext.GetCurrentContext = X11GLContext.GetCurrentContext;
|
||||
}
|
||||
|
||||
/// <private />
|
||||
/// <summary>Constructs a new X11GLContext object.</summary>
|
||||
public X11GLContext() { }
|
||||
|
||||
#endregion
|
||||
|
@ -85,7 +91,7 @@ namespace OpenTK.Platform.X11
|
|||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.ALPHA_SIZE);
|
||||
visualAttributes.Add((int)mode.Color.Alpha);
|
||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DEPTH_SIZE);
|
||||
visualAttributes.Add((int)mode.Depth);
|
||||
visualAttributes.Add((int)mode.DepthBits);
|
||||
visualAttributes.Add((int)Glx.Enums.GLXAttribute.DOUBLEBUFFER);
|
||||
visualAttributes.Add((int)0);
|
||||
}
|
||||
|
@ -130,16 +136,24 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
#endregion
|
||||
|
||||
#region public void CreateContext()
|
||||
|
||||
public void CreateContext()
|
||||
{
|
||||
this.CreateContext(true, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public void CreateContext(bool direct)
|
||||
|
||||
public void CreateContext(bool direct)
|
||||
{
|
||||
this.CreateContext(direct, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public void CreateContext(bool direct, IGLContext shareContext)
|
||||
|
||||
public void CreateContext(bool direct, IGLContext shareContext)
|
||||
|
@ -241,6 +255,13 @@ namespace OpenTK.Platform.X11
|
|||
public bool IsCurrent
|
||||
{
|
||||
get { return Glx.GetCurrentContext() == this.context; }
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
Glx.MakeCurrent(windowInfo.Display, windowInfo.Handle, context);
|
||||
else
|
||||
Glx.MakeCurrent(windowInfo.Handle, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -313,18 +334,9 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
#endregion
|
||||
|
||||
#region ContextHandle IGLContextInternal.GetCurrentContext()
|
||||
|
||||
ContextHandle IGLContextInternal.GetCurrentContext()
|
||||
{
|
||||
return (ContextHandle)Glx.GetCurrentContext();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- Public Methods ---
|
||||
#region --- Methods ---
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
|
@ -332,6 +344,15 @@ namespace OpenTK.Platform.X11
|
|||
Destroy(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#region static ContextHandle GetCurrentContext()
|
||||
|
||||
static ContextHandle GetCurrentContext()
|
||||
{
|
||||
return (ContextHandle)Glx.GetCurrentContext();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- IDisposable Members ---
|
||||
|
|
|
@ -392,20 +392,9 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
#endregion
|
||||
|
||||
#region public void CreateWindow(DisplayMode mode, out IGLContext glContext)
|
||||
#region public void CreateWindow(int width, int height, GraphicsFormat format, out IGLContext glContext)
|
||||
|
||||
/// <summary>
|
||||
/// Opens a new render window with the given DisplayMode.
|
||||
/// </summary>
|
||||
/// <param name="mode">The DisplayMode of the render window.</param>
|
||||
/// <remarks>
|
||||
/// Creates the window visual and colormap. Associates the colormap/visual
|
||||
/// with the window and raises the window on top of the window stack.
|
||||
/// <para>
|
||||
/// Colormap creation is currently disabled.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public void CreateWindow(int width, int height, DisplayMode mode, out IGLContext glContext)
|
||||
public void CreateWindow(int width, int height, GraphicsFormat format, out IGLContext glContext)
|
||||
{
|
||||
if (exists)
|
||||
throw new ApplicationException("Render window already exists!");
|
||||
|
@ -489,6 +478,26 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
#endregion
|
||||
|
||||
#region public void CreateWindow(int width, int height, DisplayMode mode, out IGLContext glContext)
|
||||
|
||||
/// <summary>
|
||||
/// Opens a new render window with the given DisplayMode.
|
||||
/// </summary>
|
||||
/// <param name="mode">The DisplayMode of the render window.</param>
|
||||
/// <remarks>
|
||||
/// Creates the window visual and colormap. Associates the colormap/visual
|
||||
/// with the window and raises the window on top of the window stack.
|
||||
/// <para>
|
||||
/// Colormap creation is currently disabled.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public void CreateWindow(int width, int height, DisplayMode mode, out IGLContext glContext)
|
||||
{
|
||||
this.CreateWindow(width, height, new GraphicsFormat(), out glContext);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnCreate
|
||||
|
||||
public event CreateEvent Create;
|
||||
|
@ -727,8 +736,8 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
MotifWmHints hints = new MotifWmHints();
|
||||
hints.flags = (IntPtr)MotifFlags.Decorations;
|
||||
Functions.XChangeProperty(this.window.Display, this.Handle, atom, atom, 32, PropertyMode.Replace, ref hints,
|
||||
Marshal.SizeOf(hints) / 4);
|
||||
Functions.XChangeProperty(this.window.Display, this.Handle, atom, atom, 32, PropertyMode.Replace, ref hints, 5
|
||||
/*Marshal.SizeOf(hints) / 4*/);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -763,7 +772,7 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
IntPtr hints = IntPtr.Zero;
|
||||
Functions.XChangeProperty(this.window.Display, this.Handle, atom, atom, 32, PropertyMode.Replace, ref hints,
|
||||
Marshal.SizeOf(hints) / 4);
|
||||
/*Marshal.SizeOf(hints) / 4*/ 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -780,8 +789,8 @@ namespace OpenTK.Platform.X11
|
|||
if (atom != IntPtr.Zero)
|
||||
{
|
||||
IntPtr hints = Functions.XInternAtom(this.window.Display, "_NET_WM_STATE_FULLSCREEN", true);
|
||||
Functions.XChangeProperty(this.window.Display, this.Handle, atom, atom, 32, PropertyMode.Replace, ref hints,
|
||||
Marshal.SizeOf(hints) / 4);
|
||||
Functions.XChangeProperty(this.window.Display, this.Handle, atom, atom, 32, PropertyMode.Replace, ref hints, 1
|
||||
/*Marshal.SizeOf(hints) / 4*/);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region --- License ---
|
||||
/* Licensed under the MIT/X11 license.
|
||||
* Copyright (c) 2006-2008 the OpenTK team.
|
||||
* This notice may not be removed.
|
||||
* Copyright (c) 2006-2008 the OpenTK Team.
|
||||
* This notice may not be removed from any source distribution.
|
||||
* See license.txt for licensing detailed licensing details.
|
||||
*/
|
||||
#endregion
|
||||
|
@ -18,8 +18,6 @@ namespace OpenTK.Platform.X11
|
|||
internal class X11XrandrDisplayDevice : IDisplayDeviceDriver
|
||||
{
|
||||
static object display_lock = new object();
|
||||
int current_size = -1; // current_size == -1 means it hasn't been changed.
|
||||
int current_refresh;
|
||||
// Store a mapping between resolutions and their respective
|
||||
// size_index (needed for XRRSetScreenConfig). The size_index
|
||||
// is simply the sequence number of the resolution as returned by
|
||||
|
|
Loading…
Reference in a new issue