Transformed compatible properties into auto-properties where possible.

This commit is contained in:
Jarl Gullberg 2017-07-07 11:51:45 +02:00
parent 4d2b5722ee
commit 127c6fd67d
No known key found for this signature in database
GPG key ID: 750FF6F6BDA72D23
66 changed files with 420 additions and 1087 deletions

View file

@ -17,14 +17,8 @@ namespace Bind.Structures
/// </summary> /// </summary>
class Constant : IComparable<Constant> class Constant : IComparable<Constant>
{ {
string original_name;
// Gets the name prior to translation. // Gets the name prior to translation.
public string OriginalName public string OriginalName { get; private set; }
{
get { return original_name; }
private set { original_name = value; }
}
string _name; string _name;
@ -67,20 +61,11 @@ namespace Bind.Structures
} }
} }
string _reference;
/// <summary> /// <summary>
/// Gets or sets a string indicating the OpenGL enum reference by this constant. /// Gets or sets a string indicating the OpenGL enum reference by this constant.
/// Can be null. /// Can be null.
/// </summary> /// </summary>
public string Reference public string Reference { get; set; }
{
get { return _reference; }
set
{
_reference = value;
}
}
public bool Unchecked public bool Unchecked
{ {

View file

@ -82,13 +82,7 @@ namespace Bind.Structures
} }
} }
private string _category; public string Category { get; set; }
public string Category
{
get { return _category; }
set { _category = value; }
}
/// <summary> /// <summary>
/// Gets a value that indicates whether this function needs to be wrapped with a Marshaling function. /// Gets a value that indicates whether this function needs to be wrapped with a Marshaling function.
@ -141,18 +135,10 @@ namespace Bind.Structures
} }
} }
Type _return_type = new Type();
/// <summary> /// <summary>
/// Gets or sets the return value of the opengl function. /// Gets or sets the return value of the opengl function.
/// </summary> /// </summary>
public Type ReturnType public Type ReturnType { get; set; } = new Type();
{
get { return _return_type; }
set
{
_return_type = value;
}
}
string _name; string _name;
/// <summary> /// <summary>
@ -170,24 +156,12 @@ namespace Bind.Structures
} }
} }
ParameterCollection _parameters; public ParameterCollection Parameters { get; set; }
public ParameterCollection Parameters
{
get { return _parameters; }
set { _parameters = value; }
}
string _version;
/// <summary> /// <summary>
/// Defines the opengl version that introduced this function. /// Defines the opengl version that introduced this function.
/// </summary> /// </summary>
public string Version public string Version { get; set; }
{
get { return _version; }
set { _version = value; }
}
public string Extension public string Extension
{ {

View file

@ -12,8 +12,6 @@ namespace Bind.Structures
{ {
class Function : Delegate, IEquatable<Function>, IComparable<Function> class Function : Delegate, IEquatable<Function>, IComparable<Function>
{ {
Delegate wrapped_delegate;
public Function(Delegate d) public Function(Delegate d)
: base(d) : base(d)
{ {
@ -34,11 +32,7 @@ namespace Bind.Structures
Body.AddRange(f.Body); Body.AddRange(f.Body);
} }
public Delegate WrappedDelegate public Delegate WrappedDelegate { get; set; }
{
get { return wrapped_delegate; }
set { wrapped_delegate = value; }
}
public void TurnVoidPointersToIntPtr() public void TurnVoidPointersToIntPtr()
{ {
@ -60,13 +54,7 @@ namespace Bind.Structures
} }
} }
FunctionBody _body; public FunctionBody Body { get; set; }
public FunctionBody Body
{
get { return _body; }
set { _body = value; }
}
public string TrimmedName { get; set; } public string TrimmedName { get; set; }

View file

@ -134,12 +134,7 @@ namespace Bind.Structures
} }
} }
bool generic; public bool Generic { get; set; }
public bool Generic
{
get { return generic; }
set { generic = value; }
}
// Returns true if this parameter differs only on reference compared to another parameter, i.e: // Returns true if this parameter differs only on reference compared to another parameter, i.e:
// returns true for 'int' & 'ref int' // returns true for 'int' & 'ref int'
@ -155,12 +150,7 @@ namespace Bind.Structures
other.Reference && !(Reference || Array > 0 || Pointer != 0)); other.Reference && !(Reference || Array > 0 || Pointer != 0));
} }
string computeSize; public string ComputeSize { get; set; }
public string ComputeSize
{
get { return computeSize; }
set { computeSize = value; }
}
// Returns the FlowDirection that matches the specified string // Returns the FlowDirection that matches the specified string
// ("out" or "in", otherwise undefined). // ("out" or "in", otherwise undefined).

View file

@ -13,7 +13,6 @@ namespace Bind.Structures
class Type : IComparable<Type>, IEquatable<Type> class Type : IComparable<Type>, IEquatable<Type>
{ {
string current_qualifier = String.Empty; string current_qualifier = String.Empty;
string previous_qualifier = String.Empty;
public Type() public Type()
{ {
@ -41,11 +40,7 @@ namespace Bind.Structures
set { PreviousQualifier = CurrentQualifier; current_qualifier = value; } set { PreviousQualifier = CurrentQualifier; current_qualifier = value; }
} }
string PreviousQualifier private string PreviousQualifier { get; set; } = String.Empty;
{
get { return previous_qualifier; }
set { previous_qualifier = value; }
}
public string QualifiedType public string QualifiedType
{ {
@ -103,21 +98,9 @@ namespace Bind.Structures
} }
} }
private string _previous_type; public string PreviousType { get; private set; }
public string PreviousType public bool Reference { get; set; }
{
get { return _previous_type; }
private set { _previous_type = value; }
}
bool reference;
public bool Reference
{
get { return reference; }
set { reference = value; }
}
int array; int array;
@ -209,13 +192,7 @@ namespace Bind.Structures
} }
} }
private WrapperTypes _wrapper_type = WrapperTypes.None; public WrapperTypes WrapperType { get; set; } = WrapperTypes.None;
public WrapperTypes WrapperType
{
get { return _wrapper_type; }
set { _wrapper_type = value; }
}
static readonly string[] PointerLevels = static readonly string[] PointerLevels =
{ {

View file

@ -228,40 +228,21 @@ namespace Mono.Options
} }
public class OptionContext { public class OptionContext {
private Option option;
private string name;
private int index;
private OptionSet set;
private OptionValueCollection c;
public OptionContext (OptionSet set) public OptionContext (OptionSet set)
{ {
this.set = set; this.OptionSet = set;
this.c = new OptionValueCollection (this); this.OptionValues = new OptionValueCollection (this);
} }
public Option Option { public Option Option { get; set; }
get {return option;}
set {option = value;}
}
public string OptionName { public string OptionName { get; set; }
get {return name;}
set {name = value;}
}
public int OptionIndex { public int OptionIndex { get; set; }
get {return index;}
set {index = value;}
}
public OptionSet OptionSet { public OptionSet OptionSet { get; }
get {return set;}
}
public OptionValueCollection OptionValues { public OptionValueCollection OptionValues { get; }
get {return c;}
}
} }
public enum OptionValueType { public enum OptionValueType {
@ -271,12 +252,6 @@ namespace Mono.Options
} }
public abstract class Option { public abstract class Option {
string prototype, description;
string[] names;
OptionValueType type;
int count;
string[] separators;
protected Option (string prototype, string description) protected Option (string prototype, string description)
: this (prototype, description, 1) : this (prototype, description, 1)
{ {
@ -291,44 +266,44 @@ namespace Mono.Options
if (maxValueCount < 0) if (maxValueCount < 0)
throw new ArgumentOutOfRangeException ("maxValueCount"); throw new ArgumentOutOfRangeException ("maxValueCount");
this.prototype = prototype; this.Prototype = prototype;
this.names = prototype.Split ('|'); this.Names = prototype.Split ('|');
this.description = description; this.Description = description;
this.count = maxValueCount; this.MaxValueCount = maxValueCount;
this.type = ParsePrototype (); this.OptionValueType = ParsePrototype ();
if (this.count == 0 && type != OptionValueType.None) if (this.MaxValueCount == 0 && OptionValueType != OptionValueType.None)
throw new ArgumentException ( throw new ArgumentException (
"Cannot provide maxValueCount of 0 for OptionValueType.Required or " + "Cannot provide maxValueCount of 0 for OptionValueType.Required or " +
"OptionValueType.Optional.", "OptionValueType.Optional.",
"maxValueCount"); "maxValueCount");
if (this.type == OptionValueType.None && maxValueCount > 1) if (this.OptionValueType == OptionValueType.None && maxValueCount > 1)
throw new ArgumentException ( throw new ArgumentException (
string.Format ("Cannot provide maxValueCount of {0} for OptionValueType.None.", maxValueCount), string.Format ("Cannot provide maxValueCount of {0} for OptionValueType.None.", maxValueCount),
"maxValueCount"); "maxValueCount");
if (Array.IndexOf (names, "<>") >= 0 && if (Array.IndexOf (Names, "<>") >= 0 &&
((names.Length == 1 && this.type != OptionValueType.None) || ((Names.Length == 1 && this.OptionValueType != OptionValueType.None) ||
(names.Length > 1 && this.MaxValueCount > 1))) (Names.Length > 1 && this.MaxValueCount > 1)))
throw new ArgumentException ( throw new ArgumentException (
"The default option handler '<>' cannot require values.", "The default option handler '<>' cannot require values.",
"prototype"); "prototype");
} }
public string Prototype {get {return prototype;}} public string Prototype { get; }
public string Description {get {return description;}} public string Description { get; }
public OptionValueType OptionValueType {get {return type;}} public OptionValueType OptionValueType { get; }
public int MaxValueCount {get {return count;}} public int MaxValueCount { get; }
public string[] GetNames () public string[] GetNames ()
{ {
return (string[]) names.Clone (); return (string[]) Names.Clone ();
} }
public string[] GetValueSeparators () public string[] GetValueSeparators ()
{ {
if (separators == null) if (ValueSeparators == null)
return new string [0]; return new string [0];
return (string[]) separators.Clone (); return (string[]) ValueSeparators.Clone ();
} }
protected static T Parse<T> (string value, OptionContext c) protected static T Parse<T> (string value, OptionContext c)
@ -354,8 +329,8 @@ namespace Mono.Options
return t; return t;
} }
internal string[] Names {get {return names;}} internal string[] Names { get; }
internal string[] ValueSeparators {get {return separators;}} internal string[] ValueSeparators { get; private set; }
static readonly char[] NameTerminator = new char[]{'=', ':'}; static readonly char[] NameTerminator = new char[]{'=', ':'};
@ -363,15 +338,15 @@ namespace Mono.Options
{ {
char type = '\0'; char type = '\0';
List<string> seps = new List<string> (); List<string> seps = new List<string> ();
for (int i = 0; i < names.Length; ++i) { for (int i = 0; i < Names.Length; ++i) {
string name = names [i]; string name = Names [i];
if (name.Length == 0) if (name.Length == 0)
throw new ArgumentException ("Empty option names are not supported.", "prototype"); throw new ArgumentException ("Empty option names are not supported.", "prototype");
int end = name.IndexOfAny (NameTerminator); int end = name.IndexOfAny (NameTerminator);
if (end == -1) if (end == -1)
continue; continue;
names [i] = name.Substring (0, end); Names [i] = name.Substring (0, end);
if (type == '\0' || type == name [end]) if (type == '\0' || type == name [end])
type = name [end]; type = name [end];
else else
@ -384,17 +359,17 @@ namespace Mono.Options
if (type == '\0') if (type == '\0')
return OptionValueType.None; return OptionValueType.None;
if (count <= 1 && seps.Count != 0) if (MaxValueCount <= 1 && seps.Count != 0)
throw new ArgumentException ( throw new ArgumentException (
string.Format ("Cannot provide key/value separators for Options taking {0} value(s).", count), string.Format ("Cannot provide key/value separators for Options taking {0} value(s).", MaxValueCount),
"prototype"); "prototype");
if (count > 1) { if (MaxValueCount > 1) {
if (seps.Count == 0) if (seps.Count == 0)
this.separators = new string[]{":", "="}; this.ValueSeparators = new string[]{":", "="};
else if (seps.Count == 1 && seps [0].Length == 0) else if (seps.Count == 1 && seps [0].Length == 0)
this.separators = null; this.ValueSeparators = null;
else else
this.separators = seps.ToArray (); this.ValueSeparators = seps.ToArray ();
} }
return type == '=' ? OptionValueType.Required : OptionValueType.Optional; return type == '=' ? OptionValueType.Required : OptionValueType.Optional;
@ -450,8 +425,6 @@ namespace Mono.Options
[Serializable] [Serializable]
public class OptionException : Exception { public class OptionException : Exception {
private string option;
public OptionException () public OptionException ()
{ {
} }
@ -459,30 +432,28 @@ namespace Mono.Options
public OptionException (string message, string optionName) public OptionException (string message, string optionName)
: base (message) : base (message)
{ {
this.option = optionName; this.OptionName = optionName;
} }
public OptionException (string message, string optionName, Exception innerException) public OptionException (string message, string optionName, Exception innerException)
: base (message, innerException) : base (message, innerException)
{ {
this.option = optionName; this.OptionName = optionName;
} }
protected OptionException (SerializationInfo info, StreamingContext context) protected OptionException (SerializationInfo info, StreamingContext context)
: base (info, context) : base (info, context)
{ {
this.option = info.GetString ("OptionName"); this.OptionName = info.GetString ("OptionName");
} }
public string OptionName { public string OptionName { get; }
get {return this.option;}
}
[SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)] [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
public override void GetObjectData (SerializationInfo info, StreamingContext context) public override void GetObjectData (SerializationInfo info, StreamingContext context)
{ {
base.GetObjectData (info, context); base.GetObjectData (info, context);
info.AddValue ("OptionName", option); info.AddValue ("OptionName", OptionName);
} }
} }
@ -497,14 +468,10 @@ namespace Mono.Options
public OptionSet (Converter<string, string> localizer) public OptionSet (Converter<string, string> localizer)
{ {
this.localizer = localizer; this.MessageLocalizer = localizer;
} }
Converter<string, string> localizer; public Converter<string, string> MessageLocalizer { get; }
public Converter<string, string> MessageLocalizer {
get {return localizer;}
}
protected override string GetKeyForItem (Option item) protected override string GetKeyForItem (Option item)
{ {
@ -812,7 +779,7 @@ namespace Mono.Options
c.Option.OptionValueType == OptionValueType.Optional) c.Option.OptionValueType == OptionValueType.Optional)
c.Option.Invoke (c); c.Option.Invoke (c);
else if (c.OptionValues.Count > c.Option.MaxValueCount) { else if (c.OptionValues.Count > c.Option.MaxValueCount) {
throw new OptionException (localizer (string.Format ( throw new OptionException (MessageLocalizer (string.Format (
"Error: Found {0} option values when expecting {1}.", "Error: Found {0} option values when expecting {1}.",
c.OptionValues.Count, c.Option.MaxValueCount)), c.OptionValues.Count, c.Option.MaxValueCount)),
c.OptionName); c.OptionName);
@ -847,7 +814,7 @@ namespace Mono.Options
if (!Contains (rn)) { if (!Contains (rn)) {
if (i == 0) if (i == 0)
return false; return false;
throw new OptionException (string.Format (localizer ( throw new OptionException (string.Format (MessageLocalizer (
"Cannot bundle unregistered option '{0}'."), opt), opt); "Cannot bundle unregistered option '{0}'."), opt), opt);
} }
p = this [rn]; p = this [rn];
@ -896,7 +863,7 @@ namespace Mono.Options
bool indent = false; bool indent = false;
string prefix = new string (' ', OptionWidth+2); string prefix = new string (' ', OptionWidth+2);
foreach (string line in GetLines (localizer (GetDescription (p.Description)))) { foreach (string line in GetLines (MessageLocalizer (GetDescription (p.Description)))) {
if (indent) if (indent)
o.Write (prefix); o.Write (prefix);
o.WriteLine (line); o.WriteLine (line);
@ -932,17 +899,17 @@ namespace Mono.Options
if (p.OptionValueType == OptionValueType.Optional || if (p.OptionValueType == OptionValueType.Optional ||
p.OptionValueType == OptionValueType.Required) { p.OptionValueType == OptionValueType.Required) {
if (p.OptionValueType == OptionValueType.Optional) { if (p.OptionValueType == OptionValueType.Optional) {
Write (o, ref written, localizer ("[")); Write (o, ref written, MessageLocalizer ("["));
} }
Write (o, ref written, localizer ("=" + GetArgumentName (0, p.MaxValueCount, p.Description))); Write (o, ref written, MessageLocalizer ("=" + GetArgumentName (0, p.MaxValueCount, p.Description)));
string sep = p.ValueSeparators != null && p.ValueSeparators.Length > 0 string sep = p.ValueSeparators != null && p.ValueSeparators.Length > 0
? p.ValueSeparators [0] ? p.ValueSeparators [0]
: " "; : " ";
for (int c = 1; c < p.MaxValueCount; ++c) { for (int c = 1; c < p.MaxValueCount; ++c) {
Write (o, ref written, localizer (sep + GetArgumentName (c, p.MaxValueCount, p.Description))); Write (o, ref written, MessageLocalizer (sep + GetArgumentName (c, p.MaxValueCount, p.Description)));
} }
if (p.OptionValueType == OptionValueType.Optional) { if (p.OptionValueType == OptionValueType.Optional) {
Write (o, ref written, localizer ("]")); Write (o, ref written, MessageLocalizer ("]"));
} }
} }
return true; return true;

View file

@ -45,12 +45,8 @@ namespace OpenTK.Platform.MacOS
/// </summary> /// </summary>
class AglContext : IGraphicsContext, IGraphicsContextInternal class AglContext : IGraphicsContext, IGraphicsContextInternal
{ {
ContextHandle Handle;
GraphicsMode mode;
IWindowInfo carbonWindow; IWindowInfo carbonWindow;
IGraphicsContext dummyContext; // for extension loading IGraphicsContext dummyContext; // for extension loading
bool disposed;
bool error_checking;
readonly GetInt XOffset; readonly GetInt XOffset;
readonly GetInt YOffset; readonly GetInt YOffset;
@ -69,7 +65,7 @@ namespace OpenTK.Platform.MacOS
if (shareContext is AglContext) if (shareContext is AglContext)
{ {
shareContextRef = ((AglContext)shareContext).Handle.Handle; shareContextRef = ((AglContext)shareContext).Context.Handle;
} }
else if (shareContext is GraphicsContext) else if (shareContext is GraphicsContext)
{ {
@ -116,7 +112,7 @@ namespace OpenTK.Platform.MacOS
Debug.Print("Creating AGL context. Sharing with {0}", shareContextRef); Debug.Print("Creating AGL context. Sharing with {0}", shareContextRef);
// create the context and share it with the share reference. // create the context and share it with the share reference.
Handle = new ContextHandle(Agl.aglCreateContext(pixelformat, shareContextRef)); Context = new ContextHandle(Agl.aglCreateContext(pixelformat, shareContextRef));
MyAGLReportError("aglCreateContext"); MyAGLReportError("aglCreateContext");
// Free the pixel format from memory. // Free the pixel format from memory.
@ -128,9 +124,9 @@ namespace OpenTK.Platform.MacOS
Update(carbonWindow); Update(carbonWindow);
MakeCurrent(carbonWindow); MakeCurrent(carbonWindow);
Debug.Print("context: {0}", Handle.Handle); Debug.Print("context: {0}", Context.Handle);
dummyContext = new GraphicsContext(Handle, dummyContext = new GraphicsContext(Context,
GetAddress, GetAddress,
delegate() delegate()
{ {
@ -157,10 +153,10 @@ namespace OpenTK.Platform.MacOS
glrect[2] = rect.Width; glrect[2] = rect.Width;
glrect[3] = rect.Height; glrect[3] = rect.Height;
Agl.aglSetInteger(Handle.Handle, Agl.ParameterNames.AGL_BUFFER_RECT, glrect); Agl.aglSetInteger(Context.Handle, Agl.ParameterNames.AGL_BUFFER_RECT, glrect);
MyAGLReportError("aglSetInteger"); MyAGLReportError("aglSetInteger");
Agl.aglEnable(Handle.Handle, Agl.ParameterNames.AGL_BUFFER_RECT); Agl.aglEnable(Context.Handle, Agl.ParameterNames.AGL_BUFFER_RECT);
MyAGLReportError("aglEnable"); MyAGLReportError("aglEnable");
} }
@ -168,7 +164,7 @@ namespace OpenTK.Platform.MacOS
{ {
IntPtr windowPort = GetWindowPortForWindowInfo(carbonWindow); IntPtr windowPort = GetWindowPortForWindowInfo(carbonWindow);
//Debug.Print("Setting drawable for context {0} to window port: {1}", Handle.Handle, windowPort); //Debug.Print("Setting drawable for context {0} to window port: {1}", Handle.Handle, windowPort);
Agl.aglSetDrawable(Handle.Handle, windowPort); Agl.aglSetDrawable(Context.Handle, windowPort);
MyAGLReportError("aglSetDrawable"); MyAGLReportError("aglSetDrawable");
} }
@ -186,7 +182,7 @@ namespace OpenTK.Platform.MacOS
SetDrawable(window); SetDrawable(window);
SetBufferRect(window); SetBufferRect(window);
Agl.aglUpdateContext(Handle.Handle); Agl.aglUpdateContext(Context.Handle);
} }
void MyAGLReportError(string function) void MyAGLReportError(string function)
@ -212,19 +208,19 @@ namespace OpenTK.Platform.MacOS
Update(carbonWindow); Update(carbonWindow);
} }
Agl.aglSwapBuffers(Handle.Handle); Agl.aglSwapBuffers(Context.Handle);
MyAGLReportError("aglSwapBuffers"); MyAGLReportError("aglSwapBuffers");
} }
public void MakeCurrent(IWindowInfo window) public void MakeCurrent(IWindowInfo window)
{ {
if (Agl.aglSetCurrentContext(Handle.Handle) == false) if (Agl.aglSetCurrentContext(Context.Handle) == false)
MyAGLReportError("aglSetCurrentContext"); MyAGLReportError("aglSetCurrentContext");
} }
public bool IsCurrent public bool IsCurrent
{ {
get { return (Handle.Handle == Agl.aglGetCurrentContext()); } get { return (Context.Handle == Agl.aglGetCurrentContext()); }
} }
public int SwapInterval public int SwapInterval
@ -232,7 +228,7 @@ namespace OpenTK.Platform.MacOS
get get
{ {
int swap_interval = 0; int swap_interval = 0;
if (Agl.aglGetInteger(Handle.Handle, Agl.ParameterNames.AGL_SWAP_INTERVAL, out swap_interval)) if (Agl.aglGetInteger(Context.Handle, Agl.ParameterNames.AGL_SWAP_INTERVAL, out swap_interval))
{ {
return swap_interval; return swap_interval;
} }
@ -244,36 +240,19 @@ namespace OpenTK.Platform.MacOS
} }
set set
{ {
if (!Agl.aglSetInteger(Handle.Handle, Agl.ParameterNames.AGL_SWAP_INTERVAL, ref value)) if (!Agl.aglSetInteger(Context.Handle, Agl.ParameterNames.AGL_SWAP_INTERVAL, ref value))
MyAGLReportError("aglSetInteger"); MyAGLReportError("aglSetInteger");
} }
} }
public GraphicsMode Mode public GraphicsMode Mode { get; set; }
{
get
{
return mode;
}
set
{
mode = value;
}
}
public void LoadAll() public void LoadAll()
{ {
dummyContext.LoadAll(); dummyContext.LoadAll();
} }
public bool IsDisposed public bool IsDisposed { get; private set; }
{
get
{
return disposed;
}
}
public bool VSync public bool VSync
{ {
@ -291,21 +270,11 @@ namespace OpenTK.Platform.MacOS
{ {
get get
{ {
return mode; return Mode;
} }
} }
public bool ErrorChecking public bool ErrorChecking { get; set; }
{
get
{
return error_checking;
}
set
{
error_checking = value;
}
}
~AglContext() ~AglContext()
{ {
@ -319,7 +288,7 @@ namespace OpenTK.Platform.MacOS
void Dispose(bool disposing) void Dispose(bool disposing)
{ {
if (IsDisposed || Handle.Handle == IntPtr.Zero) if (IsDisposed || Context.Handle == IntPtr.Zero)
return; return;
Debug.Print("Disposing of AGL context."); Debug.Print("Disposing of AGL context.");
@ -335,10 +304,10 @@ namespace OpenTK.Platform.MacOS
// Actually, it seems to crash the mono runtime. -AMK 2013 // Actually, it seems to crash the mono runtime. -AMK 2013
Debug.Print("Destroying context"); Debug.Print("Destroying context");
if (Agl.aglDestroyContext(Handle.Handle) == true) if (Agl.aglDestroyContext(Context.Handle) == true)
{ {
Debug.Print("Context destruction completed successfully."); Debug.Print("Context destruction completed successfully.");
Handle = ContextHandle.Zero; Context = ContextHandle.Zero;
return; return;
} }
@ -352,7 +321,7 @@ namespace OpenTK.Platform.MacOS
throw new Exception(Agl.ErrorString(Agl.GetError())); throw new Exception(Agl.ErrorString(Agl.GetError()));
} }
disposed = true; IsDisposed = true;
} }
public IntPtr GetAddress(string function) public IntPtr GetAddress(string function)
@ -373,12 +342,6 @@ namespace OpenTK.Platform.MacOS
} }
} }
public ContextHandle Context public ContextHandle Context { get; private set; }
{
get
{
return Handle;
}
}
} }
} }

View file

@ -38,14 +38,13 @@ namespace OpenTK
{ {
GraphicsMode mode; GraphicsMode mode;
Control control; Control control;
IWindowInfo window_info;
internal CarbonGLControl(GraphicsMode mode, Control owner) internal CarbonGLControl(GraphicsMode mode, Control owner)
{ {
this.mode = mode; this.mode = mode;
this.control = owner; this.control = owner;
window_info = Utilities.CreateMacOSCarbonWindowInfo(control.Handle, false, true); WindowInfo = Utilities.CreateMacOSCarbonWindowInfo(control.Handle, false, true);
} }
private int GetXOffset() private int GetXOffset()
@ -82,12 +81,6 @@ namespace OpenTK
} }
} }
public IWindowInfo WindowInfo public IWindowInfo WindowInfo { get; }
{
get
{
return window_info;
}
}
} }
} }

View file

@ -50,12 +50,7 @@ namespace OpenTK
{ {
static int instance_count; static int instance_count;
readonly ContextHandle handle = new ContextHandle(new IntPtr(
System.Threading.Interlocked.Increment(ref instance_count)));
IWindowInfo current_window; IWindowInfo current_window;
bool is_disposed;
int swap_interval;
public void SwapBuffers() public void SwapBuffers()
{ {
@ -71,10 +66,7 @@ namespace OpenTK
get { return current_window != null; } get { return current_window != null; }
} }
public bool IsDisposed public bool IsDisposed { get; private set; }
{
get { return is_disposed; }
}
public bool VSync public bool VSync
{ {
@ -88,17 +80,7 @@ namespace OpenTK
} }
} }
public int SwapInterval public int SwapInterval { get; set; }
{
get
{
return swap_interval;
}
set
{
swap_interval = value;
}
}
public void Update(IWindowInfo window) public void Update(IWindowInfo window)
{ {
@ -126,13 +108,11 @@ namespace OpenTK
public void Dispose() public void Dispose()
{ {
is_disposed = true; IsDisposed = true;
} }
public ContextHandle Context public ContextHandle Context { get; } = new ContextHandle(new IntPtr(
{ System.Threading.Interlocked.Increment(ref instance_count)));
get { return handle; }
}
public IntPtr GetAddress(IntPtr function) public IntPtr GetAddress(IntPtr function)
{ {

View file

@ -35,13 +35,12 @@ namespace OpenTK
{ {
class Sdl2GLControl : IGLControl class Sdl2GLControl : IGLControl
{ {
IWindowInfo window_info;
GraphicsMode mode; GraphicsMode mode;
public Sdl2GLControl(GraphicsMode mode, Control control) public Sdl2GLControl(GraphicsMode mode, Control control)
{ {
this.mode = mode; this.mode = mode;
window_info = Utilities.CreateSdl2WindowInfo(control.Handle); WindowInfo = Utilities.CreateSdl2WindowInfo(control.Handle);
// Fixme: SDL2 will refuse to create an OpenGL context on // Fixme: SDL2 will refuse to create an OpenGL context on
// a window with the SDL_WINDOW_FOREIGN flag (i.e. windows // a window with the SDL_WINDOW_FOREIGN flag (i.e. windows
// that are passed to SDL2 through SDL_CreateWindowFrom). // that are passed to SDL2 through SDL_CreateWindowFrom).
@ -50,7 +49,7 @@ namespace OpenTK
public Graphics.IGraphicsContext CreateContext(int major, int minor, Graphics.GraphicsContextFlags flags) public Graphics.IGraphicsContext CreateContext(int major, int minor, Graphics.GraphicsContextFlags flags)
{ {
return new GraphicsContext(mode, window_info, major, minor, flags); return new GraphicsContext(mode, WindowInfo, major, minor, flags);
} }
public bool IsIdle public bool IsIdle
@ -58,10 +57,7 @@ namespace OpenTK
get { return NativeMethods.SDL_HasEvents(0, 0xffff); } get { return NativeMethods.SDL_HasEvents(0, 0xffff); }
} }
public Platform.IWindowInfo WindowInfo public Platform.IWindowInfo WindowInfo { get; }
{
get { return window_info; }
}
static class NativeMethods static class NativeMethods
{ {

View file

@ -78,19 +78,18 @@ namespace OpenTK
static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags); static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
MSG msg = new MSG(); MSG msg = new MSG();
IWindowInfo window_info;
GraphicsMode mode; GraphicsMode mode;
public WinGLControl(GraphicsMode mode, Control control) public WinGLControl(GraphicsMode mode, Control control)
{ {
this.mode = mode; this.mode = mode;
window_info = Utilities.CreateWindowsWindowInfo(control.Handle); WindowInfo = Utilities.CreateWindowsWindowInfo(control.Handle);
} }
public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags) public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
{ {
return new GraphicsContext(mode, window_info, major, minor, flags); return new GraphicsContext(mode, WindowInfo, major, minor, flags);
} }
public bool IsIdle public bool IsIdle
@ -98,13 +97,6 @@ namespace OpenTK
get { return !PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); } get { return !PeekMessage(ref msg, IntPtr.Zero, 0, 0, 0); }
} }
public IWindowInfo WindowInfo public IWindowInfo WindowInfo { get; }
{
get
{
// This method forces the creation of the control. Beware of this side-effect!
return window_info;
}
}
} }
} }

View file

@ -53,7 +53,6 @@ namespace OpenTK
} }
GraphicsMode mode; GraphicsMode mode;
IWindowInfo window_info;
IntPtr display; IntPtr display;
IntPtr rootWindow; IntPtr rootWindow;
@ -92,7 +91,7 @@ namespace OpenTK
rootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow"); rootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
int screen = (int)GetStaticFieldValue(xplatui, "ScreenNo"); int screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
window_info = Utilities.CreateX11WindowInfo(display, screen, control.Handle, rootWindow, IntPtr.Zero); WindowInfo = Utilities.CreateX11WindowInfo(display, screen, control.Handle, rootWindow, IntPtr.Zero);
} }
public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags) public IGraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
@ -121,13 +120,7 @@ namespace OpenTK
get { return XPending(display) == 0; } get { return XPending(display) == 0; }
} }
public IWindowInfo WindowInfo public IWindowInfo WindowInfo { get; }
{
get
{
return window_info;
}
}
static object GetStaticFieldValue(Type type, string fieldName) static object GetStaticFieldValue(Type type, string fieldName)
{ {

View file

@ -24,7 +24,6 @@ namespace OpenTK
private IGraphicsContext _GraphicsContext; private IGraphicsContext _GraphicsContext;
private IWindowInfo _WindowInfo; private IWindowInfo _WindowInfo;
private GraphicsContextFlags _GraphicsContextFlags;
private bool _Initialized = false; private bool _Initialized = false;
/// <summary> /// <summary>
@ -76,17 +75,7 @@ namespace OpenTK
/// <summary> /// <summary>
/// The set <see cref="GraphicsContextFlags"/> for this widget. /// The set <see cref="GraphicsContextFlags"/> for this widget.
/// </summary> /// </summary>
public GraphicsContextFlags GraphicsContextFlags public GraphicsContextFlags GraphicsContextFlags { get; set; }
{
get
{
return _GraphicsContextFlags;
}
set
{
_GraphicsContextFlags = value;
}
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GLWidget"/> class. /// Initializes a new instance of the <see cref="GLWidget"/> class.
@ -364,7 +353,7 @@ namespace OpenTK
_WindowInfo = XWindowInfoInitializer.Initialize(graphicsMode, this.Display.Handle, this.Screen.Number, widgetWindowHandle, this.Screen.RootWindow.Handle); _WindowInfo = XWindowInfoInitializer.Initialize(graphicsMode, this.Display.Handle, this.Screen.Number, widgetWindowHandle, this.Screen.RootWindow.Handle);
// GraphicsContext // GraphicsContext
_GraphicsContext = new GraphicsContext(graphicsMode, _WindowInfo, GlVersionMajor, GlVersionMinor, _GraphicsContextFlags); _GraphicsContext = new GraphicsContext(graphicsMode, _WindowInfo, GlVersionMajor, GlVersionMinor, GraphicsContextFlags);
_GraphicsContext.MakeCurrent(_WindowInfo); _GraphicsContext.MakeCurrent(_WindowInfo);
if (GraphicsContext.ShareContexts) if (GraphicsContext.ShareContexts)

View file

@ -43,10 +43,6 @@ namespace OpenTK.Audio
IntPtr Handle; IntPtr Handle;
// Alc.CaptureStop should be called prior to device shutdown, this keeps track of Alc.CaptureStart/Stop calls. // Alc.CaptureStop should be called prior to device shutdown, this keeps track of Alc.CaptureStart/Stop calls.
bool _isrecording = false;
ALFormat sample_format;
int sample_frequency;
static AudioCapture() static AudioCapture()
@ -80,20 +76,20 @@ namespace OpenTK.Audio
throw new ArgumentOutOfRangeException("bufferSize"); throw new ArgumentOutOfRangeException("bufferSize");
// Try to open specified device. If it fails, try to open default device. // Try to open specified device. If it fails, try to open default device.
device_name = deviceName; CurrentDevice = deviceName;
Handle = Alc.CaptureOpenDevice(deviceName, frequency, sampleFormat, bufferSize); Handle = Alc.CaptureOpenDevice(deviceName, frequency, sampleFormat, bufferSize);
if (Handle == IntPtr.Zero) if (Handle == IntPtr.Zero)
{ {
Debug.WriteLine(ErrorMessage(deviceName, frequency, sampleFormat, bufferSize)); Debug.WriteLine(ErrorMessage(deviceName, frequency, sampleFormat, bufferSize));
device_name = "IntPtr.Zero"; CurrentDevice = "IntPtr.Zero";
Handle = Alc.CaptureOpenDevice(null, frequency, sampleFormat, bufferSize); Handle = Alc.CaptureOpenDevice(null, frequency, sampleFormat, bufferSize);
} }
if (Handle == IntPtr.Zero) if (Handle == IntPtr.Zero)
{ {
Debug.WriteLine(ErrorMessage("IntPtr.Zero", frequency, sampleFormat, bufferSize)); Debug.WriteLine(ErrorMessage("IntPtr.Zero", frequency, sampleFormat, bufferSize));
device_name = AudioDeviceEnumerator.DefaultRecordingDevice; CurrentDevice = AudioDeviceEnumerator.DefaultRecordingDevice;
Handle = Alc.CaptureOpenDevice(AudioDeviceEnumerator.DefaultRecordingDevice, frequency, sampleFormat, bufferSize); Handle = Alc.CaptureOpenDevice(AudioDeviceEnumerator.DefaultRecordingDevice, frequency, sampleFormat, bufferSize);
} }
@ -101,7 +97,7 @@ namespace OpenTK.Audio
{ {
// Everything we tried failed. Capture may not be supported, bail out. // Everything we tried failed. Capture may not be supported, bail out.
Debug.WriteLine(ErrorMessage(AudioDeviceEnumerator.DefaultRecordingDevice, frequency, sampleFormat, bufferSize)); Debug.WriteLine(ErrorMessage(AudioDeviceEnumerator.DefaultRecordingDevice, frequency, sampleFormat, bufferSize));
device_name = "None"; CurrentDevice = "None";
throw new AudioDeviceException("All attempts to open capture devices returned IntPtr.Zero. See debug log for verbose list."); throw new AudioDeviceException("All attempts to open capture devices returned IntPtr.Zero. See debug log for verbose list.");
} }
@ -113,18 +109,10 @@ namespace OpenTK.Audio
SampleFrequency = frequency; SampleFrequency = frequency;
} }
private string device_name;
/// <summary> /// <summary>
/// The name of the device associated with this instance. /// The name of the device associated with this instance.
/// </summary> /// </summary>
public string CurrentDevice public string CurrentDevice { get; }
{
get
{
return device_name;
}
}
/// <summary> /// <summary>
/// Returns a list of strings containing all known recording devices. /// Returns a list of strings containing all known recording devices.
@ -177,14 +165,14 @@ namespace OpenTK.Audio
public void Start() public void Start()
{ {
Alc.CaptureStart(Handle); Alc.CaptureStart(Handle);
_isrecording = true; IsRunning = true;
} }
/// <summary>Stop recording samples. This will not clear previously recorded samples.</summary> /// <summary>Stop recording samples. This will not clear previously recorded samples.</summary>
public void Stop() public void Stop()
{ {
Alc.CaptureStop(Handle); Alc.CaptureStop(Handle);
_isrecording = false; IsRunning = false;
} }
/// <summary>Returns the number of available samples for capture.</summary> /// <summary>Returns the number of available samples for capture.</summary>
@ -236,28 +224,17 @@ namespace OpenTK.Audio
/// <summary> /// <summary>
/// Gets the OpenTK.Audio.ALFormat for this instance. /// Gets the OpenTK.Audio.ALFormat for this instance.
/// </summary> /// </summary>
public ALFormat SampleFormat public ALFormat SampleFormat { get; private set; }
{
get { return sample_format; }
private set { sample_format = value; }
}
/// <summary> /// <summary>
/// Gets the sampling rate for this instance. /// Gets the sampling rate for this instance.
/// </summary> /// </summary>
public int SampleFrequency public int SampleFrequency { get; private set; }
{
get { return sample_frequency; }
private set { sample_frequency = value; }
}
/// <summary> /// <summary>
/// Gets a value indicating whether this instance is currently capturing samples. /// Gets a value indicating whether this instance is currently capturing samples.
/// </summary> /// </summary>
public bool IsRunning public bool IsRunning { get; private set; } = false;
{
get { return _isrecording; }
}
// Retrieves the sample size in bytes for various ALFormats. // Retrieves the sample size in bytes for various ALFormats.
// Compressed formats always return 1. // Compressed formats always return 1.
@ -342,7 +319,7 @@ namespace OpenTK.Audio
{ {
if (this.Handle != IntPtr.Zero) if (this.Handle != IntPtr.Zero)
{ {
if (this._isrecording) if (this.IsRunning)
this.Stop(); this.Stop();
Alc.CaptureCloseDevice(this.Handle); Alc.CaptureCloseDevice(this.Handle);

View file

@ -41,7 +41,6 @@ namespace OpenTK.Audio
{ {
bool disposed; bool disposed;
bool is_processing, is_synchronized; bool is_processing, is_synchronized;
IntPtr device_handle;
ContextHandle context_handle; ContextHandle context_handle;
bool context_exists; bool context_exists;
@ -218,19 +217,19 @@ namespace OpenTK.Audio
if (!String.IsNullOrEmpty(device)) if (!String.IsNullOrEmpty(device))
{ {
device_name = device; device_name = device;
device_handle = Alc.OpenDevice(device); // try to open device by name Device = Alc.OpenDevice(device); // try to open device by name
} }
if (device_handle == IntPtr.Zero) if (Device == IntPtr.Zero)
{ {
device_name = "IntPtr.Zero (null string)"; device_name = "IntPtr.Zero (null string)";
device_handle = Alc.OpenDevice(null); // try to open unnamed default device Device = Alc.OpenDevice(null); // try to open unnamed default device
} }
if (device_handle == IntPtr.Zero) if (Device == IntPtr.Zero)
{ {
device_name = AudioContext.DefaultDevice; device_name = AudioContext.DefaultDevice;
device_handle = Alc.OpenDevice(AudioContext.DefaultDevice); // try to open named default device Device = Alc.OpenDevice(AudioContext.DefaultDevice); // try to open named default device
} }
if (device_handle == IntPtr.Zero) if (Device == IntPtr.Zero)
{ {
device_name = "None"; device_name = "None";
throw new AudioDeviceException(String.Format("Audio device '{0}' does not exist or is tied up by another application.", throw new AudioDeviceException(String.Format("Audio device '{0}' does not exist or is tied up by another application.",
@ -257,7 +256,7 @@ namespace OpenTK.Audio
attributes.Add((int)AlcContextAttributes.Sync); attributes.Add((int)AlcContextAttributes.Sync);
attributes.Add(sync ? 1 : 0); attributes.Add(sync ? 1 : 0);
if (enableEfx && Alc.IsExtensionPresent(device_handle, "ALC_EXT_EFX")) if (enableEfx && Alc.IsExtensionPresent(Device, "ALC_EXT_EFX"))
{ {
int num_slots; int num_slots;
switch (efxAuxiliarySends) switch (efxAuxiliarySends)
@ -270,7 +269,7 @@ namespace OpenTK.Audio
break; break;
default: default:
case MaxAuxiliarySends.UseDriverDefault: case MaxAuxiliarySends.UseDriverDefault:
Alc.GetInteger(device_handle, AlcGetInteger.EfxMaxAuxiliarySends, 1, out num_slots); Alc.GetInteger(Device, AlcGetInteger.EfxMaxAuxiliarySends, 1, out num_slots);
break; break;
} }
@ -279,11 +278,11 @@ namespace OpenTK.Audio
} }
attributes.Add(0); attributes.Add(0);
context_handle = Alc.CreateContext(device_handle, attributes.ToArray()); context_handle = Alc.CreateContext(Device, attributes.ToArray());
if (context_handle == ContextHandle.Zero) if (context_handle == ContextHandle.Zero)
{ {
Alc.CloseDevice(device_handle); Alc.CloseDevice(Device);
throw new AudioContextException("The audio context could not be created with the specified parameters."); throw new AudioContextException("The audio context could not be created with the specified parameters.");
} }
@ -297,7 +296,7 @@ namespace OpenTK.Audio
CheckErrors(); CheckErrors();
device_name = Alc.GetString(device_handle, AlcGetString.DeviceSpecifier); device_name = Alc.GetString(Device, AlcGetString.DeviceSpecifier);
lock (audio_context_lock) lock (audio_context_lock)
@ -356,7 +355,7 @@ namespace OpenTK.Audio
} }
} }
IntPtr Device { get { return device_handle; } } private IntPtr Device { get; set; }
/// <summary> /// <summary>
/// Checks for ALC error conditions. /// Checks for ALC error conditions.
@ -370,7 +369,7 @@ namespace OpenTK.Audio
if (disposed) if (disposed)
throw new ObjectDisposedException(this.GetType().FullName); throw new ObjectDisposedException(this.GetType().FullName);
new AudioDeviceErrorChecker(device_handle).Dispose(); new AudioDeviceErrorChecker(Device).Dispose();
} }
/// <summary> /// <summary>
@ -383,7 +382,7 @@ namespace OpenTK.Audio
if (disposed) if (disposed)
throw new ObjectDisposedException(this.GetType().FullName); throw new ObjectDisposedException(this.GetType().FullName);
return Alc.GetError(device_handle); return Alc.GetError(Device);
} }
} }
@ -594,8 +593,8 @@ namespace OpenTK.Audio
Alc.DestroyContext(context_handle); Alc.DestroyContext(context_handle);
} }
if (device_handle != IntPtr.Zero) if (Device != IntPtr.Zero)
Alc.CloseDevice(device_handle); Alc.CloseDevice(Device);
if (manual) if (manual)
{ {
@ -638,7 +637,7 @@ namespace OpenTK.Audio
public override string ToString() public override string ToString()
{ {
return String.Format("{0} (handle: {1}, device: {2})", return String.Format("{0} (handle: {1}, device: {2})",
this.device_name, this.context_handle, this.device_handle); this.device_name, this.context_handle, this.Device);
} }
} }
} }

View file

@ -52,32 +52,11 @@ namespace OpenTK.Audio
} }
} }
private static string default_playback_device; internal static string DefaultPlaybackDevice { get; }
internal static string DefaultPlaybackDevice
{
get
{
return default_playback_device;
}
}
private static string default_recording_device; internal static string DefaultRecordingDevice { get; }
internal static string DefaultRecordingDevice
{
get
{
return default_recording_device;
}
}
private static bool openal_supported = true; internal static bool IsOpenALSupported { get; } = true;
internal static bool IsOpenALSupported
{
get
{
return openal_supported;
}
}
internal enum AlcVersion internal enum AlcVersion
{ {
@ -85,14 +64,7 @@ namespace OpenTK.Audio
Alc1_1 Alc1_1
} }
private static AlcVersion version; internal static AlcVersion Version { get; }
internal static AlcVersion Version
{
get
{
return version;
}
}
// Loads all available audio devices into the available_*_devices lists. // Loads all available audio devices into the available_*_devices lists.
static AudioDeviceEnumerator() static AudioDeviceEnumerator()
@ -121,21 +93,21 @@ namespace OpenTK.Audio
// Get a list of all known playback devices, using best extension available // Get a list of all known playback devices, using best extension available
if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT")) if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT"))
{ {
version = AlcVersion.Alc1_1; Version = AlcVersion.Alc1_1;
if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATE_ALL_EXT")) if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATE_ALL_EXT"))
{ {
available_playback_devices.AddRange(Alc.GetString(IntPtr.Zero, AlcGetStringList.AllDevicesSpecifier)); available_playback_devices.AddRange(Alc.GetString(IntPtr.Zero, AlcGetStringList.AllDevicesSpecifier));
default_playback_device = Alc.GetString(IntPtr.Zero, AlcGetString.DefaultAllDevicesSpecifier); DefaultPlaybackDevice = Alc.GetString(IntPtr.Zero, AlcGetString.DefaultAllDevicesSpecifier);
} }
else else
{ {
available_playback_devices.AddRange(Alc.GetString(IntPtr.Zero, AlcGetStringList.DeviceSpecifier)); available_playback_devices.AddRange(Alc.GetString(IntPtr.Zero, AlcGetStringList.DeviceSpecifier));
default_playback_device = Alc.GetString(IntPtr.Zero, AlcGetString.DefaultDeviceSpecifier); DefaultPlaybackDevice = Alc.GetString(IntPtr.Zero, AlcGetString.DefaultDeviceSpecifier);
} }
} }
else else
{ {
version = AlcVersion.Alc1_0; Version = AlcVersion.Alc1_0;
Debug.Print("Device enumeration extension not available. Failed to enumerate playback devices."); Debug.Print("Device enumeration extension not available. Failed to enumerate playback devices.");
} }
AlcError playback_err = Alc.GetError(dummy_device); AlcError playback_err = Alc.GetError(dummy_device);
@ -143,10 +115,10 @@ namespace OpenTK.Audio
throw new AudioContextException("Alc Error occured when querying available playback devices. " + playback_err.ToString()); throw new AudioContextException("Alc Error occured when querying available playback devices. " + playback_err.ToString());
// Get a list of all known recording devices, at least ALC_ENUMERATION_EXT is needed too // Get a list of all known recording devices, at least ALC_ENUMERATION_EXT is needed too
if (version == AlcVersion.Alc1_1 && Alc.IsExtensionPresent(IntPtr.Zero, "ALC_EXT_CAPTURE")) if (Version == AlcVersion.Alc1_1 && Alc.IsExtensionPresent(IntPtr.Zero, "ALC_EXT_CAPTURE"))
{ {
available_recording_devices.AddRange(Alc.GetString(IntPtr.Zero, AlcGetStringList.CaptureDeviceSpecifier)); available_recording_devices.AddRange(Alc.GetString(IntPtr.Zero, AlcGetStringList.CaptureDeviceSpecifier));
default_recording_device = Alc.GetString(IntPtr.Zero, AlcGetString.CaptureDefaultDeviceSpecifier); DefaultRecordingDevice = Alc.GetString(IntPtr.Zero, AlcGetString.CaptureDefaultDeviceSpecifier);
} }
else else
{ {
@ -161,30 +133,30 @@ namespace OpenTK.Audio
foreach (string s in available_playback_devices) foreach (string s in available_playback_devices)
Debug.WriteLine(s); Debug.WriteLine(s);
Debug.WriteLine("Default playback device: " + default_playback_device); Debug.WriteLine("Default playback device: " + DefaultPlaybackDevice);
Debug.WriteLine("Found recording devices:"); Debug.WriteLine("Found recording devices:");
foreach (string s in available_recording_devices) foreach (string s in available_recording_devices)
Debug.WriteLine(s); Debug.WriteLine(s);
Debug.WriteLine("Default recording device: " + default_recording_device); Debug.WriteLine("Default recording device: " + DefaultRecordingDevice);
#endif #endif
} }
catch (DllNotFoundException e) catch (DllNotFoundException e)
{ {
Trace.WriteLine(e.ToString()); Trace.WriteLine(e.ToString());
openal_supported = false; IsOpenALSupported = false;
} }
catch (AudioContextException ace) catch (AudioContextException ace)
{ {
Trace.WriteLine(ace.ToString()); Trace.WriteLine(ace.ToString());
openal_supported = false; IsOpenALSupported = false;
} }
finally finally
{ {
Debug.Unindent(); Debug.Unindent();
if (openal_supported) if (IsOpenALSupported)
{ {
try try
{ {
@ -197,7 +169,7 @@ namespace OpenTK.Audio
} }
catch catch
{ {
openal_supported = false; IsOpenALSupported = false;
} }
} }
} }

View file

@ -1070,23 +1070,15 @@ namespace OpenTK.Audio.OpenAL
// typedef void (__cdecl *LPALGETAUXILIARYEFFECTSLOTIV)( ALuint asid, ALenum pname, ALint* values ); // typedef void (__cdecl *LPALGETAUXILIARYEFFECTSLOTIV)( ALuint asid, ALenum pname, ALint* values );
// typedef void (__cdecl *LPALGETAUXILIARYEFFECTSLOTFV)( ALuint asid, ALenum pname, ALfloat* values ); // typedef void (__cdecl *LPALGETAUXILIARYEFFECTSLOTFV)( ALuint asid, ALenum pname, ALfloat* values );
private bool _valid;
/// <summary>Returns True if the EFX Extension has been found and could be initialized.</summary> /// <summary>Returns True if the EFX Extension has been found and could be initialized.</summary>
public bool IsInitialized public bool IsInitialized { get; }
{
get
{
return _valid;
}
}
/// <summary> /// <summary>
/// Constructs a new EffectsExtension instance. /// Constructs a new EffectsExtension instance.
/// </summary> /// </summary>
public EffectsExtension() public EffectsExtension()
{ {
_valid = false; IsInitialized = false;
if (AudioContext.CurrentContext == null) if (AudioContext.CurrentContext == null)
throw new InvalidOperationException("AL.LoadAll() needs a current AudioContext."); throw new InvalidOperationException("AL.LoadAll() needs a current AudioContext.");
@ -1152,7 +1144,7 @@ namespace OpenTK.Audio.OpenAL
// Console.WriteLine("Auxiliary Effect Slot functions appear to be ok."); // Console.WriteLine("Auxiliary Effect Slot functions appear to be ok.");
// didn't return so far, everything went fine. // didn't return so far, everything went fine.
_valid = true; IsInitialized = true;
} }
} }
} }

View file

@ -19,13 +19,8 @@ namespace OpenTK.Audio.OpenAL
[CLSCompliant(true)] [CLSCompliant(true)]
public sealed class XRamExtension public sealed class XRamExtension
{ {
private bool _valid = false;
/// <summary>Returns True if the X-Ram Extension has been found and could be initialized.</summary> /// <summary>Returns True if the X-Ram Extension has been found and could be initialized.</summary>
public bool IsInitialized public bool IsInitialized { get; } = false;
{
get { return _valid; }
}
// [CLSCompliant(false)] // [CLSCompliant(false)]
private delegate bool Delegate_SetBufferMode(int n, ref uint buffers, int value); private delegate bool Delegate_SetBufferMode(int n, ref uint buffers, int value);
@ -48,7 +43,7 @@ namespace OpenTK.Audio.OpenAL
/// </summary> /// </summary>
public XRamExtension() public XRamExtension()
{ // Query if Extension supported and retrieve Tokens/Pointers if it is. { // Query if Extension supported and retrieve Tokens/Pointers if it is.
_valid = false; IsInitialized = false;
if (AL.IsExtensionPresent("EAX-RAM") == false) if (AL.IsExtensionPresent("EAX-RAM") == false)
return; return;
@ -83,7 +78,7 @@ namespace OpenTK.Audio.OpenAL
return; return;
} }
_valid = true; IsInitialized = true;
} }
/// <summary>Query total amount of X-RAM in bytes.</summary> /// <summary>Query total amount of X-RAM in bytes.</summary>

View file

@ -37,8 +37,6 @@ namespace OpenTK
/// </summary> /// </summary>
public abstract class BindingsBase public abstract class BindingsBase
{ {
bool rebuildExtensionList = true;
/// <summary> /// <summary>
/// Constructs a new BindingsBase instance. /// Constructs a new BindingsBase instance.
/// </summary> /// </summary>
@ -49,11 +47,7 @@ namespace OpenTK
/// <summary> /// <summary>
/// Gets or sets a <see cref="System.Boolean"/> that indicates whether the list of supported extensions may have changed. /// Gets or sets a <see cref="System.Boolean"/> that indicates whether the list of supported extensions may have changed.
/// </summary> /// </summary>
protected bool RebuildExtensionList protected bool RebuildExtensionList { get; set; } = true;
{
get { return rebuildExtensionList; }
set { rebuildExtensionList = value; }
}
/// <summary> /// <summary>
/// Retrieves an unmanaged function pointer to the specified function. /// Retrieves an unmanaged function pointer to the specified function.

View file

@ -42,7 +42,6 @@ namespace OpenTK
public static class BlittableValueType<T> public static class BlittableValueType<T>
{ {
static readonly Type Type; static readonly Type Type;
static readonly int stride;
static BlittableValueType() static BlittableValueType()
{ {
@ -52,7 +51,7 @@ namespace OpenTK
// Does this support generic types? On Mono 2.4.3 it does // Does this support generic types? On Mono 2.4.3 it does
// On .Net it doesn't. // On .Net it doesn't.
// http://msdn.microsoft.com/en-us/library/5s4920fa.aspx // http://msdn.microsoft.com/en-us/library/5s4920fa.aspx
stride = Marshal.SizeOf(typeof(T)); Stride = Marshal.SizeOf(typeof(T));
} }
} }
@ -62,7 +61,7 @@ namespace OpenTK
/// <remarks> /// <remarks>
/// This property returns 0 for non-blittable types. /// This property returns 0 for non-blittable types.
/// </remarks> /// </remarks>
public static int Stride { get { return stride; } } public static int Stride { get; }
/// <summary> /// <summary>
/// Checks whether the current typename T is blittable. /// Checks whether the current typename T is blittable.

View file

@ -40,21 +40,17 @@ namespace OpenTK
/// </summary> /// </summary>
public sealed class Configuration public sealed class Configuration
{ {
static bool runningOnWindows, runningOnUnix, runningOnX11, runningOnMacOS, runningOnLinux; static bool runningOnUnix, runningOnMacOS, runningOnLinux;
static bool runningOnMono;
volatile static bool initialized; volatile static bool initialized;
readonly static object InitLock = new object(); readonly static object InitLock = new object();
Configuration() { } Configuration() { }
/// <summary>Gets a System.Boolean indicating whether OpenTK is running on a Windows platform.</summary> /// <summary>Gets a System.Boolean indicating whether OpenTK is running on a Windows platform.</summary>
public static bool RunningOnWindows { get { return runningOnWindows; } } public static bool RunningOnWindows { get; private set; }
/// <summary>Gets a System.Boolean indicating whether OpenTK is running on an X11 platform.</summary> /// <summary>Gets a System.Boolean indicating whether OpenTK is running on an X11 platform.</summary>
public static bool RunningOnX11 public static bool RunningOnX11 { get; private set; }
{
get { return runningOnX11; }
}
/// <summary> /// <summary>
/// Gets a <see cref="System.Boolean"/> indicating whether OpenTK is running on a Unix platform. /// Gets a <see cref="System.Boolean"/> indicating whether OpenTK is running on a Unix platform.
@ -82,7 +78,7 @@ namespace OpenTK
/// <summary> /// <summary>
/// Gets a System.Boolean indicating whether OpenTK is running on the Mono runtime. /// Gets a System.Boolean indicating whether OpenTK is running on the Mono runtime.
/// </summary> /// </summary>
public static bool RunningOnMono { get { return runningOnMono; } } public static bool RunningOnMono { get; private set; }
/// <summary> /// <summary>
/// Gets a <c>System.Boolean</c> indicating whether /// Gets a <c>System.Boolean</c> indicating whether
@ -287,9 +283,9 @@ namespace OpenTK
#if ANDROID || IPHONE #if ANDROID || IPHONE
runningOnMono = true; runningOnMono = true;
#else #else
runningOnMono = DetectMono(); RunningOnMono = DetectMono();
runningOnWindows = DetectWindows(); RunningOnWindows = DetectWindows();
if (!runningOnWindows) if (!RunningOnWindows)
{ {
DetectUnix(out runningOnUnix, out runningOnLinux, out runningOnMacOS); DetectUnix(out runningOnUnix, out runningOnLinux, out runningOnMacOS);
} }
@ -301,7 +297,7 @@ namespace OpenTK
if ((runningOnLinux && !RunningOnSdl2) || options.Backend == PlatformBackend.PreferX11) if ((runningOnLinux && !RunningOnSdl2) || options.Backend == PlatformBackend.PreferX11)
{ {
runningOnX11 = DetectX11(); RunningOnX11 = DetectX11();
} }
initialized = true; initialized = true;

View file

@ -44,7 +44,6 @@ namespace OpenTK
bool primary; bool primary;
Rectangle bounds; Rectangle bounds;
DisplayResolution current_resolution = new DisplayResolution(); DisplayResolution current_resolution = new DisplayResolution();
DisplayResolution original_resolution;
List<DisplayResolution> available_resolutions = new List<DisplayResolution>(); List<DisplayResolution> available_resolutions = new List<DisplayResolution>();
IList<DisplayResolution> available_resolutions_readonly; IList<DisplayResolution> available_resolutions_readonly;
@ -191,8 +190,8 @@ namespace OpenTK
if (implementation.TryChangeResolution(this, resolution)) if (implementation.TryChangeResolution(this, resolution))
{ {
if (original_resolution == null) if (OriginalResolution == null)
original_resolution = current_resolution; OriginalResolution = current_resolution;
current_resolution = resolution; current_resolution = resolution;
} }
else throw new Graphics.GraphicsModeException(String.Format("Device {0}: Failed to change resolution to {1}.", else throw new Graphics.GraphicsModeException(String.Format("Device {0}: Failed to change resolution to {1}.",
@ -216,14 +215,14 @@ namespace OpenTK
/// <exception cref="Graphics.GraphicsModeException">Thrown if the original resolution could not be restored.</exception> /// <exception cref="Graphics.GraphicsModeException">Thrown if the original resolution could not be restored.</exception>
public void RestoreResolution() public void RestoreResolution()
{ {
if (original_resolution != null) if (OriginalResolution != null)
{ {
//effect.FadeOut(); //effect.FadeOut();
if (implementation.TryRestoreResolution(this)) if (implementation.TryRestoreResolution(this))
{ {
current_resolution = original_resolution; current_resolution = OriginalResolution;
original_resolution = null; OriginalResolution = null;
} }
else throw new Graphics.GraphicsModeException(String.Format("Device {0}: Failed to restore resolution.", this)); else throw new Graphics.GraphicsModeException(String.Format("Device {0}: Failed to restore resolution.", this));
@ -250,11 +249,7 @@ namespace OpenTK
/// <summary> /// <summary>
/// Gets the original resolution of this instance. /// Gets the original resolution of this instance.
/// </summary> /// </summary>
internal DisplayResolution OriginalResolution internal DisplayResolution OriginalResolution { get; set; }
{
get { return original_resolution; }
set { original_resolution = value; }
}
internal static DisplayDevice FromPoint(int x, int y) internal static DisplayDevice FromPoint(int x, int y)
{ {

View file

@ -18,8 +18,6 @@ namespace OpenTK
public class DisplayResolution public class DisplayResolution
{ {
Rectangle bounds; Rectangle bounds;
int bits_per_pixel;
float refresh_rate;
internal DisplayResolution() { } internal DisplayResolution() { }
@ -33,8 +31,8 @@ namespace OpenTK
if (refreshRate < 0) throw new ArgumentOutOfRangeException("refreshRate", "Must be greater than, or equal to zero."); if (refreshRate < 0) throw new ArgumentOutOfRangeException("refreshRate", "Must be greater than, or equal to zero.");
this.bounds = new Rectangle(x, y, width, height); this.bounds = new Rectangle(x, y, width, height);
this.bits_per_pixel = bitsPerPixel; this.BitsPerPixel = bitsPerPixel;
this.refresh_rate = refreshRate; this.RefreshRate = refreshRate;
} }
#if false #if false
@ -91,20 +89,12 @@ namespace OpenTK
} }
/// <summary>Gets a System.Int32 that contains number of bits per pixel of this display. Typical values include 8, 16, 24 and 32.</summary> /// <summary>Gets a System.Int32 that contains number of bits per pixel of this display. Typical values include 8, 16, 24 and 32.</summary>
public int BitsPerPixel public int BitsPerPixel { get; internal set; }
{
get { return bits_per_pixel; }
internal set { bits_per_pixel = value; }
}
/// <summary> /// <summary>
/// Gets a System.Single representing the vertical refresh rate of this display. /// Gets a System.Single representing the vertical refresh rate of this display.
/// </summary> /// </summary>
public float RefreshRate public float RefreshRate { get; internal set; }
{
get { return refresh_rate; }
internal set { refresh_rate = value; }
}
/// <summary> /// <summary>
/// Returns a System.String representing this DisplayResolution. /// Returns a System.String representing this DisplayResolution.
@ -113,7 +103,7 @@ namespace OpenTK
public override string ToString() public override string ToString()
{ {
#pragma warning disable 612,618 #pragma warning disable 612,618
return String.Format("{0}x{1}@{2}Hz", Bounds, bits_per_pixel, refresh_rate); return String.Format("{0}x{1}@{2}Hz", Bounds, BitsPerPixel, RefreshRate);
#pragma warning restore 612,618 #pragma warning restore 612,618
} }
@ -141,7 +131,7 @@ namespace OpenTK
public override int GetHashCode() public override int GetHashCode()
{ {
#pragma warning disable 612,618 #pragma warning disable 612,618
return Bounds.GetHashCode() ^ bits_per_pixel ^ refresh_rate.GetHashCode(); return Bounds.GetHashCode() ^ BitsPerPixel ^ RefreshRate.GetHashCode();
#pragma warning restore 612,618 #pragma warning restore 612,618
} }

View file

@ -33,26 +33,18 @@ namespace OpenTK
/// </summary> /// </summary>
public class ContextExistsException : ApplicationException public class ContextExistsException : ApplicationException
{ {
string msg;
/// <summary> /// <summary>
/// Constructs a new ContextExistsException instance. /// Constructs a new ContextExistsException instance.
/// </summary> /// </summary>
/// <param name="message">A System.String explaining the cause of this exception.</param> /// <param name="message">A System.String explaining the cause of this exception.</param>
public ContextExistsException(string message) public ContextExistsException(string message)
{ {
msg = message; Message = message;
} }
/// <summary> /// <summary>
/// Gets a System.String explaining the cause of this exception. /// Gets a System.String explaining the cause of this exception.
/// </summary> /// </summary>
public override string Message public override string Message { get; }
{
get
{
return msg;
}
}
} }
} }

View file

@ -37,8 +37,6 @@ namespace OpenTK.Graphics
public struct ColorFormat : IComparable<ColorFormat>, IEquatable<ColorFormat> public struct ColorFormat : IComparable<ColorFormat>, IEquatable<ColorFormat>
{ {
byte red, green, blue, alpha; byte red, green, blue, alpha;
bool isIndexed;
int bitsPerPixel;
/// <summary> /// <summary>
/// Constructs a new ColorFormat with the specified aggregate bits per pixel. /// Constructs a new ColorFormat with the specified aggregate bits per pixel.
@ -49,8 +47,8 @@ namespace OpenTK.Graphics
if (bpp < 0) if (bpp < 0)
throw new ArgumentOutOfRangeException("bpp", "Must be greater or equal to zero."); throw new ArgumentOutOfRangeException("bpp", "Must be greater or equal to zero.");
red = green = blue = alpha = 0; red = green = blue = alpha = 0;
bitsPerPixel = bpp; BitsPerPixel = bpp;
isIndexed = false; IsIndexed = false;
switch (bpp) switch (bpp)
{ {
@ -103,10 +101,10 @@ namespace OpenTK.Graphics
this.green = (byte)green; this.green = (byte)green;
this.blue = (byte)blue; this.blue = (byte)blue;
this.alpha = (byte)alpha; this.alpha = (byte)alpha;
this.bitsPerPixel = red + green + blue + alpha; this.BitsPerPixel = red + green + blue + alpha;
this.isIndexed = false; this.IsIndexed = false;
if (this.bitsPerPixel < 15 && this.bitsPerPixel != 0) if (this.BitsPerPixel < 15 && this.BitsPerPixel != 0)
this.isIndexed = true; this.IsIndexed = true;
} }
/// <summary>Gets the bits per pixel for the Red channel.</summary> /// <summary>Gets the bits per pixel for the Red channel.</summary>
@ -118,9 +116,10 @@ namespace OpenTK.Graphics
/// <summary>Gets the bits per pixel for the Alpha channel.</summary> /// <summary>Gets the bits per pixel for the Alpha channel.</summary>
public int Alpha { get { return alpha; } private set { alpha = (byte)value; } } public int Alpha { get { return alpha; } private set { alpha = (byte)value; } }
/// <summary>Gets a System.Boolean indicating whether this ColorFormat is indexed.</summary> /// <summary>Gets a System.Boolean indicating whether this ColorFormat is indexed.</summary>
public bool IsIndexed { get { return isIndexed; } private set { isIndexed = value; } } public bool IsIndexed { get; private set; }
/// <summary>Gets the sum of Red, Green, Blue and Alpha bits per pixel.</summary> /// <summary>Gets the sum of Red, Green, Blue and Alpha bits per pixel.</summary>
public int BitsPerPixel { get { return bitsPerPixel; } private set { bitsPerPixel = value; } } public int BitsPerPixel { get; private set; }
/// <summary> /// <summary>
/// Defines an empty ColorFormat, where all properties are set to zero. /// Defines an empty ColorFormat, where all properties are set to zero.

View file

@ -52,7 +52,7 @@ namespace OpenTK.Graphics
IGraphicsContext implementation; // The actual render context implementation for the underlying platform. IGraphicsContext implementation; // The actual render context implementation for the underlying platform.
bool disposed; bool disposed;
bool check_errors = true;
// Cache for the context handle. We need this for RemoveContext() // Cache for the context handle. We need this for RemoveContext()
// in case the user does not call Dispose(). When this happens, // in case the user does not call Dispose(). When this happens,
// RemoveContext() is called by the finalizer, in which case // RemoveContext() is called by the finalizer, in which case
@ -61,8 +61,6 @@ namespace OpenTK.Graphics
// the handle.) // the handle.)
ContextHandle handle_cached; ContextHandle handle_cached;
static bool share_contexts = true;
static bool direct_rendering = true;
readonly static object SyncRoot = new object(); readonly static object SyncRoot = new object();
// Maps OS-specific context handles to GraphicsContext instances. // Maps OS-specific context handles to GraphicsContext instances.
readonly static Dictionary<ContextHandle, IGraphicsContext> available_contexts = readonly static Dictionary<ContextHandle, IGraphicsContext> available_contexts =
@ -172,7 +170,7 @@ namespace OpenTK.Graphics
GetCurrentContext = factory.CreateGetCurrentGraphicsContext(); GetCurrentContext = factory.CreateGetCurrentGraphicsContext();
} }
implementation = factory.CreateGLContext(mode, window, shareContext, direct_rendering, major, minor, flags); implementation = factory.CreateGLContext(mode, window, shareContext, DirectRendering, major, minor, flags);
handle_cached = ((IGraphicsContextInternal)implementation).Context; handle_cached = ((IGraphicsContextInternal)implementation).Context;
factory.RegisterResource(this); factory.RegisterResource(this);
} }
@ -392,7 +390,7 @@ namespace OpenTK.Graphics
/// false, new GLContexts will not share resources.</para> /// false, new GLContexts will not share resources.</para>
/// <para>Changing this value will not affect already created GLContexts.</para> /// <para>Changing this value will not affect already created GLContexts.</para>
/// </remarks> /// </remarks>
public static bool ShareContexts { get { return share_contexts; } set { share_contexts = value; } } public static bool ShareContexts { get; set; } = true;
/// <summary>Gets or sets a System.Boolean, indicating whether GraphicsContexts will perform direct rendering.</summary> /// <summary>Gets or sets a System.Boolean, indicating whether GraphicsContexts will perform direct rendering.</summary>
/// <remarks> /// <remarks>
@ -405,11 +403,7 @@ namespace OpenTK.Graphics
/// This property is ignored on Operating Systems without support for indirect rendering, like Windows and OS X. /// This property is ignored on Operating Systems without support for indirect rendering, like Windows and OS X.
/// </para> /// </para>
/// </remarks> /// </remarks>
public static bool DirectRendering public static bool DirectRendering { get; set; } = true;
{
get { return direct_rendering; }
set { direct_rendering = value; }
}
/// <summary> /// <summary>
/// Gets or sets a System.Boolean, indicating whether automatic error checking should be performed. /// Gets or sets a System.Boolean, indicating whether automatic error checking should be performed.
@ -417,11 +411,7 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
/// <remarks>Automatic error checking will clear the OpenGL error state. Set CheckErrors to false if you use /// <remarks>Automatic error checking will clear the OpenGL error state. Set CheckErrors to false if you use
/// the OpenGL error state in your code flow (e.g. for checking supported texture formats).</remarks> /// the OpenGL error state in your code flow (e.g. for checking supported texture formats).</remarks>
public bool ErrorChecking public bool ErrorChecking { get; set; } = true;
{
get { return check_errors; }
set { check_errors = value; }
}
/// <summary> /// <summary>
/// Swaps buffers on a context. This presents the rendered scene to the user. /// Swaps buffers on a context. This presents the rendered scene to the user.

View file

@ -36,8 +36,6 @@ namespace OpenTK.Graphics
// Provides the foundation for all IGraphicsContext implementations. // Provides the foundation for all IGraphicsContext implementations.
abstract class GraphicsContextBase : IGraphicsContext, IGraphicsContextInternal, IEquatable<IGraphicsContextInternal> abstract class GraphicsContextBase : IGraphicsContext, IGraphicsContextInternal, IEquatable<IGraphicsContextInternal>
{ {
bool disposed;
protected ContextHandle Handle; protected ContextHandle Handle;
protected GraphicsMode Mode; protected GraphicsMode Mode;
@ -47,11 +45,7 @@ namespace OpenTK.Graphics
public abstract bool IsCurrent { get; } public abstract bool IsCurrent { get; }
public bool IsDisposed public bool IsDisposed { get; protected set; }
{
get { return disposed; }
protected set { disposed = value; }
}
public bool VSync public bool VSync
{ {

View file

@ -34,9 +34,6 @@ namespace OpenTK.Graphics
/// </summary> /// </summary>
public sealed class GraphicsContextVersion public sealed class GraphicsContextVersion
{ {
int minor, major;
string vendor = String.Empty, renderer = String.Empty;
internal GraphicsContextVersion(int minor, int major, string vendor, string renderer) internal GraphicsContextVersion(int minor, int major, string vendor, string renderer)
{ {
Minor = minor; Minor = minor;
@ -48,21 +45,21 @@ namespace OpenTK.Graphics
/// <summary> /// <summary>
/// Gets a System.Int32 indicating the minor version of a GraphicsContext instance. /// Gets a System.Int32 indicating the minor version of a GraphicsContext instance.
/// </summary> /// </summary>
public int Minor { get { return minor; } private set { minor = value; } } public int Minor { get; private set; }
/// <summary> /// <summary>
/// Gets a System.Int32 indicating the major version of a GraphicsContext instance. /// Gets a System.Int32 indicating the major version of a GraphicsContext instance.
/// </summary> /// </summary>
public int Major { get { return major; } private set { major = value; } } public int Major { get; private set; }
/// <summary> /// <summary>
/// Gets a System.String indicating the vendor of a GraphicsContext instance. /// Gets a System.String indicating the vendor of a GraphicsContext instance.
/// </summary> /// </summary>
public string Vendor { get { return vendor; } private set { vendor = value; } } public string Vendor { get; private set; } = String.Empty;
/// <summary> /// <summary>
/// Gets a System.String indicating the renderer of a GraphicsContext instance. /// Gets a System.String indicating the renderer of a GraphicsContext instance.
/// </summary> /// </summary>
public string Renderer { get { return renderer; } private set { renderer = value; } } public string Renderer { get; private set; } = String.Empty;
} }
} }

View file

@ -14,10 +14,7 @@ namespace OpenTK.Graphics
/// <summary>Defines the format for graphics operations.</summary> /// <summary>Defines the format for graphics operations.</summary>
public class GraphicsMode : IEquatable<GraphicsMode> public class GraphicsMode : IEquatable<GraphicsMode>
{ {
ColorFormat color_format, accumulator_format; int samples;
int depth, stencil, buffers, samples;
bool stereo;
IntPtr? index = null; // The id of the pixel format or visual.
static GraphicsMode defaultMode; static GraphicsMode defaultMode;
static readonly object SyncRoot = new object(); static readonly object SyncRoot = new object();
@ -116,64 +113,29 @@ namespace OpenTK.Graphics
/// <summary> /// <summary>
/// Gets a nullable <see cref="System.IntPtr"/> value, indicating the platform-specific index for this GraphicsMode. /// Gets a nullable <see cref="System.IntPtr"/> value, indicating the platform-specific index for this GraphicsMode.
/// </summary> /// </summary>
public IntPtr? Index public IntPtr? Index { get; set; } = null;
{
get
{
return index;
}
set { index = value; }
}
/// <summary> /// <summary>
/// Gets an OpenTK.Graphics.ColorFormat that describes the color format for this GraphicsFormat. /// Gets an OpenTK.Graphics.ColorFormat that describes the color format for this GraphicsFormat.
/// </summary> /// </summary>
public ColorFormat ColorFormat public ColorFormat ColorFormat { get; private set; }
{
get
{
return color_format;
}
private set { color_format = value; }
}
/// <summary> /// <summary>
/// Gets an OpenTK.Graphics.ColorFormat that describes the accumulator format for this GraphicsFormat. /// Gets an OpenTK.Graphics.ColorFormat that describes the accumulator format for this GraphicsFormat.
/// </summary> /// </summary>
public ColorFormat AccumulatorFormat public ColorFormat AccumulatorFormat { get; private set; }
{
get
{
return accumulator_format;
}
private set { accumulator_format = value; }
}
/// <summary> /// <summary>
/// Gets a System.Int32 that contains the bits per pixel for the depth buffer /// Gets a System.Int32 that contains the bits per pixel for the depth buffer
/// for this GraphicsFormat. /// for this GraphicsFormat.
/// </summary> /// </summary>
public int Depth public int Depth { get; private set; }
{
get
{
return depth;
}
private set { depth = value; }
}
/// <summary> /// <summary>
/// Gets a System.Int32 that contains the bits per pixel for the stencil buffer /// Gets a System.Int32 that contains the bits per pixel for the stencil buffer
/// of this GraphicsFormat. /// of this GraphicsFormat.
/// </summary> /// </summary>
public int Stencil public int Stencil { get; private set; }
{
get
{
return stencil;
}
private set { stencil = value; }
}
/// <summary> /// <summary>
/// Gets a System.Int32 that contains the number of FSAA samples per pixel for this GraphicsFormat. /// Gets a System.Int32 that contains the number of FSAA samples per pixel for this GraphicsFormat.
@ -197,27 +159,13 @@ namespace OpenTK.Graphics
/// <summary> /// <summary>
/// Gets a System.Boolean indicating whether this DisplayMode is stereoscopic. /// Gets a System.Boolean indicating whether this DisplayMode is stereoscopic.
/// </summary> /// </summary>
public bool Stereo public bool Stereo { get; private set; }
{
get
{
return stereo;
}
private set { stereo = value; }
}
/// <summary> /// <summary>
/// Gets a System.Int32 containing the number of buffers associated with this /// Gets a System.Int32 containing the number of buffers associated with this
/// DisplayMode. /// DisplayMode.
/// </summary> /// </summary>
public int Buffers public int Buffers { get; private set; }
{
get
{
return buffers;
}
private set { buffers = value; }
}
/// <summary>Returns an OpenTK.GraphicsFormat compatible with the underlying platform.</summary> /// <summary>Returns an OpenTK.GraphicsFormat compatible with the underlying platform.</summary>
public static GraphicsMode Default public static GraphicsMode Default

View file

@ -37,8 +37,6 @@ namespace OpenTK.Input
Buttons buttons; Buttons buttons;
GamePadAxes axes; GamePadAxes axes;
byte gamepad_type; byte gamepad_type;
bool is_connected;
bool is_mapped;
internal GamePadCapabilities(GamePadType type, GamePadAxes axes, Buttons buttons, bool is_connected, bool is_mapped) internal GamePadCapabilities(GamePadType type, GamePadAxes axes, Buttons buttons, bool is_connected, bool is_mapped)
: this() : this()
@ -46,8 +44,8 @@ namespace OpenTK.Input
gamepad_type = (byte)type; gamepad_type = (byte)type;
this.axes = axes; this.axes = axes;
this.buttons = buttons; this.buttons = buttons;
this.is_connected = is_connected; this.IsConnected = is_connected;
this.is_mapped = is_mapped; this.IsMapped = is_mapped;
} }
/// <summary> /// <summary>
@ -306,19 +304,13 @@ namespace OpenTK.Input
/// currently connected. /// currently connected.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is currently connected; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is currently connected; otherwise, <c>false</c>.</value>
public bool IsConnected public bool IsConnected { get; }
{
get { return is_connected; }
}
/// <summary> /// <summary>
/// Gets a <see cref="System.Boolean"/> value describing whether a valid button configuration /// Gets a <see cref="System.Boolean"/> value describing whether a valid button configuration
/// exists for this <c>GamePad</c> in the GamePad configuration database. /// exists for this <c>GamePad</c> in the GamePad configuration database.
/// </summary> /// </summary>
public bool IsMapped public bool IsMapped { get; }
{
get { return is_mapped; }
}
/// <param name="left">A <see cref="GamePadCapabilities"/> structure to test for equality.</param> /// <param name="left">A <see cref="GamePadCapabilities"/> structure to test for equality.</param>
/// <param name="right">A <see cref="GamePadCapabilities"/> structure to test for equality.</param> /// <param name="right">A <see cref="GamePadCapabilities"/> structure to test for equality.</param>
@ -358,8 +350,8 @@ namespace OpenTK.Input
{ {
return return
buttons.GetHashCode() ^ buttons.GetHashCode() ^
is_connected.GetHashCode() ^ IsConnected.GetHashCode() ^
is_mapped.GetHashCode() ^ IsMapped.GetHashCode() ^
gamepad_type.GetHashCode(); gamepad_type.GetHashCode();
} }
@ -386,8 +378,8 @@ namespace OpenTK.Input
{ {
return return
buttons == other.buttons && buttons == other.buttons &&
is_connected == other.is_connected && IsConnected == other.IsConnected &&
is_mapped == other.is_mapped && IsMapped == other.IsMapped &&
gamepad_type == other.gamepad_type; gamepad_type == other.gamepad_type;
} }
} }

View file

@ -36,22 +36,12 @@ namespace OpenTK.Input
{ {
static readonly char[] ConfigurationSeparator = new char[] { ',' }; static readonly char[] ConfigurationSeparator = new char[] { ',' };
Guid guid;
string name;
readonly List<GamePadConfigurationItem> configuration_items = readonly List<GamePadConfigurationItem> configuration_items =
new List<GamePadConfigurationItem>(); new List<GamePadConfigurationItem>();
public Guid Guid public Guid Guid { get; private set; }
{
get { return guid; }
private set { guid = value; }
}
public string Name public string Name { get; private set; }
{
get { return name; }
private set { name = value; }
}
public GamePadConfiguration(string configuration) public GamePadConfiguration(string configuration)
{ {

View file

@ -31,26 +31,15 @@ namespace OpenTK.Input
{ {
class GamePadConfigurationItem class GamePadConfigurationItem
{ {
GamePadConfigurationSource source;
GamePadConfigurationTarget target;
public GamePadConfigurationItem(GamePadConfigurationSource source, GamePadConfigurationTarget target) public GamePadConfigurationItem(GamePadConfigurationSource source, GamePadConfigurationTarget target)
{ {
Source = source; Source = source;
Target = target; Target = target;
} }
public GamePadConfigurationSource Source public GamePadConfigurationSource Source { get; private set; }
{
get { return source; }
private set { source = value; }
}
public GamePadConfigurationTarget Target public GamePadConfigurationTarget Target { get; private set; }
{
get { return target; }
private set { target = value; }
}
} }
} }

View file

@ -31,7 +31,6 @@ namespace OpenTK.Input
{ {
struct GamePadConfigurationSource struct GamePadConfigurationSource
{ {
ConfigurationType map_type;
int? map_button; int? map_button;
JoystickAxis? map_axis; JoystickAxis? map_axis;
JoystickHat? map_hat; JoystickHat? map_hat;
@ -59,11 +58,7 @@ namespace OpenTK.Input
map_hat_position = pos; map_hat_position = pos;
} }
public ConfigurationType Type public ConfigurationType Type { get; private set; }
{
get { return map_type; }
private set { map_type = value; }
}
public JoystickAxis Axis public JoystickAxis Axis
{ {

View file

@ -31,7 +31,6 @@ namespace OpenTK.Input
{ {
struct GamePadConfigurationTarget struct GamePadConfigurationTarget
{ {
ConfigurationType map_type;
Nullable<Buttons> map_button; Nullable<Buttons> map_button;
Nullable<GamePadAxes> map_axis; Nullable<GamePadAxes> map_axis;
@ -49,11 +48,7 @@ namespace OpenTK.Input
map_axis = axis; map_axis = axis;
} }
public ConfigurationType Type public ConfigurationType Type { get; private set; }
{
get { return map_type; }
private set { map_type = value; }
}
public GamePadAxes Axis public GamePadAxes Axis
{ {

View file

@ -35,14 +35,12 @@ namespace OpenTK.Input
const float RangeMultiplier = 1.0f / (short.MaxValue + 1); const float RangeMultiplier = 1.0f / (short.MaxValue + 1);
Buttons buttons; Buttons buttons;
int packet_number;
short left_stick_x; short left_stick_x;
short left_stick_y; short left_stick_y;
short right_stick_x; short right_stick_x;
short right_stick_y; short right_stick_y;
byte left_trigger; byte left_trigger;
byte right_trigger; byte right_trigger;
bool is_connected;
/// <summary> /// <summary>
/// Gets a <see cref="GamePadThumbSticks"/> structure describing the /// Gets a <see cref="GamePadThumbSticks"/> structure describing the
@ -84,20 +82,14 @@ namespace OpenTK.Input
/// Gets a value indicating whether this <c>GamePad</c> instance is connected. /// Gets a value indicating whether this <c>GamePad</c> instance is connected.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value>
public bool IsConnected public bool IsConnected { get; private set; }
{
get { return is_connected; }
}
/// <summary> /// <summary>
/// Gets the packet number for this <c>GamePadState</c> instance. /// Gets the packet number for this <c>GamePadState</c> instance.
/// Use the packet number to determine whether the state of a /// Use the packet number to determine whether the state of a
/// <c>GamePad</c> device has changed. /// <c>GamePad</c> device has changed.
/// </summary> /// </summary>
public int PacketNumber public int PacketNumber { get; private set; }
{
get { return packet_number; }
}
/// <summary> /// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadState"/>. /// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.GamePadState"/>.
@ -199,7 +191,7 @@ namespace OpenTK.Input
internal void SetConnected(bool connected) internal void SetConnected(bool connected)
{ {
is_connected = connected; IsConnected = connected;
} }
internal void SetTriggers(byte left, byte right) internal void SetTriggers(byte left, byte right)
@ -210,7 +202,7 @@ namespace OpenTK.Input
internal void SetPacketNumber(int number) internal void SetPacketNumber(int number)
{ {
packet_number = number; PacketNumber = number;
} }
bool IsAxisValid(GamePadAxes axis) bool IsAxisValid(GamePadAxes axis)

View file

@ -40,7 +40,6 @@ namespace OpenTK.Input
byte axis_count; byte axis_count;
byte button_count; byte button_count;
byte hat_count; byte hat_count;
bool is_connected;
internal JoystickCapabilities(int axis_count, int button_count, int hat_count, bool is_connected) internal JoystickCapabilities(int axis_count, int button_count, int hat_count, bool is_connected)
{ {
@ -61,12 +60,12 @@ namespace OpenTK.Input
this.axis_count = (byte)axis_count; this.axis_count = (byte)axis_count;
this.button_count = (byte)button_count; this.button_count = (byte)button_count;
this.hat_count = (byte)hat_count; this.hat_count = (byte)hat_count;
this.is_connected = is_connected; this.IsConnected = is_connected;
} }
internal void SetIsConnected(bool value) internal void SetIsConnected(bool value)
{ {
is_connected = value; IsConnected = value;
} }
/// <summary> /// <summary>
@ -97,11 +96,7 @@ namespace OpenTK.Input
/// Gets a value indicating whether this <see cref="JoystickDevice"/> is connected. /// Gets a value indicating whether this <see cref="JoystickDevice"/> is connected.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value>
public bool IsConnected public bool IsConnected { get; private set; }
{
get { return is_connected; }
private set { is_connected = value; }
}
/// <summary> /// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.JoystickCapabilities"/>. /// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.JoystickCapabilities"/>.

View file

@ -33,10 +33,6 @@ namespace OpenTK.Input
/// </summary> /// </summary>
public abstract class JoystickDevice : IInputDevice public abstract class JoystickDevice : IInputDevice
{ {
int id;
string description;
JoystickAxisCollection axis_collection;
JoystickButtonCollection button_collection;
JoystickMoveEventArgs move_args = new JoystickMoveEventArgs(0, 0, 0); JoystickMoveEventArgs move_args = new JoystickMoveEventArgs(0, 0, 0);
JoystickButtonEventArgs button_args = new JoystickButtonEventArgs(0, false); JoystickButtonEventArgs button_args = new JoystickButtonEventArgs(0, false);
@ -49,28 +45,24 @@ namespace OpenTK.Input
throw new ArgumentOutOfRangeException("buttons"); throw new ArgumentOutOfRangeException("buttons");
Id = id; Id = id;
axis_collection = new JoystickAxisCollection(axes); Axis = new JoystickAxisCollection(axes);
button_collection = new JoystickButtonCollection(buttons); Button = new JoystickButtonCollection(buttons);
} }
/// <summary> /// <summary>
/// Gets a JoystickAxisCollection containing the state of each axis on this instance. Values are normalized in the [-1, 1] range. /// Gets a JoystickAxisCollection containing the state of each axis on this instance. Values are normalized in the [-1, 1] range.
/// </summary> /// </summary>
public JoystickAxisCollection Axis { get { return axis_collection; } } public JoystickAxisCollection Axis { get; }
/// <summary> /// <summary>
/// Gets JoystickButtonCollection containing the state of each button on this instance. True indicates that the button is pressed. /// Gets JoystickButtonCollection containing the state of each button on this instance. True indicates that the button is pressed.
/// </summary> /// </summary>
public JoystickButtonCollection Button { get { return button_collection; } } public JoystickButtonCollection Button { get; }
/// <summary> /// <summary>
/// Gets a System.String containing a unique description for this instance. /// Gets a System.String containing a unique description for this instance.
/// </summary> /// </summary>
public string Description public string Description { get; internal set; }
{
get { return description; }
internal set { description = value; }
}
/// <summary> /// <summary>
/// Gets a value indicating the InputDeviceType of this InputDevice. /// Gets a value indicating the InputDeviceType of this InputDevice.
@ -98,31 +90,27 @@ namespace OpenTK.Input
public EventHandler<JoystickButtonEventArgs> ButtonUp = public EventHandler<JoystickButtonEventArgs> ButtonUp =
delegate(object sender, JoystickButtonEventArgs e) { }; delegate(object sender, JoystickButtonEventArgs e) { };
internal int Id internal int Id { get; set; }
{
get { return id; }
set { id = value; }
}
internal void SetAxis(JoystickAxis axis, float @value) internal void SetAxis(JoystickAxis axis, float @value)
{ {
if ((int)axis < axis_collection.Count) if ((int)axis < Axis.Count)
{ {
move_args.Axis = axis; move_args.Axis = axis;
move_args.Delta = move_args.Value - @value; move_args.Delta = move_args.Value - @value;
axis_collection[axis] = move_args.Value = @value; Axis[axis] = move_args.Value = @value;
Move(this, move_args); Move(this, move_args);
} }
} }
internal void SetButton(int button, bool @value) internal void SetButton(int button, bool @value)
{ {
if (button < button_collection.Count) if (button < Button.Count)
{ {
if (button_collection[button] != @value) if (Button[button] != @value)
{ {
button_args.Button = button; button_args.Button = button;
button_collection[button] = button_args.Pressed = @value; Button[button] = button_args.Pressed = @value;
if (@value) if (@value)
ButtonDown(this, button_args); ButtonDown(this, button_args);
else else
@ -156,9 +144,6 @@ namespace OpenTK.Input
/// </summary> /// </summary>
public class JoystickButtonEventArgs : EventArgs public class JoystickButtonEventArgs : EventArgs
{ {
int button;
bool pressed;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JoystickButtonEventArgs"/> class. /// Initializes a new instance of the <see cref="JoystickButtonEventArgs"/> class.
/// </summary> /// </summary>
@ -166,19 +151,19 @@ namespace OpenTK.Input
/// <param name="pressed">The current state of the button.</param> /// <param name="pressed">The current state of the button.</param>
internal JoystickButtonEventArgs(int button, bool pressed) internal JoystickButtonEventArgs(int button, bool pressed)
{ {
this.button = button; this.Button = button;
this.pressed = pressed; this.Pressed = pressed;
} }
/// <summary> /// <summary>
/// The index of the joystick button for the event. /// The index of the joystick button for the event.
/// </summary> /// </summary>
public int Button { get { return this.button; } internal set { this.button = value; } } public int Button { get; internal set; }
/// <summary> /// <summary>
/// Gets a System.Boolean representing the state of the button for the event. /// Gets a System.Boolean representing the state of the button for the event.
/// </summary> /// </summary>
public bool Pressed { get { return pressed; } internal set { this.pressed = value; } } public bool Pressed { get; internal set; }
} }
/// <summary> /// <summary>
@ -187,10 +172,6 @@ namespace OpenTK.Input
/// </summary> /// </summary>
public class JoystickMoveEventArgs : JoystickEventArgs public class JoystickMoveEventArgs : JoystickEventArgs
{ {
JoystickAxis axis;
float value;
float delta;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="JoystickMoveEventArgs"/> class. /// Initializes a new instance of the <see cref="JoystickMoveEventArgs"/> class.
/// </summary> /// </summary>
@ -199,25 +180,25 @@ namespace OpenTK.Input
/// <param name="delta">The relative change in value of the joystick axis.</param> /// <param name="delta">The relative change in value of the joystick axis.</param>
public JoystickMoveEventArgs(JoystickAxis axis, float value, float delta) public JoystickMoveEventArgs(JoystickAxis axis, float value, float delta)
{ {
this.axis = axis; this.Axis = axis;
this.value = value; this.Value = value;
this.delta = delta; this.Delta = delta;
} }
/// <summary> /// <summary>
/// Gets a System.Int32 representing the index of the axis that was moved. /// Gets a System.Int32 representing the index of the axis that was moved.
/// </summary> /// </summary>
public JoystickAxis Axis { get { return axis; } internal set { this.axis = value; } } public JoystickAxis Axis { get; internal set; }
/// <summary> /// <summary>
/// Gets a System.Single representing the absolute position of the axis. /// Gets a System.Single representing the absolute position of the axis.
/// </summary> /// </summary>
public float Value { get { return value; } internal set { this.value = value; } } public float Value { get; internal set; }
/// <summary> /// <summary>
/// Gets a System.Single representing the relative change in the position of the axis. /// Gets a System.Single representing the relative change in the position of the axis.
/// </summary> /// </summary>
public float Delta { get { return delta; } internal set { this.delta = value; } } public float Delta { get; internal set; }
} }
/// <summary> /// <summary>

View file

@ -34,11 +34,9 @@ namespace OpenTK.Input
/// </summary> /// </summary>
public struct JoystickHatState : IEquatable<JoystickHatState> public struct JoystickHatState : IEquatable<JoystickHatState>
{ {
HatPosition position;
internal JoystickHatState(HatPosition pos) internal JoystickHatState(HatPosition pos)
{ {
position = pos; Position = pos;
} }
/// <summary> /// <summary>
@ -46,7 +44,7 @@ namespace OpenTK.Input
/// the position of this hat. /// the position of this hat.
/// </summary> /// </summary>
/// <value>The position.</value> /// <value>The position.</value>
public HatPosition Position { get { return position; } } public HatPosition Position { get; }
/// <summary> /// <summary>
/// Gets a <see cref="System.Boolean"/> indicating /// Gets a <see cref="System.Boolean"/> indicating

View file

@ -44,14 +44,12 @@ namespace OpenTK.Input
const float ConversionFactor = 1.0f / (short.MaxValue + 0.5f); const float ConversionFactor = 1.0f / (short.MaxValue + 0.5f);
int packet_number;
long buttons; long buttons;
unsafe fixed short axes[MaxAxes]; unsafe fixed short axes[MaxAxes];
JoystickHatState hat0; JoystickHatState hat0;
JoystickHatState hat1; JoystickHatState hat1;
JoystickHatState hat2; JoystickHatState hat2;
JoystickHatState hat3; JoystickHatState hat3;
bool is_connected;
/// <summary> /// <summary>
/// Gets a value between -1.0 and 1.0 representing the current offset of the specified <see cref="JoystickAxis"/>. /// Gets a value between -1.0 and 1.0 representing the current offset of the specified <see cref="JoystickAxis"/>.
@ -136,10 +134,7 @@ namespace OpenTK.Input
/// Gets a value indicating whether this instance is connected. /// Gets a value indicating whether this instance is connected.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value>
public bool IsConnected public bool IsConnected { get; private set; }
{
get { return is_connected; }
}
/// <summary> /// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.JoystickState"/>. /// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.JoystickState"/>.
@ -189,10 +184,7 @@ namespace OpenTK.Input
Equals((JoystickState)obj); Equals((JoystickState)obj);
} }
internal int PacketNumber internal int PacketNumber { get; private set; }
{
get { return packet_number; }
}
internal short GetAxisRaw(JoystickAxis axis) internal short GetAxisRaw(JoystickAxis axis)
{ {
@ -271,12 +263,12 @@ namespace OpenTK.Input
internal void SetIsConnected(bool value) internal void SetIsConnected(bool value)
{ {
is_connected = value; IsConnected = value;
} }
internal void SetPacketNumber(int number) internal void SetPacketNumber(int number)
{ {
packet_number = number; PacketNumber = number;
} }
short GetAxisUnsafe(int index) short GetAxisUnsafe(int index)

View file

@ -15,10 +15,8 @@ namespace OpenTK.Input
public sealed class KeyboardDevice : IInputDevice public sealed class KeyboardDevice : IInputDevice
{ {
//private IKeyboard keyboard; //private IKeyboard keyboard;
private string description;
private int numKeys, numFKeys, numLeds;
private IntPtr devID; private IntPtr devID;
private bool repeat;
private KeyboardState state; private KeyboardState state;
internal KeyboardDevice() { } internal KeyboardDevice() { }
@ -47,29 +45,17 @@ namespace OpenTK.Input
/// <summary> /// <summary>
/// Gets an integer representing the number of keys on this KeyboardDevice. /// Gets an integer representing the number of keys on this KeyboardDevice.
/// </summary> /// </summary>
public int NumberOfKeys public int NumberOfKeys { get; internal set; }
{
get { return numKeys; }
internal set { numKeys = value; }
}
/// <summary> /// <summary>
/// Gets an integer representing the number of function keys (F-keys) on this KeyboardDevice. /// Gets an integer representing the number of function keys (F-keys) on this KeyboardDevice.
/// </summary> /// </summary>
public int NumberOfFunctionKeys public int NumberOfFunctionKeys { get; internal set; }
{
get { return numFKeys; }
internal set { numFKeys = value; }
}
/// <summary> /// <summary>
/// Gets a value indicating the number of led indicators on this KeyboardDevice. /// Gets a value indicating the number of led indicators on this KeyboardDevice.
/// </summary> /// </summary>
public int NumberOfLeds public int NumberOfLeds { get; internal set; }
{
get { return numLeds; }
internal set { numLeds = value; }
}
/// <summary> /// <summary>
/// Gets an IntPtr representing a device dependent ID. /// Gets an IntPtr representing a device dependent ID.
@ -96,11 +82,7 @@ namespace OpenTK.Input
/// for game input. /// for game input.
/// </para> /// </para>
/// </remarks> /// </remarks>
public bool KeyRepeat public bool KeyRepeat { get; set; }
{
get { return repeat; }
set { repeat = value; }
}
/// <summary> /// <summary>
/// Occurs when a key is pressed. /// Occurs when a key is pressed.
@ -115,11 +97,7 @@ namespace OpenTK.Input
/// <summary> /// <summary>
/// Gets a <see cref="System.String"/> which describes this instance. /// Gets a <see cref="System.String"/> which describes this instance.
/// </summary> /// </summary>
public string Description public string Description { get; internal set; }
{
get { return description; }
internal set { description = value; }
}
/// <summary> /// <summary>
/// Gets the <see cref="InputDeviceType"/> for this instance. /// Gets the <see cref="InputDeviceType"/> for this instance.
@ -157,7 +135,7 @@ namespace OpenTK.Input
public override int GetHashCode() public override int GetHashCode()
{ {
//return base.GetHashCode(); //return base.GetHashCode();
return (int)(numKeys ^ numFKeys ^ numLeds ^ devID.GetHashCode() ^ description.GetHashCode()); return (int)(NumberOfKeys ^ NumberOfFunctionKeys ^ NumberOfLeds ^ devID.GetHashCode() ^ Description.GetHashCode());
} }
/// <summary> /// <summary>

View file

@ -41,10 +41,6 @@ namespace OpenTK.Input
/// </remarks> /// </remarks>
public class KeyboardKeyEventArgs : EventArgs public class KeyboardKeyEventArgs : EventArgs
{ {
Key key;
bool repeat;
KeyboardState state;
/// <summary> /// <summary>
/// Constructs a new KeyboardEventArgs instance. /// Constructs a new KeyboardEventArgs instance.
/// </summary> /// </summary>
@ -62,11 +58,7 @@ namespace OpenTK.Input
/// <summary> /// <summary>
/// Gets the <see cref="Key"/> that generated this event. /// Gets the <see cref="Key"/> that generated this event.
/// </summary> /// </summary>
public Key Key public Key Key { get; internal set; }
{
get { return key; }
internal set { key = value; }
}
/// <summary> /// <summary>
/// Gets the scancode which generated this event. /// Gets the scancode which generated this event.
@ -83,7 +75,7 @@ namespace OpenTK.Input
/// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value> /// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value>
public bool Alt public bool Alt
{ {
get { return state[Key.AltLeft] || state[Key.AltRight]; } get { return Keyboard[Key.AltLeft] || Keyboard[Key.AltRight]; }
} }
/// <summary> /// <summary>
@ -92,7 +84,7 @@ namespace OpenTK.Input
/// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value> /// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value>
public bool Control public bool Control
{ {
get { return state[Key.ControlLeft] || state[Key.ControlRight]; } get { return Keyboard[Key.ControlLeft] || Keyboard[Key.ControlRight]; }
} }
/// <summary> /// <summary>
@ -101,7 +93,7 @@ namespace OpenTK.Input
/// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value> /// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value>
public bool Shift public bool Shift
{ {
get { return state[Key.ShiftLeft] || state[Key.ShiftRight]; } get { return Keyboard[Key.ShiftLeft] || Keyboard[Key.ShiftRight]; }
} }
/// <summary> /// <summary>
@ -125,11 +117,7 @@ namespace OpenTK.Input
/// Gets the current <see cref="OpenTK.Input.KeyboardState"/>. /// Gets the current <see cref="OpenTK.Input.KeyboardState"/>.
/// </summary> /// </summary>
/// <value>The keyboard.</value> /// <value>The keyboard.</value>
public KeyboardState Keyboard public KeyboardState Keyboard { get; internal set; }
{
get { return state; }
internal set { state = value; }
}
/// <summary> /// <summary>
/// Gets a <see cref="System.Boolean"/> indicating whether /// Gets a <see cref="System.Boolean"/> indicating whether
@ -140,10 +128,6 @@ namespace OpenTK.Input
/// a key; false, if this was caused by the user pressing a /// a key; false, if this was caused by the user pressing a
/// key for the first time. /// key for the first time.
/// </value> /// </value>
public bool IsRepeat public bool IsRepeat { get; internal set; }
{
get { return repeat; }
internal set { repeat = value; }
}
} }
} }

View file

@ -39,7 +39,6 @@ namespace OpenTK.Input
const int NumInts = ((int)Key.LastKey + IntSize - 1) / IntSize; const int NumInts = ((int)Key.LastKey + IntSize - 1) / IntSize;
// The following line triggers bogus CS0214 in gmcs 2.0.1, sigh... // The following line triggers bogus CS0214 in gmcs 2.0.1, sigh...
unsafe fixed int Keys[NumInts]; unsafe fixed int Keys[NumInts];
bool is_connected;
/// <summary> /// <summary>
/// Gets a <see cref="System.Boolean"/> indicating whether the specified /// Gets a <see cref="System.Boolean"/> indicating whether the specified
@ -131,11 +130,7 @@ namespace OpenTK.Input
/// Gets a <see cref="System.Boolean"/> indicating whether this keyboard /// Gets a <see cref="System.Boolean"/> indicating whether this keyboard
/// is connected. /// is connected.
/// </summary> /// </summary>
public bool IsConnected public bool IsConnected { get; internal set; }
{
get { return is_connected; }
internal set { is_connected = value; }
}
#if false #if false
// Disabled until the correct cross-platform API can be determined. // Disabled until the correct cross-platform API can be determined.

View file

@ -40,9 +40,7 @@ namespace OpenTK.Input
/// </summary> /// </summary>
public sealed class MouseDevice : IInputDevice public sealed class MouseDevice : IInputDevice
{ {
string description;
IntPtr id; IntPtr id;
int numButtons, numWheels;
MouseState state; MouseState state;
#if COMPAT_REV1519 #if COMPAT_REV1519
@ -53,11 +51,7 @@ namespace OpenTK.Input
/// <summary> /// <summary>
/// Gets a string describing this MouseDevice. /// Gets a string describing this MouseDevice.
/// </summary> /// </summary>
public string Description public string Description { get; internal set; }
{
get { return description; }
internal set { description = value; }
}
/// <summary> /// <summary>
/// Gets a value indicating the InputDeviceType of this InputDevice. /// Gets a value indicating the InputDeviceType of this InputDevice.
@ -104,20 +98,12 @@ namespace OpenTK.Input
/// <summary> /// <summary>
/// Gets an integer representing the number of buttons on this MouseDevice. /// Gets an integer representing the number of buttons on this MouseDevice.
/// </summary> /// </summary>
public int NumberOfButtons public int NumberOfButtons { get; internal set; }
{
get { return numButtons; }
internal set { numButtons = value; }
}
/// <summary> /// <summary>
/// Gets an integer representing the number of wheels on this MouseDevice. /// Gets an integer representing the number of wheels on this MouseDevice.
/// </summary> /// </summary>
public int NumberOfWheels public int NumberOfWheels { get; internal set; }
{
get { return numWheels; }
internal set { numWheels = value; }
}
/// <summary> /// <summary>
/// Gets an IntPtr representing a device dependent ID. /// Gets an IntPtr representing a device dependent ID.
@ -228,7 +214,7 @@ namespace OpenTK.Input
/// <returns></returns> /// <returns></returns>
public override int GetHashCode() public override int GetHashCode()
{ {
return (int)(numButtons ^ numWheels ^ id.GetHashCode() ^ description.GetHashCode()); return (int)(NumberOfButtons ^ NumberOfWheels ^ id.GetHashCode() ^ Description.GetHashCode());
} }
/// <summary> /// <summary>

View file

@ -147,8 +147,6 @@ namespace OpenTK.Input
/// </remarks> /// </remarks>
public class MouseMoveEventArgs : MouseEventArgs public class MouseMoveEventArgs : MouseEventArgs
{ {
int x_delta, y_delta;
/// <summary> /// <summary>
/// Constructs a new <see cref="MouseMoveEventArgs"/> instance. /// Constructs a new <see cref="MouseMoveEventArgs"/> instance.
/// </summary> /// </summary>
@ -180,12 +178,12 @@ namespace OpenTK.Input
/// <summary> /// <summary>
/// Gets the change in X position produced by this event. /// Gets the change in X position produced by this event.
/// </summary> /// </summary>
public int XDelta { get { return x_delta; } internal set { x_delta = value; } } public int XDelta { get; internal set; }
/// <summary> /// <summary>
/// Gets the change in Y position produced by this event. /// Gets the change in Y position produced by this event.
/// </summary> /// </summary>
public int YDelta { get { return y_delta; } internal set { y_delta = value; } } public int YDelta { get; internal set; }
} }
/// <summary> /// <summary>
@ -200,8 +198,6 @@ namespace OpenTK.Input
/// </remarks> /// </remarks>
public class MouseButtonEventArgs : MouseEventArgs public class MouseButtonEventArgs : MouseEventArgs
{ {
MouseButton button;
/// <summary> /// <summary>
/// Constructs a new <see cref="MouseButtonEventArgs"/> instance. /// Constructs a new <see cref="MouseButtonEventArgs"/> instance.
/// </summary> /// </summary>
@ -217,7 +213,7 @@ namespace OpenTK.Input
public MouseButtonEventArgs(int x, int y, MouseButton button, bool pressed) public MouseButtonEventArgs(int x, int y, MouseButton button, bool pressed)
: base(x, y) : base(x, y)
{ {
this.button = button; this.Button = button;
this.IsPressed = pressed; this.IsPressed = pressed;
} }
@ -233,7 +229,7 @@ namespace OpenTK.Input
/// <summary> /// <summary>
/// Gets the <see cref="MouseButton"/> that triggered this event. /// Gets the <see cref="MouseButton"/> that triggered this event.
/// </summary> /// </summary>
public MouseButton Button { get { return button; } internal set { button = value; } } public MouseButton Button { get; internal set; }
/// <summary> /// <summary>
/// Gets a System.Boolean representing the state of the mouse button for the event. /// Gets a System.Boolean representing the state of the mouse button for the event.
@ -257,8 +253,6 @@ namespace OpenTK.Input
/// </remarks> /// </remarks>
public class MouseWheelEventArgs : MouseEventArgs public class MouseWheelEventArgs : MouseEventArgs
{ {
float delta;
/// <summary> /// <summary>
/// Constructs a new <see cref="MouseWheelEventArgs"/> instance. /// Constructs a new <see cref="MouseWheelEventArgs"/> instance.
/// </summary> /// </summary>
@ -275,7 +269,7 @@ namespace OpenTK.Input
: base(x, y) : base(x, y)
{ {
Mouse.SetScrollAbsolute(Mouse.Scroll.X, value); Mouse.SetScrollAbsolute(Mouse.Scroll.X, value);
this.delta = delta; this.DeltaPrecise = delta;
} }
/// <summary> /// <summary>
@ -297,7 +291,7 @@ namespace OpenTK.Input
/// Gets the change in value of the wheel for this event in integer units. /// Gets the change in value of the wheel for this event in integer units.
/// To support high-precision mice, it is recommended to use <see cref="DeltaPrecise"/> instead. /// To support high-precision mice, it is recommended to use <see cref="DeltaPrecise"/> instead.
/// </summary> /// </summary>
public int Delta { get { return (int)Math.Round(delta, MidpointRounding.AwayFromZero); } } public int Delta { get { return (int)Math.Round(DeltaPrecise, MidpointRounding.AwayFromZero); } }
/// <summary> /// <summary>
/// Gets the precise value of the wheel in floating-point units. /// Gets the precise value of the wheel in floating-point units.
@ -310,7 +304,7 @@ namespace OpenTK.Input
/// <summary> /// <summary>
/// Gets the precise change in value of the wheel for this event in floating-point units. /// Gets the precise change in value of the wheel for this event in floating-point units.
/// </summary> /// </summary>
public float DeltaPrecise { get { return delta; } internal set { delta = value; } } public float DeltaPrecise { get; internal set; }
} }
} }

View file

@ -38,7 +38,6 @@ namespace OpenTK.Input
Vector2 position; Vector2 position;
MouseScroll scroll; MouseScroll scroll;
ushort buttons; ushort buttons;
bool is_connected;
/// <summary> /// <summary>
/// Gets a <see cref="System.Boolean"/> indicating whether the specified /// Gets a <see cref="System.Boolean"/> indicating whether the specified
@ -191,11 +190,7 @@ namespace OpenTK.Input
/// Gets a value indicating whether this instance is connected. /// Gets a value indicating whether this instance is connected.
/// </summary> /// </summary>
/// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value> /// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value>
public bool IsConnected public bool IsConnected { get; internal set; }
{
get { return is_connected; }
internal set { is_connected = value; }
}
/// <summary> /// <summary>
/// Checks whether two <see cref="MouseState" /> instances are equal. /// Checks whether two <see cref="MouseState" /> instances are equal.

View file

@ -33,8 +33,6 @@ namespace OpenTK
/// </summary> /// </summary>
public class KeyPressEventArgs : EventArgs public class KeyPressEventArgs : EventArgs
{ {
char key_char;
/// <summary> /// <summary>
/// Constructs a new instance. /// Constructs a new instance.
/// </summary> /// </summary>
@ -47,10 +45,6 @@ namespace OpenTK
/// <summary> /// <summary>
/// Gets a <see cref="System.Char"/> that defines the ASCII character that was typed. /// Gets a <see cref="System.Char"/> that defines the ASCII character that was typed.
/// </summary> /// </summary>
public char KeyChar public char KeyChar { get; internal set; }
{
get { return key_char; }
internal set { key_char = value; }
}
} }
} }

View file

@ -34,13 +34,6 @@ namespace OpenTK
/// </summary> /// </summary>
public sealed class MouseCursor : WindowIcon public sealed class MouseCursor : WindowIcon
{ {
static readonly MouseCursor default_cursor = new MouseCursor();
static readonly MouseCursor empty_cursor = new MouseCursor(
0, 0, 16, 16, new byte[16 * 16 * 4]);
int x;
int y;
MouseCursor() MouseCursor()
{ {
} }
@ -71,8 +64,8 @@ namespace OpenTK
if (hotx < 0 || hotx >= Width || hoty < 0 || hoty >= Height) if (hotx < 0 || hotx >= Width || hoty < 0 || hoty >= Height)
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
x = hotx; X = hotx;
y = hoty; Y = hoty;
} }
/// <summary> /// <summary>
@ -100,34 +93,23 @@ namespace OpenTK
if (hotx < 0 || hotx >= Width || hoty < 0 || hoty >= Height) if (hotx < 0 || hotx >= Width || hoty < 0 || hoty >= Height)
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
x = hotx; X = hotx;
y = hoty; Y = hoty;
} }
internal int X { get { return x; } } internal int X { get; }
internal int Y { get { return y; } } internal int Y { get; }
/// <summary> /// <summary>
/// Gets the default mouse cursor for this platform. /// Gets the default mouse cursor for this platform.
/// </summary> /// </summary>
public static MouseCursor Default public static MouseCursor Default { get; } = new MouseCursor();
{
get
{
return default_cursor;
}
}
/// <summary> /// <summary>
/// Gets an empty (invisible) mouse cursor. /// Gets an empty (invisible) mouse cursor.
/// </summary> /// </summary>
public static MouseCursor Empty public static MouseCursor Empty { get; } = new MouseCursor(
{ 0, 0, 16, 16, new byte[16 * 16 * 4]);
get
{
return empty_cursor;
}
}
} }
} }

View file

@ -46,7 +46,7 @@ namespace OpenTK
private readonly INativeWindow implementation; private readonly INativeWindow implementation;
private bool disposed, events; private bool events;
private bool cursor_visible = true; private bool cursor_visible = true;
private bool previous_cursor_visible = true; private bool previous_cursor_visible = true;
@ -619,11 +619,7 @@ namespace OpenTK
/// Gets or sets a <see cref="System.Boolean"/>, which indicates whether /// Gets or sets a <see cref="System.Boolean"/>, which indicates whether
/// this instance has been disposed. /// this instance has been disposed.
/// </summary> /// </summary>
protected bool IsDisposed protected bool IsDisposed { get; set; }
{
get { return disposed; }
set { disposed = value; }
}
/// <summary> /// <summary>
/// Called when the NativeWindow has closed. /// Called when the NativeWindow has closed.

View file

@ -22,7 +22,6 @@ namespace OpenTK.Platform.Dummy
{ {
readonly GraphicsContext.GetAddressDelegate Loader; readonly GraphicsContext.GetAddressDelegate Loader;
int swap_interval;
static int handle_count; static int handle_count;
Thread current_thread; Thread current_thread;
@ -77,17 +76,7 @@ namespace OpenTK.Platform.Dummy
return Loader(str); return Loader(str);
} }
public override int SwapInterval public override int SwapInterval { get; set; }
{
get
{
return swap_interval;
}
set
{
swap_interval = value;
}
}
public override void Update(IWindowInfo window) public override void Update(IWindowInfo window)
{ } { }

View file

@ -53,18 +53,14 @@ namespace OpenTK.Platform.Egl
internal class AngleWindowInfo : IAngleWindowInfoInternal internal class AngleWindowInfo : IAngleWindowInfoInternal
{ {
private readonly IWindowInfo _platform_window;
private bool _disposed; private bool _disposed;
public AngleWindowInfo(IWindowInfo platform_window) public AngleWindowInfo(IWindowInfo platform_window)
{ {
_platform_window = platform_window; PlatformWindow = platform_window;
} }
public IWindowInfo PlatformWindow public IWindowInfo PlatformWindow { get; }
{
get { return _platform_window; }
}
public IWindowInfo WindowInfo public IWindowInfo WindowInfo
{ {
@ -75,7 +71,7 @@ namespace OpenTK.Platform.Egl
{ {
get get
{ {
var win_win = _platform_window as WinWindowInfo; var win_win = PlatformWindow as WinWindowInfo;
if (win_win != null) if (win_win != null)
{ {
return win_win.DeviceContext; return win_win.DeviceContext;
@ -104,7 +100,7 @@ namespace OpenTK.Platform.Egl
public IntPtr Handle public IntPtr Handle
{ {
get { return _platform_window.Handle; } get { return PlatformWindow.Handle; }
} }
~AngleWindowInfo() ~AngleWindowInfo()
@ -120,7 +116,7 @@ namespace OpenTK.Platform.Egl
} }
if (!called_from_finalizer) if (!called_from_finalizer)
{ {
_platform_window.Dispose(); PlatformWindow.Dispose();
} }
// dispose unmanaged // dispose unmanaged

View file

@ -34,8 +34,6 @@ namespace OpenTK.Platform.Egl
// Holds information about an EGL window. // Holds information about an EGL window.
class EglWindowInfo : IWindowInfo class EglWindowInfo : IWindowInfo
{ {
IntPtr handle;
IntPtr display;
IntPtr surface; IntPtr surface;
bool disposed; bool disposed;
@ -63,9 +61,9 @@ namespace OpenTK.Platform.Egl
} }
} }
public IntPtr Handle { get { return handle; } set { handle = value; } } public IntPtr Handle { get; set; }
public IntPtr Display { get { return display; } private set { display = value; } } public IntPtr Display { get; private set; }
public IntPtr Surface { get { return surface; } private set { surface = value; } } public IntPtr Surface { get { return surface; } private set { surface = value; } }

View file

@ -34,9 +34,6 @@ namespace OpenTK.Platform
sealed class Factory : IPlatformFactory sealed class Factory : IPlatformFactory
{ {
private bool disposed; private bool disposed;
private static IPlatformFactory defaultImplementation;
private static IPlatformFactory embeddedImplementation;
private static IPlatformFactory angleImplementation;
static Factory() static Factory()
{ {
@ -112,73 +109,61 @@ namespace OpenTK.Platform
Default = Embedded; Default = Embedded;
} }
public static IPlatformFactory Default public static IPlatformFactory Default { get; private set; }
{
get { return defaultImplementation; }
private set { defaultImplementation = value; }
}
public static IPlatformFactory Embedded public static IPlatformFactory Embedded { get; private set; }
{
get { return embeddedImplementation; }
private set { embeddedImplementation = value; }
}
public static IPlatformFactory Angle public static IPlatformFactory Angle { get; private set; }
{
get { return angleImplementation; }
private set { angleImplementation = value; }
}
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title,
GraphicsMode mode, GameWindowFlags options, DisplayDevice device) GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
{ {
return defaultImplementation.CreateNativeWindow(x, y, width, height, title, mode, options, device); return Default.CreateNativeWindow(x, y, width, height, title, mode, options, device);
} }
public IDisplayDeviceDriver CreateDisplayDeviceDriver() public IDisplayDeviceDriver CreateDisplayDeviceDriver()
{ {
return defaultImplementation.CreateDisplayDeviceDriver(); return Default.CreateDisplayDeviceDriver();
} }
public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags) public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
{ {
return defaultImplementation.CreateGLContext(mode, window, shareContext, directRendering, major, minor, flags); return Default.CreateGLContext(mode, window, shareContext, directRendering, major, minor, flags);
} }
public IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags) public IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
{ {
return defaultImplementation.CreateGLContext(handle, window, shareContext, directRendering, major, minor, flags); return Default.CreateGLContext(handle, window, shareContext, directRendering, major, minor, flags);
} }
public GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext() public GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
{ {
return defaultImplementation.CreateGetCurrentGraphicsContext(); return Default.CreateGetCurrentGraphicsContext();
} }
public IKeyboardDriver2 CreateKeyboardDriver() public IKeyboardDriver2 CreateKeyboardDriver()
{ {
return defaultImplementation.CreateKeyboardDriver(); return Default.CreateKeyboardDriver();
} }
public IMouseDriver2 CreateMouseDriver() public IMouseDriver2 CreateMouseDriver()
{ {
return defaultImplementation.CreateMouseDriver(); return Default.CreateMouseDriver();
} }
public IGamePadDriver CreateGamePadDriver() public IGamePadDriver CreateGamePadDriver()
{ {
return defaultImplementation.CreateGamePadDriver(); return Default.CreateGamePadDriver();
} }
public IJoystickDriver2 CreateJoystickDriver() public IJoystickDriver2 CreateJoystickDriver()
{ {
return defaultImplementation.CreateJoystickDriver(); return Default.CreateJoystickDriver();
} }
public void RegisterResource(IDisposable resource) public void RegisterResource(IDisposable resource)
{ {
defaultImplementation.RegisterResource(resource); Default.RegisterResource(resource);
} }
class UnsupportedPlatform : PlatformFactoryBase class UnsupportedPlatform : PlatformFactoryBase

View file

@ -214,14 +214,12 @@ namespace OpenTK.Platform.Linux
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
struct KeyboardEvent struct KeyboardEvent
{ {
IntPtr @event; public IntPtr BaseEvent { get { return GetBaseEvent(Event); } }
public IntPtr Event { get; }
public IntPtr BaseEvent { get { return GetBaseEvent(@event); } } public uint Time { get { return GetTime(Event); } }
public IntPtr Event { get { return @event; } } public uint Key { get { return GetKey(Event); } }
public uint Time { get { return GetTime(@event); } } public uint KeyCount { get { return GetSeatKeyCount(Event); } }
public uint Key { get { return GetKey(@event); } } public KeyState KeyState { get { return GetKeyState(Event); } }
public uint KeyCount { get { return GetSeatKeyCount(@event); } }
public KeyState KeyState { get { return GetKeyState(@event); } }
[DllImport(LibInput.lib, EntryPoint = "libinput_event_keyboard_get_time", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_keyboard_get_time", CallingConvention = CallingConvention.Cdecl)]
static extern uint GetTime(IntPtr @event); static extern uint GetTime(IntPtr @event);
@ -243,22 +241,20 @@ namespace OpenTK.Platform.Linux
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
struct PointerEvent struct PointerEvent
{ {
IntPtr @event; public IntPtr BaseEvent { get { return GetBaseEvent(Event); } }
public IntPtr Event { get; }
public IntPtr BaseEvent { get { return GetBaseEvent(@event); } } public uint Time { get { return GetTime(Event); } }
public IntPtr Event { get { return @event; } } public EvdevButton Button { get { return (EvdevButton)GetButton(Event); } }
public uint Time { get { return GetTime(@event); } } public uint ButtonCount { get { return GetButtonCount(Event); } }
public EvdevButton Button { get { return (EvdevButton)GetButton(@event); } } public ButtonState ButtonState { get { return GetButtonState(Event); } }
public uint ButtonCount { get { return GetButtonCount(@event); } } public bool HasAxis(PointerAxis axis) { return HasAxis(Event, axis) != 0; }
public ButtonState ButtonState { get { return GetButtonState(@event); } } public double AxisValue(PointerAxis axis) { return GetAxisValue(Event, axis); }
public bool HasAxis(PointerAxis axis) { return HasAxis(@event, axis) != 0; } public double DeltaX { get { return GetDX(Event); } }
public double AxisValue(PointerAxis axis) { return GetAxisValue(@event, axis); } public double DeltaY { get { return GetDY(Event); } }
public double DeltaX { get { return GetDX(@event); } } public double X { get { return GetAbsX(Event); } }
public double DeltaY { get { return GetDY(@event); } } public double Y { get { return GetAbsY(Event); } }
public double X { get { return GetAbsX(@event); } } public double TransformedX(int width) { return GetAbsXTransformed(Event, width); }
public double Y { get { return GetAbsY(@event); } } public double TransformedY(int height) { return GetAbsYTransformed(Event, height); }
public double TransformedX(int width) { return GetAbsXTransformed(@event, width); }
public double TransformedY(int height) { return GetAbsYTransformed(@event, height); }
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_time", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_time", CallingConvention = CallingConvention.Cdecl)]
static extern uint GetTime(IntPtr @event); static extern uint GetTime(IntPtr @event);

View file

@ -36,15 +36,8 @@ namespace OpenTK.Platform.MacOS
/// </summary> /// </summary>
sealed class CarbonWindowInfo : IWindowInfo sealed class CarbonWindowInfo : IWindowInfo
{ {
IntPtr windowRef;
bool ownHandle = false; bool ownHandle = false;
bool disposed = false; bool disposed = false;
bool isControl = true;
bool goFullScreenHack = false;
bool goWindowedHack = false;
GetInt xOffset;
GetInt yOffset;
/// <summary> /// <summary>
/// Constructs a new instance with the specified parameters. /// Constructs a new instance with the specified parameters.
@ -54,44 +47,30 @@ namespace OpenTK.Platform.MacOS
/// <param name="isControl"></param> /// <param name="isControl"></param>
public CarbonWindowInfo(IntPtr windowRef, bool ownHandle, bool isControl) public CarbonWindowInfo(IntPtr windowRef, bool ownHandle, bool isControl)
{ {
this.windowRef = windowRef; this.Handle = windowRef;
this.ownHandle = ownHandle; this.ownHandle = ownHandle;
this.isControl = isControl; this.IsControl = isControl;
} }
public CarbonWindowInfo(IntPtr windowRef, bool ownHandle, bool isControl, GetInt getX, GetInt getY) : this(windowRef, ownHandle, isControl) public CarbonWindowInfo(IntPtr windowRef, bool ownHandle, bool isControl, GetInt getX, GetInt getY) : this(windowRef, ownHandle, isControl)
{ {
this.xOffset = getX; this.XOffset = getX;
this.yOffset = getY; this.YOffset = getY;
} }
/// <summary> /// <summary>
/// Gets the window reference for this instance. /// Gets the window reference for this instance.
/// </summary> /// </summary>
public IntPtr Handle public IntPtr Handle { get; set; }
{
get { return this.windowRef; }
set { this.windowRef = value; }
}
internal bool GoFullScreenHack internal bool GoFullScreenHack { get; set; } = false;
{
get { return goFullScreenHack; } internal bool GoWindowedHack { get; set; } = false;
set { goFullScreenHack = value; }
}
internal bool GoWindowedHack
{
get { return goWindowedHack; }
set { goWindowedHack = value; }
}
/// <summary> /// <summary>
/// Gets a value indicating whether this instance refers to a System.Windows.Forms.Control. /// Gets a value indicating whether this instance refers to a System.Windows.Forms.Control.
/// </summary> /// </summary>
public bool IsControl public bool IsControl { get; } = true;
{
get { return isControl; }
}
/// <summary>Returns a System.String that represents the current window.</summary> /// <summary>Returns a System.String that represents the current window.</summary>
/// <returns>A System.String that represents the current window.</returns> /// <returns>A System.String that represents the current window.</returns>
@ -105,16 +84,10 @@ namespace OpenTK.Platform.MacOS
// (e.g. MonoGame) // (e.g. MonoGame)
public IntPtr WindowHandle { get { return Handle; } set { Handle = value; } } public IntPtr WindowHandle { get { return Handle; } set { Handle = value; } }
public GetInt XOffset public GetInt XOffset { get; set; }
{
get { return xOffset; } public GetInt YOffset { get; set; }
set { xOffset = value; }
}
public GetInt YOffset
{
get { return yOffset; }
set { yOffset = value; }
}
public void Dispose() public void Dispose()
{ {
Dispose(true); Dispose(true);
@ -132,7 +105,7 @@ namespace OpenTK.Platform.MacOS
if (ownHandle) if (ownHandle)
{ {
windowRef = IntPtr.Zero; Handle = IntPtr.Zero;
} }
disposed = true; disposed = true;

View file

@ -41,33 +41,27 @@ namespace OpenTK.Platform.MacOS
// However, NSFloat is used internally in places where this precision loss does not matter. // However, NSFloat is used internally in places where this precision loss does not matter.
struct NSFloat struct NSFloat
{ {
IntPtr value; private IntPtr _value;
public IntPtr Value public IntPtr Value
{ {
get get { return _value; }
{ set { _value = value; }
return value;
}
set
{
this.value = value;
}
} }
public static implicit operator NSFloat(float v) public static implicit operator NSFloat(float v)
{ {
NSFloat f; NSFloat f = new NSFloat();
unsafe unsafe
{ {
if (IntPtr.Size == 4) if (IntPtr.Size == 4)
{ {
f.value = *(IntPtr*)&v; f.Value = *(IntPtr*)&v;
} }
else else
{ {
double d = v; double d = v;
f.value = *(IntPtr*)&d; f.Value = *(IntPtr*)&d;
} }
} }
return f; return f;
@ -75,17 +69,17 @@ namespace OpenTK.Platform.MacOS
public static implicit operator NSFloat(double v) public static implicit operator NSFloat(double v)
{ {
NSFloat f; NSFloat f = new NSFloat();
unsafe unsafe
{ {
if (IntPtr.Size == 4) if (IntPtr.Size == 4)
{ {
float fv = (float)v; float fv = (float)v;
f.value = *(IntPtr*)&fv; f.Value = *(IntPtr*)&fv;
} }
else else
{ {
f.value = *(IntPtr*)&v; f.Value = *(IntPtr*)&v;
} }
} }
return f; return f;
@ -97,11 +91,11 @@ namespace OpenTK.Platform.MacOS
{ {
if (IntPtr.Size == 4) if (IntPtr.Size == 4)
{ {
return *(float*)&f.value; return *(float*)f._value;
} }
else else
{ {
return (float)*(double*)&f.value; return (float)*(double*)&f._value;
} }
} }
} }
@ -112,11 +106,11 @@ namespace OpenTK.Platform.MacOS
{ {
if (IntPtr.Size == 4) if (IntPtr.Size == 4)
{ {
return (double)*(float*)&f.value; return (double)*(float*)&f._value;
} }
else else
{ {
return *(double*)&f.value; return *(double*)&f._value;
} }
} }
} }

View file

@ -40,9 +40,6 @@ namespace OpenTK.Platform.MacOS
{ {
static readonly IntPtr selContentView = Selector.Get("contentView"); static readonly IntPtr selContentView = Selector.Get("contentView");
IntPtr nsWindowRef;
IntPtr nsViewRef;
bool disposed = false; bool disposed = false;
/// <summary> /// <summary>
@ -62,26 +59,26 @@ namespace OpenTK.Platform.MacOS
/// <param name="nsViewRef">A valid NSView reference.</param> /// <param name="nsViewRef">A valid NSView reference.</param>
public CocoaWindowInfo(IntPtr nsWindowRef, IntPtr nsViewRef) public CocoaWindowInfo(IntPtr nsWindowRef, IntPtr nsViewRef)
{ {
this.nsWindowRef = nsWindowRef; this.Handle = nsWindowRef;
this.nsViewRef = nsViewRef; this.ViewHandle = nsViewRef;
Cocoa.SendVoid(nsWindowRef, Selector.Retain); Cocoa.SendVoid(nsWindowRef, Selector.Retain);
} }
/// <summary> /// <summary>
/// Gets the window reference for this instance. /// Gets the window reference for this instance.
/// </summary> /// </summary>
public IntPtr Handle { get { return nsWindowRef; } } public IntPtr Handle { get; }
/// <summary> /// <summary>
/// Gets the view reference for this instance. /// Gets the view reference for this instance.
/// </summary> /// </summary>
public IntPtr ViewHandle { get { return nsViewRef; } } public IntPtr ViewHandle { get; }
/// <summary>Returns a System.String that represents the current window.</summary> /// <summary>Returns a System.String that represents the current window.</summary>
/// <returns>A System.String that represents the current window.</returns> /// <returns>A System.String that represents the current window.</returns>
public override string ToString() public override string ToString()
{ {
return String.Format("MacOS.CocoaWindowInfo: NSWindow {0}, NSView {1}", nsWindowRef, nsViewRef); return String.Format("MacOS.CocoaWindowInfo: NSWindow {0}, NSView {1}", Handle, ViewHandle);
} }
public void Dispose() public void Dispose()
@ -96,11 +93,11 @@ namespace OpenTK.Platform.MacOS
if (disposing) if (disposing)
{ {
Cocoa.SendVoid(nsWindowRef, Selector.Release); Cocoa.SendVoid(Handle, Selector.Release);
} }
else else
{ {
Debug.Print("CocoaWindowInfo:{0} leaked, did you forget to call Dispose()?", nsWindowRef); Debug.Print("CocoaWindowInfo:{0} leaked, did you forget to call Dispose()?", Handle);
} }
disposed = true; disposed = true;

View file

@ -31,30 +31,25 @@ namespace OpenTK.Platform.MacOS
{ {
internal class MacOSException : Exception internal class MacOSException : Exception
{ {
OSStatus errorCode;
public MacOSException() public MacOSException()
{} {}
public MacOSException(OSStatus errorCode) public MacOSException(OSStatus errorCode)
: base("Error Code " + ((int)errorCode).ToString() + ": " + errorCode.ToString()) : base("Error Code " + ((int)errorCode).ToString() + ": " + errorCode.ToString())
{ {
this.errorCode = errorCode; this.ErrorCode = errorCode;
} }
public MacOSException(OSStatus errorCode, string message) public MacOSException(OSStatus errorCode, string message)
: base(message) : base(message)
{ {
this.errorCode = errorCode; this.ErrorCode = errorCode;
} }
internal MacOSException(int errorCode, string message) internal MacOSException(int errorCode, string message)
: base(message) : base(message)
{ {
this.errorCode = (OSStatus)errorCode; this.ErrorCode = (OSStatus)errorCode;
} }
public OSStatus ErrorCode public OSStatus ErrorCode { get; }
{
get { return errorCode; }
}
} }
internal enum OSStatus internal enum OSStatus

View file

@ -41,17 +41,16 @@ namespace OpenTK.Platform.MacOS.Carbon
struct CFArray struct CFArray
{ {
IntPtr arrayRef; public IntPtr Ref { get; set; }
public IntPtr Ref { get { return arrayRef; } set { arrayRef = value; } }
public CFArray(IntPtr reference) public CFArray(IntPtr reference)
{ {
arrayRef = reference; Ref = reference;
} }
public int Count public int Count
{ {
get { return CF.CFArrayGetCount(arrayRef); } get { return CF.CFArrayGetCount(Ref); }
} }
public IntPtr this[int index] public IntPtr this[int index]
{ {
@ -60,7 +59,7 @@ namespace OpenTK.Platform.MacOS.Carbon
if (index >= Count || index < 0) if (index >= Count || index < 0)
throw new IndexOutOfRangeException(); throw new IndexOutOfRangeException();
return CF.CFArrayGetValueAtIndex(arrayRef, index); return CF.CFArrayGetValueAtIndex(Ref, index);
} }
} }
} }
@ -69,24 +68,23 @@ namespace OpenTK.Platform.MacOS.Carbon
{ {
public CFDictionary(IntPtr reference) public CFDictionary(IntPtr reference)
{ {
dictionaryRef = reference; Ref = reference;
} }
IntPtr dictionaryRef; public IntPtr Ref { get; set; }
public IntPtr Ref { get { return dictionaryRef; } set { dictionaryRef = value; } }
public int Count public int Count
{ {
get get
{ {
return CF.CFDictionaryGetCount(dictionaryRef); return CF.CFDictionaryGetCount(Ref);
} }
} }
public double GetNumberValue(string key) public double GetNumberValue(string key)
{ {
double retval; double retval;
IntPtr cfnum = CF.CFDictionaryGetValue(dictionaryRef, IntPtr cfnum = CF.CFDictionaryGetValue(Ref,
CF.CFSTR(key)); CF.CFSTR(key));
CF.CFNumberGetValue(cfnum, CF.CFNumberType.kCFNumberDoubleType, out retval); CF.CFNumberGetValue(cfnum, CF.CFNumberType.kCFNumberDoubleType, out retval);

View file

@ -23,7 +23,6 @@ namespace OpenTK.Platform.Windows
{ {
static readonly object LoadLock = new object(); static readonly object LoadLock = new object();
IntPtr device_context;
bool vsync_supported; bool vsync_supported;
bool vsync_tear_supported; bool vsync_tear_supported;
@ -262,12 +261,12 @@ namespace OpenTK.Platform.Windows
throw new ArgumentException("window", "Must point to a valid window."); throw new ArgumentException("window", "Must point to a valid window.");
success = Wgl.MakeCurrent(wnd.DeviceContext, Handle.Handle); success = Wgl.MakeCurrent(wnd.DeviceContext, Handle.Handle);
device_context = wnd.DeviceContext; DeviceContext = wnd.DeviceContext;
} }
else else
{ {
success = Wgl.MakeCurrent(IntPtr.Zero, IntPtr.Zero); success = Wgl.MakeCurrent(IntPtr.Zero, IntPtr.Zero);
device_context = IntPtr.Zero; DeviceContext = IntPtr.Zero;
} }
if (!success) if (!success)
@ -387,13 +386,7 @@ namespace OpenTK.Platform.Windows
return mode; return mode;
} }
internal IntPtr DeviceContext internal IntPtr DeviceContext { get; private set; }
{
get
{
return device_context;
}
}
/// <summary>Returns a System.String describing this OpenGL context.</summary> /// <summary>Returns a System.String describing this OpenGL context.</summary>
/// <returns>A System.String describing this OpenGL context.</returns> /// <returns>A System.String describing this OpenGL context.</returns>

View file

@ -38,9 +38,9 @@ namespace OpenTK.Platform.Windows
readonly AutoResetEvent InputReady = new AutoResetEvent(false); readonly AutoResetEvent InputReady = new AutoResetEvent(false);
IntPtr OldWndProc; IntPtr OldWndProc;
INativeWindow native;
protected INativeWindow Native { get { return native; } private set { native = value; } } protected INativeWindow Native { get; private set; }
protected WinWindowInfo Parent { get { return (WinWindowInfo)Native.WindowInfo; } } protected WinWindowInfo Parent { get { return (WinWindowInfo)Native.WindowInfo; } }
static readonly IntPtr Unhandled = new IntPtr(-1); static readonly IntPtr Unhandled = new IntPtr(-1);

View file

@ -36,7 +36,6 @@ namespace OpenTK.Platform.Windows
sealed class WinWindowInfo : IWindowInfo sealed class WinWindowInfo : IWindowInfo
{ {
IntPtr handle, dc; IntPtr handle, dc;
WinWindowInfo parent;
bool disposed; bool disposed;
/// <summary> /// <summary>
@ -54,7 +53,7 @@ namespace OpenTK.Platform.Windows
public WinWindowInfo(IntPtr handle, WinWindowInfo parent) public WinWindowInfo(IntPtr handle, WinWindowInfo parent)
{ {
this.handle = handle; this.handle = handle;
this.parent = parent; this.Parent = parent;
} }
/// <summary> /// <summary>
@ -65,7 +64,7 @@ namespace OpenTK.Platform.Windows
/// <summary> /// <summary>
/// Gets or sets the Parent of the window (may be null). /// Gets or sets the Parent of the window (may be null).
/// </summary> /// </summary>
public WinWindowInfo Parent { get { return parent; } set { parent = value; } } public WinWindowInfo Parent { get; set; }
/// <summary> /// <summary>
/// Gets the device context for this window instance. /// Gets the device context for this window instance.
@ -132,8 +131,8 @@ namespace OpenTK.Platform.Windows
if (manual) if (manual)
{ {
if (parent != null) if (Parent != null)
parent.Dispose(); Parent.Dispose();
} }
disposed = true; disposed = true;

View file

@ -67,15 +67,14 @@ namespace OpenTK.Platform.X11
private const string _dll_name = "libX11"; private const string _dll_name = "libX11";
private const string _dll_name_vid = "libXxf86vm"; private const string _dll_name_vid = "libXxf86vm";
static Display defaultDisplay;
static int defaultScreen;
static Window rootWindow; static Window rootWindow;
static int screenCount;
internal static Display DefaultDisplay { get { return defaultDisplay; } } internal static Display DefaultDisplay { get; private set; }
static int DefaultScreen { get { return defaultScreen; } }
private static int DefaultScreen { get; set; }
//internal static Window RootWindow { get { return rootWindow; } } //internal static Window RootWindow { get { return rootWindow; } }
internal static int ScreenCount { get { return screenCount; } } internal static int ScreenCount { get; }
internal static object Lock = new object(); internal static object Lock = new object();
@ -84,14 +83,14 @@ namespace OpenTK.Platform.X11
int has_threaded_x = Functions.XInitThreads(); int has_threaded_x = Functions.XInitThreads();
Debug.Print("Initializing threaded X11: {0}.", has_threaded_x.ToString()); Debug.Print("Initializing threaded X11: {0}.", has_threaded_x.ToString());
defaultDisplay = Functions.XOpenDisplay(IntPtr.Zero); DefaultDisplay = Functions.XOpenDisplay(IntPtr.Zero);
if (defaultDisplay == IntPtr.Zero) if (DefaultDisplay == IntPtr.Zero)
throw new PlatformException("Could not establish connection to the X-Server."); throw new PlatformException("Could not establish connection to the X-Server.");
using (new XLock(defaultDisplay)) using (new XLock(DefaultDisplay))
{ {
screenCount = Functions.XScreenCount(DefaultDisplay); ScreenCount = Functions.XScreenCount(DefaultDisplay);
} }
Debug.Print("Display connection: {0}, Screen count: {1}", DefaultDisplay, ScreenCount); Debug.Print("Display connection: {0}, Screen count: {1}", DefaultDisplay, ScreenCount);
@ -100,11 +99,11 @@ namespace OpenTK.Platform.X11
static void CurrentDomain_ProcessExit(object sender, EventArgs e) static void CurrentDomain_ProcessExit(object sender, EventArgs e)
{ {
if (defaultDisplay != IntPtr.Zero) if (DefaultDisplay != IntPtr.Zero)
{ {
Functions.XCloseDisplay(defaultDisplay); Functions.XCloseDisplay(DefaultDisplay);
defaultDisplay = IntPtr.Zero; DefaultDisplay = IntPtr.Zero;
defaultScreen = 0; DefaultScreen = 0;
rootWindow = IntPtr.Zero; rootWindow = IntPtr.Zero;
} }
} }

View file

@ -36,7 +36,6 @@ namespace OpenTK.Platform.X11
readonly X11Mouse mouse = new X11Mouse(); readonly X11Mouse mouse = new X11Mouse();
readonly X11Keyboard keyboard = new X11Keyboard(); readonly X11Keyboard keyboard = new X11Keyboard();
readonly Linux.LinuxJoystick joystick = new Linux.LinuxJoystick(); readonly Linux.LinuxJoystick joystick = new Linux.LinuxJoystick();
readonly IGamePadDriver gamepad = new MappedGamePadDriver();
internal X11Input() internal X11Input()
{ {
@ -61,13 +60,7 @@ namespace OpenTK.Platform.X11
} }
} }
public IGamePadDriver GamePadDriver public IGamePadDriver GamePadDriver { get; } = new MappedGamePadDriver();
{
get
{
return gamepad;
}
}
public IJoystickDriver2 JoystickDriver public IJoystickDriver2 JoystickDriver
{ {

View file

@ -34,11 +34,8 @@ namespace OpenTK.Platform.X11
/// <summary>Describes an X11 window.</summary> /// <summary>Describes an X11 window.</summary>
sealed class X11WindowInfo : IWindowInfo sealed class X11WindowInfo : IWindowInfo
{ {
IntPtr handle, rootWindow, display; IntPtr handle, display;
X11WindowInfo parent;
int screen;
XVisualInfo visualInfo; XVisualInfo visualInfo;
EventMask eventMask;
/// <summary>Constructs a new X11WindowInfo class.</summary> /// <summary>Constructs a new X11WindowInfo class.</summary>
public X11WindowInfo() { } public X11WindowInfo() { }
@ -51,12 +48,12 @@ namespace OpenTK.Platform.X11
public X11WindowInfo(IntPtr handle, X11WindowInfo parent) public X11WindowInfo(IntPtr handle, X11WindowInfo parent)
{ {
this.handle = handle; this.handle = handle;
this.parent = parent; this.Parent = parent;
if (parent != null) if (parent != null)
{ {
this.rootWindow = parent.rootWindow; this.RootWindow = parent.RootWindow;
this.display = parent.display; this.display = parent.display;
this.screen = parent.screen; this.Screen = parent.Screen;
this.visualInfo = parent.visualInfo; this.visualInfo = parent.visualInfo;
} }
} }
@ -64,13 +61,16 @@ namespace OpenTK.Platform.X11
/// <summary>Gets or sets the handle of the window.</summary> /// <summary>Gets or sets the handle of the window.</summary>
public IntPtr Handle { get { return handle; } set { handle = value; } } public IntPtr Handle { get { return handle; } set { handle = value; } }
/// <summary>Gets or sets the parent of the window.</summary> /// <summary>Gets or sets the parent of the window.</summary>
public X11WindowInfo Parent { get { return parent; } set { parent = value; } } public X11WindowInfo Parent { get; set; }
/// <summary>Gets or sets the X11 root window.</summary> /// <summary>Gets or sets the X11 root window.</summary>
public IntPtr RootWindow { get { return rootWindow; } set { rootWindow = value; } } public IntPtr RootWindow { get; set; }
/// <summary>Gets or sets the connection to the X11 display.</summary> /// <summary>Gets or sets the connection to the X11 display.</summary>
public IntPtr Display { get { return display; } set { display = value; } } public IntPtr Display { get { return display; } set { display = value; } }
/// <summary>Gets or sets the X11 screen.</summary> /// <summary>Gets or sets the X11 screen.</summary>
public int Screen { get { return screen; } set { screen = value; } } public int Screen { get; set; }
/// <summary>Gets or sets the X11 VisualInfo.</summary> /// <summary>Gets or sets the X11 VisualInfo.</summary>
public XVisualInfo VisualInfo public XVisualInfo VisualInfo
{ {
@ -84,7 +84,7 @@ namespace OpenTK.Platform.X11
} }
} }
/// <summary>Gets or sets the X11 EventMask.</summary> /// <summary>Gets or sets the X11 EventMask.</summary>
public EventMask EventMask { get { return eventMask; } set { eventMask = value; } } public EventMask EventMask { get; set; }
// For compatibility with whoever thought it would be // For compatibility with whoever thought it would be
// a good idea to access internal APIs through reflection // a good idea to access internal APIs through reflection

View file

@ -35,7 +35,6 @@ namespace OpenTK.Platform.X11
{ {
readonly XI2MouseKeyboard mouse_keyboard = new XI2MouseKeyboard(); readonly XI2MouseKeyboard mouse_keyboard = new XI2MouseKeyboard();
readonly Linux.LinuxJoystick joystick = new Linux.LinuxJoystick(); readonly Linux.LinuxJoystick joystick = new Linux.LinuxJoystick();
readonly IGamePadDriver gamepad = new MappedGamePadDriver();
internal XI2Input() internal XI2Input()
{ {
@ -58,13 +57,7 @@ namespace OpenTK.Platform.X11
} }
} }
public IGamePadDriver GamePadDriver public IGamePadDriver GamePadDriver { get; } = new MappedGamePadDriver();
{
get
{
return gamepad;
}
}
public IJoystickDriver2 JoystickDriver public IJoystickDriver2 JoystickDriver
{ {

View file

@ -36,10 +36,6 @@ namespace OpenTK
/// </summary> /// </summary>
public class WindowIcon public class WindowIcon
{ {
byte[] data;
int width;
int height;
/// \internal /// \internal
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="OpenTK.WindowIcon"/> class. /// Initializes a new instance of the <see cref="OpenTK.WindowIcon"/> class.
@ -53,8 +49,8 @@ namespace OpenTK
if (width < 0 || width > 256 || height < 0 || height > 256) if (width < 0 || width > 256 || height < 0 || height > 256)
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
this.width = width; this.Width = width;
this.height = height; this.Height = height;
} }
internal WindowIcon(int width, int height, byte[] data) internal WindowIcon(int width, int height, byte[] data)
@ -65,7 +61,7 @@ namespace OpenTK
if (data.Length < Width * Height * 4) if (data.Length < Width * Height * 4)
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
this.data = data; this.Data = data;
} }
internal WindowIcon(int width, int height, IntPtr data) internal WindowIcon(int width, int height, IntPtr data)
@ -77,13 +73,13 @@ namespace OpenTK
// We assume that width and height are correctly set. // We assume that width and height are correctly set.
// If they are not, we will read garbage and probably // If they are not, we will read garbage and probably
// crash. // crash.
this.data = new byte[width * height * 4]; this.Data = new byte[width * height * 4];
Marshal.Copy(data, this.data, 0, this.data.Length); Marshal.Copy(data, this.Data, 0, this.Data.Length);
} }
internal byte[] Data { get { return data; } } internal byte[] Data { get; }
internal int Width { get { return width; } } internal int Width { get; }
internal int Height { get { return height; } } internal int Height { get; }
} }
} }