mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-05 23:10:46 +00:00
Enforced the use of braces for conditional statements.
This commit is contained in:
parent
52699104f9
commit
4f60f95607
|
@ -60,7 +60,9 @@ namespace Bind
|
||||||
public void Unindent()
|
public void Unindent()
|
||||||
{
|
{
|
||||||
if (indent_level > 0)
|
if (indent_level > 0)
|
||||||
|
{
|
||||||
--indent_level;
|
--indent_level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(WriteOptions options, string value)
|
public void Write(WriteOptions options, string value)
|
||||||
|
@ -144,7 +146,9 @@ namespace Bind
|
||||||
if (options != WriteOptions.NoIndent)
|
if (options != WriteOptions.NoIndent)
|
||||||
{
|
{
|
||||||
for (int i = indent_level; i > 0; i--)
|
for (int i = indent_level; i > 0; i--)
|
||||||
|
{
|
||||||
sw.Write(" ");
|
sw.Write(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,9 @@ namespace Bind
|
||||||
int top = Console.CursorTop;
|
int top = Console.CursorTop;
|
||||||
Console.Write(text);
|
Console.Write(text);
|
||||||
for (int i = text.Length; i < 80; i++)
|
for (int i = text.Length; i < 80; i++)
|
||||||
|
{
|
||||||
Console.Write(" ");
|
Console.Write(" ");
|
||||||
|
}
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.SetCursorPosition(left, top);
|
Console.SetCursorPosition(left, top);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +65,9 @@ namespace Bind
|
||||||
{
|
{
|
||||||
Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
|
Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
|
||||||
if (!Directory.Exists(Settings.OutputPath))
|
if (!Directory.Exists(Settings.OutputPath))
|
||||||
|
{
|
||||||
Directory.CreateDirectory(Settings.OutputPath);
|
Directory.CreateDirectory(Settings.OutputPath);
|
||||||
|
}
|
||||||
|
|
||||||
string temp_enums_file = Path.GetTempFileName();
|
string temp_enums_file = Path.GetTempFileName();
|
||||||
string temp_wrappers_file = Path.GetTempFileName();
|
string temp_wrappers_file = Path.GetTempFileName();
|
||||||
|
@ -84,7 +88,9 @@ namespace Bind
|
||||||
sw.WriteLine("static partial class {0}", Settings.OutputClass);
|
sw.WriteLine("static partial class {0}", Settings.OutputClass);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sw.WriteLine("namespace {0}", Settings.EnumsOutput);
|
sw.WriteLine("namespace {0}", Settings.EnumsOutput);
|
||||||
|
}
|
||||||
|
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
|
|
||||||
|
@ -124,10 +130,22 @@ namespace Bind
|
||||||
string output_core = Path.Combine(Settings.OutputPath, Settings.ImportsFile);
|
string output_core = Path.Combine(Settings.OutputPath, Settings.ImportsFile);
|
||||||
string output_wrappers = Path.Combine(Settings.OutputPath, Settings.WrappersFile);
|
string output_wrappers = Path.Combine(Settings.OutputPath, Settings.WrappersFile);
|
||||||
|
|
||||||
if (File.Exists(output_enums)) File.Delete(output_enums);
|
if (File.Exists(output_enums))
|
||||||
if (File.Exists(output_delegates)) File.Delete(output_delegates);
|
{
|
||||||
if (File.Exists(output_core)) File.Delete(output_core);
|
File.Delete(output_enums);
|
||||||
if (File.Exists(output_wrappers)) File.Delete(output_wrappers);
|
}
|
||||||
|
if (File.Exists(output_delegates))
|
||||||
|
{
|
||||||
|
File.Delete(output_delegates);
|
||||||
|
}
|
||||||
|
if (File.Exists(output_core))
|
||||||
|
{
|
||||||
|
File.Delete(output_core);
|
||||||
|
}
|
||||||
|
if (File.Exists(output_wrappers))
|
||||||
|
{
|
||||||
|
File.Delete(output_wrappers);
|
||||||
|
}
|
||||||
|
|
||||||
File.Move(temp_enums_file, output_enums);
|
File.Move(temp_enums_file, output_enums);
|
||||||
File.Move(temp_wrappers_file, output_wrappers);
|
File.Move(temp_wrappers_file, output_wrappers);
|
||||||
|
@ -296,9 +314,13 @@ namespace Bind
|
||||||
else if (!String.IsNullOrEmpty(f.Version))
|
else if (!String.IsNullOrEmpty(f.Version))
|
||||||
{
|
{
|
||||||
if (f.Category.StartsWith("VERSION"))
|
if (f.Category.StartsWith("VERSION"))
|
||||||
|
{
|
||||||
category = String.Format("[requires: {0}]", "v" + f.Version);
|
category = String.Format("[requires: {0}]", "v" + f.Version);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
category = String.Format("[requires: {0}]", "v" + f.Version + " or " + f.Category);
|
category = String.Format("[requires: {0}]", "v" + f.Version + " or " + f.Category);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write function summary
|
// Write function summary
|
||||||
|
@ -413,7 +435,9 @@ namespace Bind
|
||||||
|
|
||||||
sw.Write(str);
|
sw.Write(str);
|
||||||
if (!String.IsNullOrEmpty(str))
|
if (!String.IsNullOrEmpty(str))
|
||||||
|
{
|
||||||
sw.WriteLine(",");
|
sw.WriteLine(",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,9 +448,13 @@ namespace Bind
|
||||||
//sw.WriteLine();
|
//sw.WriteLine();
|
||||||
|
|
||||||
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
|
if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
|
||||||
|
{
|
||||||
Trace.WriteLine(String.Format("Writing enums to:\t{0}.{1}.{2}", Settings.OutputNamespace, Settings.OutputClass, Settings.NestedEnumsClass));
|
Trace.WriteLine(String.Format("Writing enums to:\t{0}.{1}.{2}", Settings.OutputNamespace, Settings.OutputClass, Settings.NestedEnumsClass));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Trace.WriteLine(String.Format("Writing enums to:\t{0}", Settings.EnumsOutput));
|
Trace.WriteLine(String.Format("Writing enums to:\t{0}", Settings.EnumsOutput));
|
||||||
|
}
|
||||||
|
|
||||||
if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) == Settings.Legacy.None)
|
if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) == Settings.Legacy.None)
|
||||||
{
|
{
|
||||||
|
@ -480,11 +508,17 @@ namespace Bind
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@enum.IsObsolete)
|
if (@enum.IsObsolete)
|
||||||
|
{
|
||||||
sw.WriteLine("[Obsolete(\"{0}\")]", @enum.Obsolete);
|
sw.WriteLine("[Obsolete(\"{0}\")]", @enum.Obsolete);
|
||||||
|
}
|
||||||
if (!@enum.CLSCompliant)
|
if (!@enum.CLSCompliant)
|
||||||
|
{
|
||||||
sw.WriteLine("[CLSCompliant(false)]");
|
sw.WriteLine("[CLSCompliant(false)]");
|
||||||
|
}
|
||||||
if (@enum.IsFlagCollection)
|
if (@enum.IsFlagCollection)
|
||||||
|
{
|
||||||
sw.WriteLine("[Flags]");
|
sw.WriteLine("[Flags]");
|
||||||
|
}
|
||||||
sw.WriteLine("public enum " + @enum.Name + " : " + @enum.Type);
|
sw.WriteLine("public enum " + @enum.Name + " : " + @enum.Type);
|
||||||
sw.WriteLine("{");
|
sw.WriteLine("{");
|
||||||
sw.Indent();
|
sw.Indent();
|
||||||
|
@ -561,7 +595,9 @@ namespace Bind
|
||||||
|
|
||||||
sb.Append(d.Unsafe ? "unsafe " : "");
|
sb.Append(d.Unsafe ? "unsafe " : "");
|
||||||
if (is_delegate)
|
if (is_delegate)
|
||||||
|
{
|
||||||
sb.Append("delegate ");
|
sb.Append("delegate ");
|
||||||
|
}
|
||||||
sb.Append(GetDeclarationString(d.ReturnType, Settings.Legacy.ConstIntEnums));
|
sb.Append(GetDeclarationString(d.ReturnType, Settings.Legacy.ConstIntEnums));
|
||||||
sb.Append(" ");
|
sb.Append(" ");
|
||||||
sb.Append(Settings.FunctionPrefix);
|
sb.Append(Settings.FunctionPrefix);
|
||||||
|
@ -579,12 +615,16 @@ namespace Bind
|
||||||
{
|
{
|
||||||
int ret = String.Compare(c1.Value, c2.Value);
|
int ret = String.Compare(c1.Value, c2.Value);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
{
|
||||||
return String.Compare(c1.Name, c2.Name);
|
return String.Compare(c1.Name, c2.Name);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (e.IsFlagCollection)
|
if (e.IsFlagCollection)
|
||||||
|
{
|
||||||
sb.AppendLine("[Flags]");
|
sb.AppendLine("[Flags]");
|
||||||
|
}
|
||||||
sb.Append("public enum ");
|
sb.Append("public enum ");
|
||||||
sb.Append(e.Name);
|
sb.Append(e.Name);
|
||||||
sb.Append(" : ");
|
sb.Append(" : ");
|
||||||
|
@ -597,7 +637,9 @@ namespace Bind
|
||||||
sb.Append(" ");
|
sb.Append(" ");
|
||||||
sb.Append(declaration);
|
sb.Append(declaration);
|
||||||
if (!String.IsNullOrEmpty(declaration))
|
if (!String.IsNullOrEmpty(declaration))
|
||||||
|
{
|
||||||
sb.AppendLine(",");
|
sb.AppendLine(",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.Append("}");
|
sb.Append("}");
|
||||||
|
|
||||||
|
@ -640,7 +682,9 @@ namespace Bind
|
||||||
foreach (Parameter p in f.Parameters)
|
foreach (Parameter p in f.Parameters)
|
||||||
{
|
{
|
||||||
if (p.Generic)
|
if (p.Generic)
|
||||||
|
{
|
||||||
sb.AppendLine(String.Format(" where {0} : struct", p.CurrentType));
|
sb.AppendLine(String.Format(" where {0} : struct", p.CurrentType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,16 +696,24 @@ namespace Bind
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (p.Flow == FlowDirection.Out)
|
if (p.Flow == FlowDirection.Out)
|
||||||
|
{
|
||||||
sb.Append("[OutAttribute] ");
|
sb.Append("[OutAttribute] ");
|
||||||
|
}
|
||||||
else if (p.Flow == FlowDirection.Undefined)
|
else if (p.Flow == FlowDirection.Undefined)
|
||||||
|
{
|
||||||
sb.Append("[InAttribute, OutAttribute] ");
|
sb.Append("[InAttribute, OutAttribute] ");
|
||||||
|
}
|
||||||
|
|
||||||
if (p.Reference)
|
if (p.Reference)
|
||||||
{
|
{
|
||||||
if (p.Flow == FlowDirection.Out)
|
if (p.Flow == FlowDirection.Out)
|
||||||
|
{
|
||||||
sb.Append("out ");
|
sb.Append("out ");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sb.Append("ref ");
|
sb.Append("ref ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!override_unsafe_setting && ((Settings.Compatibility & Settings.Legacy.NoPublicUnsafeFunctions) != Settings.Legacy.None))
|
if (!override_unsafe_setting && ((Settings.Compatibility & Settings.Legacy.NoPublicUnsafeFunctions) != Settings.Legacy.None))
|
||||||
|
|
|
@ -42,7 +42,9 @@ namespace Bind
|
||||||
public DocProcessor(IBind generator)
|
public DocProcessor(IBind generator)
|
||||||
{
|
{
|
||||||
if (generator == null)
|
if (generator == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
Generator = generator;
|
Generator = generator;
|
||||||
foreach (string file in Directory.GetFiles(Settings.DocPath).Concat(
|
foreach (string file in Directory.GetFiles(Settings.DocPath).Concat(
|
||||||
|
@ -68,9 +70,13 @@ namespace Bind
|
||||||
{
|
{
|
||||||
var file = Settings.FunctionPrefix + f.WrappedDelegate.Name + ".xml";
|
var file = Settings.FunctionPrefix + f.WrappedDelegate.Name + ".xml";
|
||||||
if (!DocumentationFiles.ContainsKey(file))
|
if (!DocumentationFiles.ContainsKey(file))
|
||||||
|
{
|
||||||
file = Settings.FunctionPrefix + f.TrimmedName + ".xml";
|
file = Settings.FunctionPrefix + f.TrimmedName + ".xml";
|
||||||
|
}
|
||||||
if (!DocumentationFiles.ContainsKey(file))
|
if (!DocumentationFiles.ContainsKey(file))
|
||||||
|
{
|
||||||
file = Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml";
|
file = Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml";
|
||||||
|
}
|
||||||
|
|
||||||
docs =
|
docs =
|
||||||
(DocumentationFiles.ContainsKey(file) ? ProcessFile(DocumentationFiles[file], processor) : null) ??
|
(DocumentationFiles.ContainsKey(file) ? ProcessFile(DocumentationFiles[file], processor) : null) ??
|
||||||
|
@ -96,7 +102,9 @@ namespace Bind
|
||||||
string text;
|
string text;
|
||||||
|
|
||||||
if (LastFile == file)
|
if (LastFile == file)
|
||||||
|
{
|
||||||
return Cached;
|
return Cached;
|
||||||
|
}
|
||||||
|
|
||||||
LastFile = file;
|
LastFile = file;
|
||||||
text = File.ReadAllText(file);
|
text = File.ReadAllText(file);
|
||||||
|
@ -155,7 +163,9 @@ namespace Bind
|
||||||
private Documentation ToInlineDocs(XDocument doc, EnumProcessor enum_processor)
|
private Documentation ToInlineDocs(XDocument doc, EnumProcessor enum_processor)
|
||||||
{
|
{
|
||||||
if (doc == null || enum_processor == null)
|
if (doc == null || enum_processor == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
var no_const_processing = Settings.Legacy.NoAdvancedEnumProcessing | Settings.Legacy.ConstIntEnums;
|
var no_const_processing = Settings.Legacy.NoAdvancedEnumProcessing | Settings.Legacy.ConstIntEnums;
|
||||||
if (!Generator.Settings.IsEnabled(no_const_processing))
|
if (!Generator.Settings.IsEnabled(no_const_processing))
|
||||||
|
|
|
@ -45,9 +45,13 @@ namespace Bind
|
||||||
public EnumProcessor(IBind generator, IEnumerable<string> overrides)
|
public EnumProcessor(IBind generator, IEnumerable<string> overrides)
|
||||||
{
|
{
|
||||||
if (generator == null)
|
if (generator == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("generator");
|
throw new ArgumentNullException("generator");
|
||||||
|
}
|
||||||
if (overrides == null)
|
if (overrides == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("overrides");
|
throw new ArgumentNullException("overrides");
|
||||||
|
}
|
||||||
|
|
||||||
Generator = generator;
|
Generator = generator;
|
||||||
Overrides = overrides;
|
Overrides = overrides;
|
||||||
|
@ -69,7 +73,9 @@ namespace Bind
|
||||||
public static string GetOverridesPath(string apiname, string enumeration)
|
public static string GetOverridesPath(string apiname, string enumeration)
|
||||||
{
|
{
|
||||||
if (enumeration == null)
|
if (enumeration == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("enumeration");
|
throw new ArgumentNullException("enumeration");
|
||||||
|
}
|
||||||
|
|
||||||
var path = new StringBuilder();
|
var path = new StringBuilder();
|
||||||
path.Append("/signatures/replace");
|
path.Append("/signatures/replace");
|
||||||
|
@ -149,15 +155,21 @@ namespace Bind
|
||||||
public string TranslateEnumName(string name)
|
public string TranslateEnumName(string name)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(name))
|
if (String.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
return name;
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
if (Utilities.CSharpKeywords.Contains(name))
|
if (Utilities.CSharpKeywords.Contains(name))
|
||||||
|
{
|
||||||
return name;
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsAlreadyProcessed(name))
|
if (!IsAlreadyProcessed(name))
|
||||||
{
|
{
|
||||||
if (Char.IsDigit(name[0]))
|
if (Char.IsDigit(name[0]))
|
||||||
|
{
|
||||||
name = Settings.ConstantPrefix + name;
|
name = Settings.ConstantPrefix + name;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder translator = new StringBuilder(name);
|
StringBuilder translator = new StringBuilder(name);
|
||||||
|
|
||||||
|
@ -194,11 +206,17 @@ namespace Bind
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_after_underscore_or_number)
|
if (is_after_underscore_or_number)
|
||||||
|
{
|
||||||
char_to_add = Char.ToUpper(c);
|
char_to_add = Char.ToUpper(c);
|
||||||
|
}
|
||||||
else if (is_previous_uppercase)
|
else if (is_previous_uppercase)
|
||||||
|
{
|
||||||
char_to_add = Char.ToLower(c);
|
char_to_add = Char.ToLower(c);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
char_to_add = c;
|
char_to_add = c;
|
||||||
|
}
|
||||||
|
|
||||||
translator.Append(char_to_add);
|
translator.Append(char_to_add);
|
||||||
|
|
||||||
|
@ -219,7 +237,9 @@ namespace Bind
|
||||||
|
|
||||||
name = translator.ToString();
|
name = translator.ToString();
|
||||||
if (name.StartsWith(Settings.EnumPrefix))
|
if (name.StartsWith(Settings.EnumPrefix))
|
||||||
|
{
|
||||||
name = name.Substring(Settings.EnumPrefix.Length);
|
name = name.Substring(Settings.EnumPrefix.Length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
@ -282,7 +302,9 @@ namespace Bind
|
||||||
public string TranslateConstantName(string s, bool isValue)
|
public string TranslateConstantName(string s, bool isValue)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(s))
|
if (String.IsNullOrEmpty(s))
|
||||||
|
{
|
||||||
return s;
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder translator = new StringBuilder(s.Length);
|
StringBuilder translator = new StringBuilder(s.Length);
|
||||||
|
|
||||||
|
@ -302,7 +324,9 @@ namespace Bind
|
||||||
bool is_after_digit = false;
|
bool is_after_digit = false;
|
||||||
|
|
||||||
if (!isValue && Char.IsDigit(s[0]))
|
if (!isValue && Char.IsDigit(s[0]))
|
||||||
|
{
|
||||||
s = Settings.ConstantPrefix + s;
|
s = Settings.ConstantPrefix + s;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (char c in s)
|
foreach (char c in s)
|
||||||
{
|
{
|
||||||
|
@ -333,7 +357,9 @@ namespace Bind
|
||||||
translator[0] = Char.ToUpper(translator[0]);
|
translator[0] = Char.ToUpper(translator[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
translator.Append(s);
|
translator.Append(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return translator.ToString();
|
return translator.ToString();
|
||||||
|
@ -346,14 +372,20 @@ namespace Bind
|
||||||
{
|
{
|
||||||
// Trim the unsigned or long specifiers used in C constants ('u' or 'ull').
|
// Trim the unsigned or long specifiers used in C constants ('u' or 'ull').
|
||||||
if (value.ToLower().EndsWith("ull"))
|
if (value.ToLower().EndsWith("ull"))
|
||||||
|
{
|
||||||
value = value.Substring(0, value.Length - 3);
|
value = value.Substring(0, value.Length - 3);
|
||||||
|
}
|
||||||
if (value.ToLower().EndsWith("u"))
|
if (value.ToLower().EndsWith("u"))
|
||||||
|
{
|
||||||
value = value.Substring(0, value.Length - 1);
|
value = value.Substring(0, value.Length - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip the prefix, if any.
|
// Strip the prefix, if any.
|
||||||
if (value.StartsWith(Settings.ConstantPrefix))
|
if (value.StartsWith(Settings.ConstantPrefix))
|
||||||
|
{
|
||||||
value = value.Substring(Settings.ConstantPrefix.Length);
|
value = value.Substring(Settings.ConstantPrefix.Length);
|
||||||
|
}
|
||||||
|
|
||||||
return TranslateConstantName(value, IsValue(value));
|
return TranslateConstantName(value, IsValue(value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,13 @@ namespace Bind
|
||||||
public FuncProcessor(IBind generator, IEnumerable<string> overrides)
|
public FuncProcessor(IBind generator, IEnumerable<string> overrides)
|
||||||
{
|
{
|
||||||
if (generator == null)
|
if (generator == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("generator");
|
throw new ArgumentNullException("generator");
|
||||||
|
}
|
||||||
if (overrides == null)
|
if (overrides == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("overrides");
|
throw new ArgumentNullException("overrides");
|
||||||
|
}
|
||||||
|
|
||||||
Generator = generator;
|
Generator = generator;
|
||||||
Overrides = overrides;
|
Overrides = overrides;
|
||||||
|
@ -351,15 +355,23 @@ namespace Bind
|
||||||
{
|
{
|
||||||
// For consistency - many overrides use string instead of String.
|
// For consistency - many overrides use string instead of String.
|
||||||
if (enum_override.Value == "string")
|
if (enum_override.Value == "string")
|
||||||
|
{
|
||||||
type.QualifiedType = "String";
|
type.QualifiedType = "String";
|
||||||
|
}
|
||||||
else if (enum_override.Value == "StringBuilder")
|
else if (enum_override.Value == "StringBuilder")
|
||||||
|
{
|
||||||
type.QualifiedType = "StringBuilder";
|
type.QualifiedType = "StringBuilder";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
type.CurrentType = enum_override.Value;
|
type.CurrentType = enum_override.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.CurrentType == "IntPtr" && String.IsNullOrEmpty(type.PreviousType))
|
if (type.CurrentType == "IntPtr" && String.IsNullOrEmpty(type.PreviousType))
|
||||||
|
{
|
||||||
type.Pointer = 0;
|
type.Pointer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (type.Pointer >= 3)
|
if (type.Pointer >= 3)
|
||||||
{
|
{
|
||||||
|
@ -455,13 +467,19 @@ namespace Bind
|
||||||
string extensionless_name = GetTrimmedExtension(d.Name, ext);
|
string extensionless_name = GetTrimmedExtension(d.Name, ext);
|
||||||
function_overload = nav.Select(GetOverloadsPath(apiname, apiversion, d.Name, ext));
|
function_overload = nav.Select(GetOverloadsPath(apiname, apiversion, d.Name, ext));
|
||||||
if (function_overload.Count != 0)
|
if (function_overload.Count != 0)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
function_overload = nav.Select(GetOverloadsPath(apiname, apiversion, extensionless_name, ext));
|
function_overload = nav.Select(GetOverloadsPath(apiname, apiversion, extensionless_name, ext));
|
||||||
if (function_overload.Count != 0)
|
if (function_overload.Count != 0)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
function_overload = nav.Select(GetOverloadsPath(apiname, apiversion, trimmed_name, ext));
|
function_overload = nav.Select(GetOverloadsPath(apiname, apiversion, trimmed_name, ext));
|
||||||
if (function_overload.Count != 0)
|
if (function_overload.Count != 0)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return function_overload;
|
return function_overload;
|
||||||
}
|
}
|
||||||
|
@ -522,7 +540,9 @@ namespace Bind
|
||||||
case "count":
|
case "count":
|
||||||
int count;
|
int count;
|
||||||
if (Int32.TryParse(node.Value, out count))
|
if (Int32.TryParse(node.Value, out count))
|
||||||
|
{
|
||||||
d.Parameters[i].ElementCount = count;
|
d.Parameters[i].ElementCount = count;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -583,10 +603,14 @@ namespace Bind
|
||||||
if (d.ReturnType.CurrentType.Contains("GLenum"))
|
if (d.ReturnType.CurrentType.Contains("GLenum"))
|
||||||
{
|
{
|
||||||
if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) == Settings.Legacy.None)
|
if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) == Settings.Legacy.None)
|
||||||
|
{
|
||||||
d.ReturnType.QualifiedType = String.Format("{0}{1}{2}",
|
d.ReturnType.QualifiedType = String.Format("{0}{1}{2}",
|
||||||
Settings.EnumsOutput, Settings.NamespaceSeparator, Settings.CompleteEnumName);
|
Settings.EnumsOutput, Settings.NamespaceSeparator, Settings.CompleteEnumName);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
d.ReturnType.QualifiedType = "int";
|
d.ReturnType.QualifiedType = "int";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d.ReturnType.CurrentType.ToLower().Contains("bool"))
|
if (d.ReturnType.CurrentType.ToLower().Contains("bool"))
|
||||||
|
@ -623,7 +647,9 @@ namespace Bind
|
||||||
{
|
{
|
||||||
TranslateParameter(d.Parameters[i], function_override, nav, enum_processor, enums, d.Category, apiname);
|
TranslateParameter(d.Parameters[i], function_override, nav, enum_processor, enums, d.Category, apiname);
|
||||||
if (d.Parameters[i].CurrentType == "UInt16" && d.Name.Contains("LineStipple"))
|
if (d.Parameters[i].CurrentType == "UInt16" && d.Name.Contains("LineStipple"))
|
||||||
|
{
|
||||||
d.Parameters[i].WrapperType |= WrapperTypes.UncheckedParameter;
|
d.Parameters[i].WrapperType |= WrapperTypes.UncheckedParameter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,7 +719,9 @@ namespace Bind
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utilities.CSharpKeywords.Contains(p.Name))
|
if (Utilities.CSharpKeywords.Contains(p.Name))
|
||||||
|
{
|
||||||
p.Name = Settings.KeywordEscapeCharacter + p.Name;
|
p.Name = Settings.KeywordEscapeCharacter + p.Name;
|
||||||
|
}
|
||||||
|
|
||||||
// This causes problems with bool arrays
|
// This causes problems with bool arrays
|
||||||
//if (CurrentType.ToLower().Contains("bool"))
|
//if (CurrentType.ToLower().Contains("bool"))
|
||||||
|
@ -793,7 +821,9 @@ namespace Bind
|
||||||
{
|
{
|
||||||
cls.Parameters[i].CurrentType = GetCLSCompliantType(cls.Parameters[i]);
|
cls.Parameters[i].CurrentType = GetCLSCompliantType(cls.Parameters[i]);
|
||||||
if (cls.Parameters[i].CurrentType != f.Parameters[i].CurrentType)
|
if (cls.Parameters[i].CurrentType != f.Parameters[i].CurrentType)
|
||||||
|
{
|
||||||
modified = true;
|
modified = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add a cls-compliant overload if we have
|
// Only add a cls-compliant overload if we have
|
||||||
|
@ -840,21 +870,33 @@ namespace Bind
|
||||||
for (k = 0; k < wrappers[i].Parameters.Count; k++)
|
for (k = 0; k < wrappers[i].Parameters.Count; k++)
|
||||||
{
|
{
|
||||||
if (wrappers[i].Parameters[k].CurrentType != wrappers[j].Parameters[k].CurrentType)
|
if (wrappers[i].Parameters[k].CurrentType != wrappers[j].Parameters[k].CurrentType)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (wrappers[i].Parameters[k].DiffersOnlyOnReference(wrappers[j].Parameters[k]))
|
if (wrappers[i].Parameters[k].DiffersOnlyOnReference(wrappers[j].Parameters[k]))
|
||||||
|
{
|
||||||
if (wrappers[i].Parameters[k].Reference)
|
if (wrappers[i].Parameters[k].Reference)
|
||||||
|
{
|
||||||
function_i_is_problematic = true;
|
function_i_is_problematic = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
function_j_is_problematic = true;
|
function_j_is_problematic = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k == wrappers[i].Parameters.Count)
|
if (k == wrappers[i].Parameters.Count)
|
||||||
{
|
{
|
||||||
if (function_i_is_problematic)
|
if (function_i_is_problematic)
|
||||||
|
{
|
||||||
must_remove.Add(i);
|
must_remove.Add(i);
|
||||||
|
}
|
||||||
if (function_j_is_problematic)
|
if (function_j_is_problematic)
|
||||||
|
{
|
||||||
must_remove.Add(j);
|
must_remove.Add(j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -879,7 +921,9 @@ namespace Bind
|
||||||
if (!type.CLSCompliant)
|
if (!type.CLSCompliant)
|
||||||
{
|
{
|
||||||
if (type.Pointer != 0 && Settings.Compatibility == Settings.Legacy.Tao)
|
if (type.Pointer != 0 && Settings.Compatibility == Settings.Legacy.Tao)
|
||||||
|
{
|
||||||
return "IntPtr";
|
return "IntPtr";
|
||||||
|
}
|
||||||
|
|
||||||
switch (type.CurrentType)
|
switch (type.CurrentType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,7 +55,9 @@ namespace Bind.GL2
|
||||||
public Generator(Settings settings)
|
public Generator(Settings settings)
|
||||||
{
|
{
|
||||||
if (settings == null)
|
if (settings == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("settings");
|
throw new ArgumentNullException("settings");
|
||||||
|
}
|
||||||
|
|
||||||
Settings = settings.Clone();
|
Settings = settings.Clone();
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,9 @@ namespace Bind
|
||||||
val = val.ToLower();
|
val = val.ToLower();
|
||||||
bool enable = !opt.StartsWith("-");
|
bool enable = !opt.StartsWith("-");
|
||||||
if (val.StartsWith("+") || val.StartsWith("-"))
|
if (val.StartsWith("+") || val.StartsWith("-"))
|
||||||
|
{
|
||||||
val = val.Substring(1);
|
val = val.Substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
var settings = Settings.Legacy.None;
|
var settings = Settings.Legacy.None;
|
||||||
switch (val)
|
switch (val)
|
||||||
|
|
|
@ -84,9 +84,13 @@ namespace Bind
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ((Compatibility & Legacy.NestedEnums) != Legacy.None)
|
if ((Compatibility & Legacy.NestedEnums) != Legacy.None)
|
||||||
|
{
|
||||||
return OutputNamespace + NamespaceSeparator + OutputClass + NamespaceSeparator + NestedEnumsClass;
|
return OutputNamespace + NamespaceSeparator + OutputClass + NamespaceSeparator + NestedEnumsClass;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return String.IsNullOrEmpty(EnumsNamespace) ? OutputNamespace : OutputNamespace + NamespaceSeparator + EnumsNamespace;
|
return String.IsNullOrEmpty(EnumsNamespace) ? OutputNamespace : OutputNamespace + NamespaceSeparator + EnumsNamespace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,9 +99,13 @@ namespace Bind
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if ((Compatibility & Legacy.NestedEnums) != Legacy.None)
|
if ((Compatibility & Legacy.NestedEnums) != Legacy.None)
|
||||||
|
{
|
||||||
return OutputNamespace + NamespaceSeparator + GLClass + NamespaceSeparator + NestedEnumsClass;
|
return OutputNamespace + NamespaceSeparator + GLClass + NamespaceSeparator + NestedEnumsClass;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return OutputNamespace + NamespaceSeparator + EnumsNamespace;
|
return OutputNamespace + NamespaceSeparator + EnumsNamespace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +207,15 @@ namespace Bind
|
||||||
public bool DropMultipleTokens
|
public bool DropMultipleTokens
|
||||||
{
|
{
|
||||||
get { return (Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; }
|
get { return (Compatibility & Legacy.NoDropMultipleTokens) == Legacy.None; }
|
||||||
set { if (value) Compatibility |= Legacy.NoDropMultipleTokens; else Compatibility &= ~Legacy.NoDropMultipleTokens; }
|
set { if (value)
|
||||||
|
{
|
||||||
|
Compatibility |= Legacy.NoDropMultipleTokens;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Compatibility &= ~Legacy.NoDropMultipleTokens;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string WindowsGDI = "OpenTK.Platform.Windows.API";
|
public string WindowsGDI = "OpenTK.Platform.Windows.API";
|
||||||
|
|
|
@ -32,10 +32,14 @@ namespace Bind.Structures
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(value))
|
if (String.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
throw new ArgumentNullException("value");
|
throw new ArgumentNullException("value");
|
||||||
|
}
|
||||||
|
|
||||||
if (OriginalName == null)
|
if (OriginalName == null)
|
||||||
|
{
|
||||||
OriginalName = _name;
|
OriginalName = _name;
|
||||||
|
}
|
||||||
|
|
||||||
_name = value;
|
_name = value;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +59,9 @@ namespace Bind.Structures
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(value))
|
if (String.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
throw new ArgumentNullException("value");
|
throw new ArgumentNullException("value");
|
||||||
|
}
|
||||||
|
|
||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
|
@ -108,9 +114,13 @@ namespace Bind.Structures
|
||||||
public static bool TranslateConstantWithReference(Constant c, EnumCollection enums)
|
public static bool TranslateConstantWithReference(Constant c, EnumCollection enums)
|
||||||
{
|
{
|
||||||
if (c == null)
|
if (c == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("c");
|
throw new ArgumentNullException("c");
|
||||||
|
}
|
||||||
if (enums == null)
|
if (enums == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("enums");
|
throw new ArgumentNullException("enums");
|
||||||
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(c.Reference))
|
if (!String.IsNullOrEmpty(c.Reference))
|
||||||
{
|
{
|
||||||
|
@ -165,7 +175,9 @@ namespace Bind.Structures
|
||||||
{
|
{
|
||||||
int ret = Value.CompareTo(other.Value);
|
int ret = Value.CompareTo(other.Value);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
{
|
||||||
return Name.CompareTo(other.Name);
|
return Name.CompareTo(other.Name);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,18 +61,26 @@ namespace Bind.Structures
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (cls_compliance_overriden != null)
|
if (cls_compliance_overriden != null)
|
||||||
|
{
|
||||||
return (bool)cls_compliance_overriden;
|
return (bool)cls_compliance_overriden;
|
||||||
|
}
|
||||||
|
|
||||||
if (Unsafe)
|
if (Unsafe)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ReturnType.CLSCompliant)
|
if (!ReturnType.CLSCompliant)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Parameter p in Parameters)
|
foreach (Parameter p in Parameters)
|
||||||
{
|
{
|
||||||
if (!p.CLSCompliant)
|
if (!p.CLSCompliant)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -96,12 +104,16 @@ namespace Bind.Structures
|
||||||
// TODO: Add special cases for (Get)ShaderSource.
|
// TODO: Add special cases for (Get)ShaderSource.
|
||||||
|
|
||||||
if (ReturnType.WrapperType != WrapperTypes.None)
|
if (ReturnType.WrapperType != WrapperTypes.None)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Parameter p in Parameters)
|
foreach (Parameter p in Parameters)
|
||||||
{
|
{
|
||||||
if (p.WrapperType != WrapperTypes.None)
|
if (p.WrapperType != WrapperTypes.None)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -121,7 +133,9 @@ namespace Bind.Structures
|
||||||
// return false;
|
// return false;
|
||||||
|
|
||||||
if (ReturnType.Pointer != 0)
|
if (ReturnType.Pointer != 0)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Parameter p in Parameters)
|
foreach (Parameter p in Parameters)
|
||||||
{
|
{
|
||||||
|
@ -198,9 +212,13 @@ namespace Bind.Structures
|
||||||
{
|
{
|
||||||
int ret = Name.CompareTo(other.Name);
|
int ret = Name.CompareTo(other.Name);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
{
|
||||||
ret = Parameters.CompareTo(other.Parameters);
|
ret = Parameters.CompareTo(other.Parameters);
|
||||||
|
}
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
{
|
||||||
ret = ReturnType.CompareTo(other.ReturnType);
|
ret = ReturnType.CompareTo(other.ReturnType);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,9 @@ namespace Bind.Structures
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("value");
|
throw new ArgumentNullException("value");
|
||||||
|
}
|
||||||
|
|
||||||
_constant_collection.Clear();
|
_constant_collection.Clear();
|
||||||
foreach (var item in value)
|
foreach (var item in value)
|
||||||
|
@ -89,12 +91,16 @@ namespace Bind.Structures
|
||||||
// empty check, let's try to remove first Arb, then Ext from the strings.
|
// empty check, let's try to remove first Arb, then Ext from the strings.
|
||||||
int ret = PreferEmpty(ext1, ext2);
|
int ret = PreferEmpty(ext1, ext2);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
{
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ext1 = ext1.Replace("Arb", ""); ext2 = ext2.Replace("Arb", "");
|
ext1 = ext1.Replace("Arb", ""); ext2 = ext2.Replace("Arb", "");
|
||||||
ret = PreferEmpty(ext1, ext2);
|
ret = PreferEmpty(ext1, ext2);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
{
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ext1 = ext1.Replace("Ext", ""); ext2 = ext2.Replace("Ext", "");
|
ext1 = ext1.Replace("Ext", ""); ext2 = ext2.Replace("Ext", "");
|
||||||
return PreferEmpty(ext1, ext2);
|
return PreferEmpty(ext1, ext2);
|
||||||
|
@ -104,11 +110,17 @@ namespace Bind.Structures
|
||||||
private int PreferEmpty(string ext1, string ext2)
|
private int PreferEmpty(string ext1, string ext2)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(ext1) && !String.IsNullOrEmpty(ext2))
|
if (String.IsNullOrEmpty(ext1) && !String.IsNullOrEmpty(ext2))
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
else if (String.IsNullOrEmpty(ext2) && !String.IsNullOrEmpty(ext1))
|
else if (String.IsNullOrEmpty(ext2) && !String.IsNullOrEmpty(ext1))
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(Enum e)
|
public void Add(Enum e)
|
||||||
|
|
|
@ -81,9 +81,13 @@ namespace Bind.Structures
|
||||||
{
|
{
|
||||||
int ret = Name.CompareTo(other.Name);
|
int ret = Name.CompareTo(other.Name);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
{
|
||||||
ret = Parameters.CompareTo(other.Parameters);
|
ret = Parameters.CompareTo(other.Parameters);
|
||||||
|
}
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
{
|
||||||
ret = ReturnType.CompareTo(other.ReturnType);
|
ret = ReturnType.CompareTo(other.ReturnType);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,9 +116,13 @@ namespace Bind.Structures
|
||||||
public void Unindent()
|
public void Unindent()
|
||||||
{
|
{
|
||||||
if (indent.Length > 4)
|
if (indent.Length > 4)
|
||||||
|
{
|
||||||
indent = indent.Substring(4);
|
indent = indent.Substring(4);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
indent = String.Empty;
|
indent = String.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new public void Add(string s)
|
new public void Add(string s)
|
||||||
|
@ -133,7 +141,9 @@ namespace Bind.Structures
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (Count == 0)
|
if (Count == 0)
|
||||||
|
{
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder(Count);
|
StringBuilder sb = new StringBuilder(Count);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,9 @@ namespace Bind.Structures
|
||||||
: base(p)
|
: base(p)
|
||||||
{
|
{
|
||||||
if (p == null)
|
if (p == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Name = p.Name;
|
Name = p.Name;
|
||||||
Unchecked = p.Unchecked;
|
Unchecked = p.Unchecked;
|
||||||
|
@ -164,7 +166,9 @@ namespace Bind.Structures
|
||||||
{
|
{
|
||||||
int result = base.CompareTo(other);
|
int result = base.CompareTo(other);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
|
{
|
||||||
result = Name.CompareTo(other.Name);
|
result = Name.CompareTo(other.Name);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +222,9 @@ namespace Bind.Structures
|
||||||
public ParameterCollection(IEnumerable<Parameter> parameters)
|
public ParameterCollection(IEnumerable<Parameter> parameters)
|
||||||
{
|
{
|
||||||
foreach (Parameter p in parameters)
|
foreach (Parameter p in parameters)
|
||||||
|
{
|
||||||
Add(new Parameter(p));
|
Add(new Parameter(p));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildCache()
|
private void BuildCache()
|
||||||
|
@ -285,16 +291,24 @@ namespace Bind.Structures
|
||||||
foreach (Parameter p in this)
|
foreach (Parameter p in this)
|
||||||
{
|
{
|
||||||
if (p.Pointer != 0 || p.CurrentType.Contains("IntPtr"))
|
if (p.Pointer != 0 || p.CurrentType.Contains("IntPtr"))
|
||||||
|
{
|
||||||
hasPointerParameters = true;
|
hasPointerParameters = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (p.Reference)
|
if (p.Reference)
|
||||||
|
{
|
||||||
hasReferenceParameters = true;
|
hasReferenceParameters = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (p.Unsigned)
|
if (p.Unsigned)
|
||||||
|
{
|
||||||
hasUnsignedParameters = true;
|
hasUnsignedParameters = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (p.Generic)
|
if (p.Generic)
|
||||||
|
{
|
||||||
hasGenericParameters = true;
|
hasGenericParameters = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +327,9 @@ namespace Bind.Structures
|
||||||
sb.Replace(", ", ")", sb.Length - 2, 2);
|
sb.Replace(", ", ")", sb.Length - 2, 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sb.Append(")");
|
sb.Append(")");
|
||||||
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
@ -321,8 +337,12 @@ namespace Bind.Structures
|
||||||
public bool ContainsType(string type)
|
public bool ContainsType(string type)
|
||||||
{
|
{
|
||||||
foreach (Parameter p in this)
|
foreach (Parameter p in this)
|
||||||
|
{
|
||||||
if (p.CurrentType == type)
|
if (p.CurrentType == type)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +443,9 @@ namespace Bind.Structures
|
||||||
{
|
{
|
||||||
int result = this[i].CompareTo(other[i]);
|
int result = this[i].CompareTo(other[i]);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -432,7 +454,9 @@ namespace Bind.Structures
|
||||||
public bool Equals(ParameterCollection other)
|
public bool Equals(ParameterCollection other)
|
||||||
{
|
{
|
||||||
if (Count != other.Count)
|
if (Count != other.Count)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
for (int i = 0; i < Count && result; i++)
|
for (int i = 0; i < Count && result; i++)
|
||||||
|
|
|
@ -54,7 +54,9 @@ namespace Bind.Structures
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(value))
|
if (String.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
int qualifier_end = value.LastIndexOf('.');
|
int qualifier_end = value.LastIndexOf('.');
|
||||||
if (qualifier_end > -1)
|
if (qualifier_end > -1)
|
||||||
|
@ -83,12 +85,18 @@ namespace Bind.Structures
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(value))
|
if (String.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
throw new ArgumentException();
|
throw new ArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(type))
|
if (!String.IsNullOrEmpty(type))
|
||||||
|
{
|
||||||
PreviousType = type;
|
PreviousType = type;
|
||||||
|
}
|
||||||
if (!String.IsNullOrEmpty(value))
|
if (!String.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
type = value.Trim();
|
type = value.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
while (type.EndsWith("*"))
|
while (type.EndsWith("*"))
|
||||||
{
|
{
|
||||||
|
@ -228,19 +236,29 @@ namespace Bind.Structures
|
||||||
// DelegateCollection.Add that depends on this fact.
|
// DelegateCollection.Add that depends on this fact.
|
||||||
int result = this.CurrentType.CompareTo(other.CurrentType);
|
int result = this.CurrentType.CompareTo(other.CurrentType);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
|
{
|
||||||
result = Pointer.CompareTo(other.Pointer); // Must come after array/ref, see issue [#1098]
|
result = Pointer.CompareTo(other.Pointer); // Must come after array/ref, see issue [#1098]
|
||||||
|
}
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
|
{
|
||||||
result = Reference.CompareTo(other.Reference);
|
result = Reference.CompareTo(other.Reference);
|
||||||
|
}
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
|
{
|
||||||
result = Array.CompareTo(other.Array);
|
result = Array.CompareTo(other.Array);
|
||||||
|
}
|
||||||
// Note: CLS-compliance and element counts
|
// Note: CLS-compliance and element counts
|
||||||
// are used for comparison calculations, in order
|
// are used for comparison calculations, in order
|
||||||
// to maintain a stable sorting order, even though
|
// to maintain a stable sorting order, even though
|
||||||
// they are not used in equality calculations.
|
// they are not used in equality calculations.
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
|
{
|
||||||
result = CLSCompliant.CompareTo(other.CLSCompliant);
|
result = CLSCompliant.CompareTo(other.CLSCompliant);
|
||||||
|
}
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
|
{
|
||||||
result = ElementCount.CompareTo(other.ElementCount);
|
result = ElementCount.CompareTo(other.ElementCount);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,9 @@ namespace Bind
|
||||||
internal static StreamReader OpenSpecFile(string folder, string file)
|
internal static StreamReader OpenSpecFile(string folder, string file)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(folder) || String.IsNullOrEmpty(file))
|
if (String.IsNullOrEmpty(folder) || String.IsNullOrEmpty(file))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine(folder);
|
Console.WriteLine(folder);
|
||||||
Console.WriteLine(file);
|
Console.WriteLine(file);
|
||||||
|
|
|
@ -44,7 +44,9 @@ namespace Bind
|
||||||
public XmlSpecReader(Settings settings)
|
public XmlSpecReader(Settings settings)
|
||||||
{
|
{
|
||||||
if (settings == null)
|
if (settings == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("settings");
|
throw new ArgumentNullException("settings");
|
||||||
|
}
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +73,9 @@ namespace Bind
|
||||||
foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_delete))
|
foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_delete))
|
||||||
{
|
{
|
||||||
foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
|
foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
|
||||||
|
{
|
||||||
delegates.Remove(node.GetAttribute("name", String.Empty));
|
delegates.Remove(node.GetAttribute("name", String.Empty));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_add))
|
foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_add))
|
||||||
{
|
{
|
||||||
|
@ -105,7 +109,9 @@ namespace Bind
|
||||||
foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_delete))
|
foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_delete))
|
||||||
{
|
{
|
||||||
foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty))
|
foreach (XPathNavigator node in nav.SelectChildren("enum", String.Empty))
|
||||||
|
{
|
||||||
enums.Remove(node.GetAttribute("name", String.Empty));
|
enums.Remove(node.GetAttribute("name", String.Empty));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_add))
|
foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_add))
|
||||||
{
|
{
|
||||||
|
@ -122,14 +128,18 @@ namespace Bind
|
||||||
Dictionary<string, string> GLTypes = new Dictionary<string, string>();
|
Dictionary<string, string> GLTypes = new Dictionary<string, string>();
|
||||||
|
|
||||||
if (sr == null)
|
if (sr == null)
|
||||||
|
{
|
||||||
return GLTypes;
|
return GLTypes;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
string line = sr.ReadLine();
|
string line = sr.ReadLine();
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(line) || line.StartsWith("#"))
|
if (String.IsNullOrEmpty(line) || line.StartsWith("#"))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
string[] words = line.Split(" ,*\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
string[] words = line.Split(" ,*\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
@ -190,14 +200,20 @@ namespace Bind
|
||||||
{
|
{
|
||||||
string line = sr.ReadLine();
|
string line = sr.ReadLine();
|
||||||
if (String.IsNullOrEmpty(line) || line.StartsWith("#"))
|
if (String.IsNullOrEmpty(line) || line.StartsWith("#"))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
string[] words = line.Split(" ,\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
string[] words = line.Split(" ,\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (words.Length < 2)
|
if (words.Length < 2)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (((Settings.Compatibility & Settings.Legacy.NoBoolParameters) != Settings.Legacy.None) && words[1] == "bool")
|
if (((Settings.Compatibility & Settings.Legacy.NoBoolParameters) != Settings.Legacy.None) && words[1] == "bool")
|
||||||
|
{
|
||||||
words[1] = "Int32";
|
words[1] = "Int32";
|
||||||
|
}
|
||||||
|
|
||||||
CSTypes.Add(words[0], words[1]);
|
CSTypes.Add(words[0], words[1]);
|
||||||
}
|
}
|
||||||
|
@ -257,7 +273,9 @@ namespace Bind
|
||||||
// so we add them anyway (which is desirable).
|
// so we add them anyway (which is desirable).
|
||||||
if (!String.IsNullOrEmpty(version) && !String.IsNullOrEmpty(apiversion) &&
|
if (!String.IsNullOrEmpty(version) && !String.IsNullOrEmpty(apiversion) &&
|
||||||
Decimal.Parse(version) > Decimal.Parse(apiversion))
|
Decimal.Parse(version) > Decimal.Parse(apiversion))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check whether we are adding to an existing delegate or creating a new one.
|
// Check whether we are adding to an existing delegate or creating a new one.
|
||||||
var d = new Delegate
|
var d = new Delegate
|
||||||
|
@ -272,7 +290,9 @@ namespace Bind
|
||||||
Obsolete = node.GetAttribute("obsolete", String.Empty).Trim()
|
Obsolete = node.GetAttribute("obsolete", String.Empty).Trim()
|
||||||
};
|
};
|
||||||
if (!extensions.Contains(d.Extension))
|
if (!extensions.Contains(d.Extension))
|
||||||
|
{
|
||||||
extensions.Add(d.Extension);
|
extensions.Add(d.Extension);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
|
foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
|
||||||
{
|
{
|
||||||
|
@ -344,7 +364,9 @@ namespace Bind
|
||||||
e.Obsolete = node.GetAttribute("obsolete", String.Empty).Trim();
|
e.Obsolete = node.GetAttribute("obsolete", String.Empty).Trim();
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(e.Name))
|
if (String.IsNullOrEmpty(e.Name))
|
||||||
|
{
|
||||||
throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString()));
|
throw new InvalidOperationException(String.Format("Empty name for enum element {0}", node.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
// It seems that all flag collections contain "Mask" in their names.
|
// It seems that all flag collections contain "Mask" in their names.
|
||||||
// This looks like a heuristic, but it holds 100% in practice
|
// This looks like a heuristic, but it holds 100% in practice
|
||||||
|
|
|
@ -61,9 +61,13 @@ namespace OpenTK.Convert
|
||||||
var version = (e.Attribute("version") ?? new XAttribute("version", String.Empty)).Value;
|
var version = (e.Attribute("version") ?? new XAttribute("version", String.Empty)).Value;
|
||||||
var key = name + version;
|
var key = name + version;
|
||||||
if (!elements.ContainsKey(key))
|
if (!elements.ContainsKey(key))
|
||||||
|
{
|
||||||
elements.Add(key, e);
|
elements.Add(key, e);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
elements[key].Add(e.Elements());
|
elements[key].Add(e.Elements());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return elements.Values;
|
return elements.Values;
|
||||||
|
@ -124,7 +128,9 @@ namespace OpenTK.Convert
|
||||||
{
|
{
|
||||||
var api = (e.Attribute("api") ?? new XAttribute("api", "default")).Value;
|
var api = (e.Attribute("api") ?? new XAttribute("api", "default")).Value;
|
||||||
if (!enums.ContainsKey(api))
|
if (!enums.ContainsKey(api))
|
||||||
|
{
|
||||||
enums.Add(api, new SortedDictionary<string, string>());
|
enums.Add(api, new SortedDictionary<string, string>());
|
||||||
|
}
|
||||||
|
|
||||||
enums[api].Add(
|
enums[api].Add(
|
||||||
TrimName(e.Attribute("name").Value),
|
TrimName(e.Attribute("name").Value),
|
||||||
|
@ -151,12 +157,14 @@ namespace OpenTK.Convert
|
||||||
{
|
{
|
||||||
var key = apiname + version;
|
var key = apiname + version;
|
||||||
if (!APIs.ContainsKey(key))
|
if (!APIs.ContainsKey(key))
|
||||||
|
{
|
||||||
APIs.Add(
|
APIs.Add(
|
||||||
key,
|
key,
|
||||||
new XElement(
|
new XElement(
|
||||||
"api",
|
"api",
|
||||||
new XAttribute("name", apiname),
|
new XAttribute("name", apiname),
|
||||||
String.IsNullOrEmpty(version) ? null : new XAttribute("version", version)));
|
String.IsNullOrEmpty(version) ? null : new XAttribute("version", version)));
|
||||||
|
}
|
||||||
var api = APIs[key];
|
var api = APIs[key];
|
||||||
|
|
||||||
var enum_name = TrimName(feature.Attribute("name").Value);
|
var enum_name = TrimName(feature.Attribute("name").Value);
|
||||||
|
@ -267,12 +275,14 @@ namespace OpenTK.Convert
|
||||||
|
|
||||||
var key = apiname + cmd_version;
|
var key = apiname + cmd_version;
|
||||||
if (!APIs.ContainsKey(key))
|
if (!APIs.ContainsKey(key))
|
||||||
|
{
|
||||||
APIs.Add(
|
APIs.Add(
|
||||||
key,
|
key,
|
||||||
new XElement(
|
new XElement(
|
||||||
"api",
|
"api",
|
||||||
new XAttribute("name", apiname),
|
new XAttribute("name", apiname),
|
||||||
new XAttribute("version", cmd_version)));
|
new XAttribute("version", cmd_version)));
|
||||||
|
}
|
||||||
var api = APIs[key];
|
var api = APIs[key];
|
||||||
|
|
||||||
foreach (var command in feature.Elements("require").Elements("command"))
|
foreach (var command in feature.Elements("require").Elements("command"))
|
||||||
|
@ -282,13 +292,17 @@ namespace OpenTK.Convert
|
||||||
ExtensionRegex.Match(cmd_name).Value ??
|
ExtensionRegex.Match(cmd_name).Value ??
|
||||||
(feature.Name == "extension" ? category.Substring(0, category.IndexOf("_")) : "Core");
|
(feature.Name == "extension" ? category.Substring(0, category.IndexOf("_")) : "Core");
|
||||||
if (String.IsNullOrEmpty(cmd_extension))
|
if (String.IsNullOrEmpty(cmd_extension))
|
||||||
|
{
|
||||||
cmd_extension = "Core";
|
cmd_extension = "Core";
|
||||||
|
}
|
||||||
|
|
||||||
XElement function = TranslateCommand(commands[cmd_name]);
|
XElement function = TranslateCommand(commands[cmd_name]);
|
||||||
function.Add(new XAttribute("category", cmd_category));
|
function.Add(new XAttribute("category", cmd_category));
|
||||||
function.Add(new XAttribute("extension", cmd_extension));
|
function.Add(new XAttribute("extension", cmd_extension));
|
||||||
if (!String.IsNullOrEmpty(cmd_version))
|
if (!String.IsNullOrEmpty(cmd_version))
|
||||||
|
{
|
||||||
function.Add(new XAttribute("version", cmd_version));
|
function.Add(new XAttribute("version", cmd_version));
|
||||||
|
}
|
||||||
|
|
||||||
Merge(api, function);
|
Merge(api, function);
|
||||||
}
|
}
|
||||||
|
@ -345,8 +359,9 @@ namespace OpenTK.Convert
|
||||||
|
|
||||||
// Sanity check: one function cannot belong to two different extensions
|
// Sanity check: one function cannot belong to two different extensions
|
||||||
if (f.Attribute("extension").Value != function.Attribute("extension").Value)
|
if (f.Attribute("extension").Value != function.Attribute("extension").Value)
|
||||||
|
{
|
||||||
throw new InvalidOperationException("Different extensions for the same function");
|
throw new InvalidOperationException("Different extensions for the same function");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -434,9 +449,13 @@ namespace OpenTK.Convert
|
||||||
{
|
{
|
||||||
var words = ret.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
var words = ret.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (words[0] == "struct" || words[0] == "const")
|
if (words[0] == "struct" || words[0] == "const")
|
||||||
words[1] = group.Value;
|
{
|
||||||
|
words[1] = @group.Value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
words[0] = group.Value;
|
{
|
||||||
|
words[0] = @group.Value;
|
||||||
|
}
|
||||||
|
|
||||||
ret = String.Join(" ", words);
|
ret = String.Join(" ", words);
|
||||||
}
|
}
|
||||||
|
@ -447,13 +466,21 @@ namespace OpenTK.Convert
|
||||||
private static string Join(string left, string right)
|
private static string Join(string left, string right)
|
||||||
{
|
{
|
||||||
if (!String.IsNullOrEmpty(left) && !String.IsNullOrEmpty(right))
|
if (!String.IsNullOrEmpty(left) && !String.IsNullOrEmpty(right))
|
||||||
|
{
|
||||||
return left + "|" + right;
|
return left + "|" + right;
|
||||||
|
}
|
||||||
else if (!String.IsNullOrEmpty(left))
|
else if (!String.IsNullOrEmpty(left))
|
||||||
|
{
|
||||||
return left;
|
return left;
|
||||||
|
}
|
||||||
else if (!String.IsNullOrEmpty(right))
|
else if (!String.IsNullOrEmpty(right))
|
||||||
|
{
|
||||||
return right;
|
return right;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static XAttribute Lookup(IDictionary<string, XElement> categories, string cmd_name, string attribute)
|
private static XAttribute Lookup(IDictionary<string, XElement> categories, string cmd_name, string attribute)
|
||||||
|
|
|
@ -136,7 +136,9 @@ namespace OpenTK.Convert
|
||||||
foreach (var e in entries)
|
foreach (var e in entries)
|
||||||
{
|
{
|
||||||
if (e.Value.Name.LocalName != "enum")
|
if (e.Value.Name.LocalName != "enum")
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
var tokens = e.Value.Elements()
|
var tokens = e.Value.Elements()
|
||||||
.OrderBy(t => (string)t.Attribute("name"))
|
.OrderBy(t => (string)t.Attribute("name"))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
|
@ -85,11 +85,17 @@ namespace OpenTK.Convert
|
||||||
public string TrimName(string name)
|
public string TrimName(string name)
|
||||||
{
|
{
|
||||||
if (name.StartsWith(EnumPrefix))
|
if (name.StartsWith(EnumPrefix))
|
||||||
|
{
|
||||||
return name.Remove(0, EnumPrefix.Length);
|
return name.Remove(0, EnumPrefix.Length);
|
||||||
|
}
|
||||||
else if (name.StartsWith(FuncPrefix))
|
else if (name.StartsWith(FuncPrefix))
|
||||||
|
{
|
||||||
return name.Remove(0, FuncPrefix.Length);
|
return name.Remove(0, FuncPrefix.Length);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return name;
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,9 @@ namespace OpenTK.Rewrite
|
||||||
{
|
{
|
||||||
// Pretend there is no slots if we want to force everything to work through DllImport (Android & iOS)
|
// Pretend there is no slots if we want to force everything to work through DllImport (Android & iOS)
|
||||||
if (dllimport)
|
if (dllimport)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
var slot_attribute = signature.CustomAttributes
|
var slot_attribute = signature.CustomAttributes
|
||||||
.FirstOrDefault(a => a.AttributeType.Name == "SlotAttribute");
|
.FirstOrDefault(a => a.AttributeType.Name == "SlotAttribute");
|
||||||
|
|
|
@ -355,9 +355,13 @@ namespace OpenTK.Platform.MacOS
|
||||||
byte retval = _aglSetCurrentContext(context);
|
byte retval = _aglSetCurrentContext(context);
|
||||||
|
|
||||||
if (retval != 0)
|
if (retval != 0)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport(agl)] internal static extern AGLContext aglGetCurrentContext();
|
[DllImport(agl)] internal static extern AGLContext aglGetCurrentContext();
|
||||||
|
|
|
@ -143,13 +143,21 @@ namespace OpenTK.Platform.MacOS
|
||||||
int[] glrect = new int[4];
|
int[] glrect = new int[4];
|
||||||
|
|
||||||
if (XOffset != null)
|
if (XOffset != null)
|
||||||
|
{
|
||||||
glrect[0] = rect.X + XOffset();
|
glrect[0] = rect.X + XOffset();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
glrect[0] = rect.X;
|
glrect[0] = rect.X;
|
||||||
|
}
|
||||||
if (YOffset != null)
|
if (YOffset != null)
|
||||||
|
{
|
||||||
glrect[1] = rect.Y + YOffset();
|
glrect[1] = rect.Y + YOffset();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
glrect[1] = rect.Y;
|
glrect[1] = rect.Y;
|
||||||
|
}
|
||||||
glrect[2] = rect.Width;
|
glrect[2] = rect.Width;
|
||||||
glrect[3] = rect.Height;
|
glrect[3] = rect.Height;
|
||||||
|
|
||||||
|
@ -190,9 +198,11 @@ namespace OpenTK.Platform.MacOS
|
||||||
Agl.AglError err = Agl.GetError();
|
Agl.AglError err = Agl.GetError();
|
||||||
|
|
||||||
if (err != Agl.AglError.NoError)
|
if (err != Agl.AglError.NoError)
|
||||||
|
{
|
||||||
throw new Exception(String.Format(
|
throw new Exception(String.Format(
|
||||||
"AGL Error from function {0}: {1} {2}",
|
"AGL Error from function {0}: {1} {2}",
|
||||||
function, err, Agl.ErrorString(err)));
|
function, err, Agl.ErrorString(err)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool firstSwap = true;
|
private bool firstSwap = true;
|
||||||
|
@ -215,7 +225,9 @@ namespace OpenTK.Platform.MacOS
|
||||||
public void MakeCurrent(IWindowInfo window)
|
public void MakeCurrent(IWindowInfo window)
|
||||||
{
|
{
|
||||||
if (Agl.aglSetCurrentContext(Context.Handle) == false)
|
if (Agl.aglSetCurrentContext(Context.Handle) == false)
|
||||||
|
{
|
||||||
MyAGLReportError("aglSetCurrentContext");
|
MyAGLReportError("aglSetCurrentContext");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsCurrent
|
public bool IsCurrent
|
||||||
|
@ -241,7 +253,9 @@ namespace OpenTK.Platform.MacOS
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!Agl.aglSetInteger(Context.Handle, Agl.ParameterNames.AGL_SWAP_INTERVAL, ref value))
|
if (!Agl.aglSetInteger(Context.Handle, Agl.ParameterNames.AGL_SWAP_INTERVAL, ref value))
|
||||||
|
{
|
||||||
MyAGLReportError("aglSetInteger");
|
MyAGLReportError("aglSetInteger");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +303,9 @@ namespace OpenTK.Platform.MacOS
|
||||||
private void Dispose(bool disposing)
|
private void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (IsDisposed || Context.Handle == IntPtr.Zero)
|
if (IsDisposed || Context.Handle == IntPtr.Zero)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Print("Disposing of AGL context.");
|
Debug.Print("Disposing of AGL context.");
|
||||||
Agl.aglSetCurrentContext(IntPtr.Zero);
|
Agl.aglSetCurrentContext(IntPtr.Zero);
|
||||||
|
|
|
@ -88,7 +88,9 @@ namespace OpenTK
|
||||||
public GLControl(GraphicsMode mode, int major, int minor, GraphicsContextFlags flags)
|
public GLControl(GraphicsMode mode, int major, int minor, GraphicsContextFlags flags)
|
||||||
{
|
{
|
||||||
if (mode == null)
|
if (mode == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("mode");
|
throw new ArgumentNullException("mode");
|
||||||
|
}
|
||||||
|
|
||||||
// SDL does not currently support embedding
|
// SDL does not currently support embedding
|
||||||
// on external windows. If Open.Toolkit is not yet
|
// on external windows. If Open.Toolkit is not yet
|
||||||
|
@ -144,13 +146,19 @@ namespace OpenTK
|
||||||
private void ValidateState()
|
private void ValidateState()
|
||||||
{
|
{
|
||||||
if (IsDisposed)
|
if (IsDisposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(GetType().Name);
|
throw new ObjectDisposedException(GetType().Name);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsHandleCreated)
|
if (!IsHandleCreated)
|
||||||
|
{
|
||||||
CreateControl();
|
CreateControl();
|
||||||
|
}
|
||||||
|
|
||||||
if (implementation == null || context == null || context.IsDisposed)
|
if (implementation == null || context == null || context.IsDisposed)
|
||||||
|
{
|
||||||
RecreateHandle();
|
RecreateHandle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -179,21 +187,31 @@ namespace OpenTK
|
||||||
protected override void OnHandleCreated(EventArgs e)
|
protected override void OnHandleCreated(EventArgs e)
|
||||||
{
|
{
|
||||||
if (context != null)
|
if (context != null)
|
||||||
|
{
|
||||||
context.Dispose();
|
context.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
if (implementation != null)
|
if (implementation != null)
|
||||||
|
{
|
||||||
implementation.WindowInfo.Dispose();
|
implementation.WindowInfo.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
if (design_mode)
|
if (design_mode)
|
||||||
|
{
|
||||||
implementation = new DummyGLControl();
|
implementation = new DummyGLControl();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
implementation = new GLControlFactory().CreateGLControl(format, this);
|
implementation = new GLControlFactory().CreateGLControl(format, this);
|
||||||
|
}
|
||||||
|
|
||||||
context = implementation.CreateContext(major, minor, flags);
|
context = implementation.CreateContext(major, minor, flags);
|
||||||
MakeCurrent();
|
MakeCurrent();
|
||||||
|
|
||||||
if (!design_mode)
|
if (!design_mode)
|
||||||
|
{
|
||||||
((IGraphicsContextInternal)Context).LoadAll();
|
((IGraphicsContextInternal)Context).LoadAll();
|
||||||
|
}
|
||||||
|
|
||||||
// Deferred setting of vsync mode. See VSync property for more information.
|
// Deferred setting of vsync mode. See VSync property for more information.
|
||||||
if (initial_vsync_value.HasValue)
|
if (initial_vsync_value.HasValue)
|
||||||
|
@ -242,7 +260,9 @@ namespace OpenTK
|
||||||
ValidateState();
|
ValidateState();
|
||||||
|
|
||||||
if (design_mode)
|
if (design_mode)
|
||||||
|
{
|
||||||
e.Graphics.Clear(BackColor);
|
e.Graphics.Clear(BackColor);
|
||||||
|
}
|
||||||
|
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +288,9 @@ namespace OpenTK
|
||||||
BeginInvoke(delay); //Need the native window to resize first otherwise our control will be in the wrong place.
|
BeginInvoke(delay); //Need the native window to resize first otherwise our control will be in the wrong place.
|
||||||
}
|
}
|
||||||
else if (context != null)
|
else if (context != null)
|
||||||
|
{
|
||||||
context.Update (Implementation.WindowInfo);
|
context.Update (Implementation.WindowInfo);
|
||||||
|
}
|
||||||
|
|
||||||
base.OnResize(e);
|
base.OnResize(e);
|
||||||
}
|
}
|
||||||
|
@ -283,7 +305,9 @@ namespace OpenTK
|
||||||
public void PerformContextUpdate()
|
public void PerformContextUpdate()
|
||||||
{
|
{
|
||||||
if (context != null)
|
if (context != null)
|
||||||
|
{
|
||||||
context.Update (Implementation.WindowInfo);
|
context.Update (Implementation.WindowInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -293,7 +317,9 @@ namespace OpenTK
|
||||||
protected override void OnParentChanged(EventArgs e)
|
protected override void OnParentChanged(EventArgs e)
|
||||||
{
|
{
|
||||||
if (context != null)
|
if (context != null)
|
||||||
|
{
|
||||||
context.Update(Implementation.WindowInfo);
|
context.Update(Implementation.WindowInfo);
|
||||||
|
}
|
||||||
|
|
||||||
base.OnParentChanged(e);
|
base.OnParentChanged(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,15 +37,34 @@ namespace OpenTK
|
||||||
public IGLControl CreateGLControl(GraphicsMode mode, Control control)
|
public IGLControl CreateGLControl(GraphicsMode mode, Control control)
|
||||||
{
|
{
|
||||||
if (mode == null)
|
if (mode == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("mode");
|
throw new ArgumentNullException("mode");
|
||||||
|
}
|
||||||
if (control == null)
|
if (control == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("control");
|
throw new ArgumentNullException("control");
|
||||||
|
}
|
||||||
|
|
||||||
if (Configuration.RunningOnSdl2) return new Sdl2GLControl(mode, control);
|
if (Configuration.RunningOnSdl2)
|
||||||
else if (Configuration.RunningOnWindows) return new WinGLControl(mode, control);
|
{
|
||||||
else if (Configuration.RunningOnMacOS) return new CarbonGLControl(mode, control);
|
return new Sdl2GLControl(mode, control);
|
||||||
else if (Configuration.RunningOnX11) return new X11GLControl(mode, control);
|
}
|
||||||
else throw new PlatformNotSupportedException();
|
else if (Configuration.RunningOnWindows)
|
||||||
|
{
|
||||||
|
return new WinGLControl(mode, control);
|
||||||
|
}
|
||||||
|
else if (Configuration.RunningOnMacOS)
|
||||||
|
{
|
||||||
|
return new CarbonGLControl(mode, control);
|
||||||
|
}
|
||||||
|
else if (Configuration.RunningOnX11)
|
||||||
|
{
|
||||||
|
return new X11GLControl(mode, control);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new PlatformNotSupportedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,9 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
symbol = NSLookupAndBindSymbol(function);
|
symbol = NSLookupAndBindSymbol(function);
|
||||||
if (symbol != IntPtr.Zero)
|
if (symbol != IntPtr.Zero)
|
||||||
|
{
|
||||||
symbol = NSAddressOfSymbol(symbol);
|
symbol = NSAddressOfSymbol(symbol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,13 @@ namespace OpenTK
|
||||||
internal X11GLControl(GraphicsMode mode, Control control)
|
internal X11GLControl(GraphicsMode mode, Control control)
|
||||||
{
|
{
|
||||||
if (mode == null)
|
if (mode == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("mode");
|
throw new ArgumentNullException("mode");
|
||||||
|
}
|
||||||
if (control == null)
|
if (control == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("control");
|
throw new ArgumentNullException("control");
|
||||||
|
}
|
||||||
|
|
||||||
// Note: the X11 window is created with a default XVisualInfo,
|
// Note: the X11 window is created with a default XVisualInfo,
|
||||||
// that is not necessarily compatible with the desired GraphicsMode.
|
// that is not necessarily compatible with the desired GraphicsMode.
|
||||||
|
@ -83,8 +87,11 @@ namespace OpenTK
|
||||||
mode.Buffers,
|
mode.Buffers,
|
||||||
mode.Stereo);
|
mode.Stereo);
|
||||||
|
|
||||||
if (xplatui == null) throw new PlatformNotSupportedException(
|
if (xplatui == null)
|
||||||
|
{
|
||||||
|
throw new PlatformNotSupportedException(
|
||||||
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
||||||
|
}
|
||||||
|
|
||||||
// get the required handles from the X11 API.
|
// get the required handles from the X11 API.
|
||||||
display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
|
display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
|
||||||
|
|
|
@ -191,7 +191,9 @@ namespace OpenTK
|
||||||
private static void OnGraphicsContextInitialized()
|
private static void OnGraphicsContextInitialized()
|
||||||
{
|
{
|
||||||
if (GraphicsContextInitialized != null)
|
if (GraphicsContextInitialized != null)
|
||||||
|
{
|
||||||
GraphicsContextInitialized(null, EventArgs.Empty);
|
GraphicsContextInitialized(null, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -206,7 +208,9 @@ namespace OpenTK
|
||||||
private static void OnGraphicsContextShuttingDown()
|
private static void OnGraphicsContextShuttingDown()
|
||||||
{
|
{
|
||||||
if (GraphicsContextShuttingDown != null)
|
if (GraphicsContextShuttingDown != null)
|
||||||
|
{
|
||||||
GraphicsContextShuttingDown(null, EventArgs.Empty);
|
GraphicsContextShuttingDown(null, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -221,7 +225,9 @@ namespace OpenTK
|
||||||
protected virtual void OnInitialized()
|
protected virtual void OnInitialized()
|
||||||
{
|
{
|
||||||
if (Initialized != null)
|
if (Initialized != null)
|
||||||
|
{
|
||||||
Initialized(this, EventArgs.Empty);
|
Initialized(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -235,7 +241,9 @@ namespace OpenTK
|
||||||
protected virtual void OnRenderFrame()
|
protected virtual void OnRenderFrame()
|
||||||
{
|
{
|
||||||
if (RenderFrame != null)
|
if (RenderFrame != null)
|
||||||
|
{
|
||||||
RenderFrame(this, EventArgs.Empty);
|
RenderFrame(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -249,7 +257,9 @@ namespace OpenTK
|
||||||
protected virtual void OnShuttingDown()
|
protected virtual void OnShuttingDown()
|
||||||
{
|
{
|
||||||
if (ShuttingDown != null)
|
if (ShuttingDown != null)
|
||||||
|
{
|
||||||
ShuttingDown(this, EventArgs.Empty);
|
ShuttingDown(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GTK3
|
#if GTK3
|
||||||
|
@ -269,9 +279,13 @@ namespace OpenTK
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (!_Initialized)
|
if (!_Initialized)
|
||||||
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
_GraphicsContext.MakeCurrent(_WindowInfo);
|
_GraphicsContext.MakeCurrent(_WindowInfo);
|
||||||
|
}
|
||||||
|
|
||||||
#if GTK3
|
#if GTK3
|
||||||
var result = base.OnDrawn(cr);
|
var result = base.OnDrawn(cr);
|
||||||
|
@ -300,7 +314,9 @@ namespace OpenTK
|
||||||
bool result = base.OnConfigureEvent(evnt);
|
bool result = base.OnConfigureEvent(evnt);
|
||||||
|
|
||||||
if (_GraphicsContext != null)
|
if (_GraphicsContext != null)
|
||||||
|
{
|
||||||
_GraphicsContext.Update(_WindowInfo);
|
_GraphicsContext.Update(_WindowInfo);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -318,7 +334,9 @@ namespace OpenTK
|
||||||
ColorBPP = 32;
|
ColorBPP = 32;
|
||||||
|
|
||||||
if (DepthBPP == 0)
|
if (DepthBPP == 0)
|
||||||
|
{
|
||||||
DepthBPP = 16;
|
DepthBPP = 16;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorFormat colorBufferColorFormat = new ColorFormat(ColorBPP);
|
ColorFormat colorBufferColorFormat = new ColorFormat(ColorBPP);
|
||||||
|
@ -327,16 +345,24 @@ namespace OpenTK
|
||||||
|
|
||||||
int buffers = 2;
|
int buffers = 2;
|
||||||
if (SingleBuffer)
|
if (SingleBuffer)
|
||||||
|
{
|
||||||
buffers--;
|
buffers--;
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsMode graphicsMode = new GraphicsMode(colorBufferColorFormat, DepthBPP, StencilBPP, Samples, accumulationColorFormat, buffers, Stereo);
|
GraphicsMode graphicsMode = new GraphicsMode(colorBufferColorFormat, DepthBPP, StencilBPP, Samples, accumulationColorFormat, buffers, Stereo);
|
||||||
|
|
||||||
if (Configuration.RunningOnWindows)
|
if (Configuration.RunningOnWindows)
|
||||||
|
{
|
||||||
Console.WriteLine("OpenTK running on windows");
|
Console.WriteLine("OpenTK running on windows");
|
||||||
|
}
|
||||||
else if (Configuration.RunningOnMacOS)
|
else if (Configuration.RunningOnMacOS)
|
||||||
|
{
|
||||||
Console.WriteLine("OpenTK running on OSX");
|
Console.WriteLine("OpenTK running on OSX");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Console.WriteLine("OpenTK running on X11");
|
Console.WriteLine("OpenTK running on X11");
|
||||||
|
}
|
||||||
|
|
||||||
#if GTK3
|
#if GTK3
|
||||||
IntPtr widgetWindowHandle = this.Window.Handle;
|
IntPtr widgetWindowHandle = this.Window.Handle;
|
||||||
|
@ -346,11 +372,17 @@ namespace OpenTK
|
||||||
|
|
||||||
// IWindowInfo
|
// IWindowInfo
|
||||||
if (Configuration.RunningOnWindows)
|
if (Configuration.RunningOnWindows)
|
||||||
|
{
|
||||||
_WindowInfo = WinWindowsInfoInitializer.Initialize(widgetWindowHandle);
|
_WindowInfo = WinWindowsInfoInitializer.Initialize(widgetWindowHandle);
|
||||||
|
}
|
||||||
else if (Configuration.RunningOnMacOS)
|
else if (Configuration.RunningOnMacOS)
|
||||||
|
{
|
||||||
_WindowInfo = OSXWindowInfoInitializer.Initialize(widgetWindowHandle);
|
_WindowInfo = OSXWindowInfoInitializer.Initialize(widgetWindowHandle);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
_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);
|
||||||
|
|
|
@ -69,11 +69,17 @@ namespace OpenTK.Audio
|
||||||
public AudioCapture(string deviceName, int frequency, ALFormat sampleFormat, int bufferSize)
|
public AudioCapture(string deviceName, int frequency, ALFormat sampleFormat, int bufferSize)
|
||||||
{
|
{
|
||||||
if (!AudioDeviceEnumerator.IsOpenALSupported)
|
if (!AudioDeviceEnumerator.IsOpenALSupported)
|
||||||
|
{
|
||||||
throw new DllNotFoundException("openal32.dll");
|
throw new DllNotFoundException("openal32.dll");
|
||||||
|
}
|
||||||
if (frequency <= 0)
|
if (frequency <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("frequency");
|
throw new ArgumentOutOfRangeException("frequency");
|
||||||
|
}
|
||||||
if (bufferSize <= 0)
|
if (bufferSize <= 0)
|
||||||
|
{
|
||||||
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.
|
||||||
CurrentDevice = deviceName;
|
CurrentDevice = deviceName;
|
||||||
|
@ -205,7 +211,9 @@ namespace OpenTK.Audio
|
||||||
where TBuffer : struct
|
where TBuffer : struct
|
||||||
{
|
{
|
||||||
if (buffer == null)
|
if (buffer == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("buffer");
|
throw new ArgumentNullException("buffer");
|
||||||
|
}
|
||||||
|
|
||||||
int buffer_size = BlittableValueType<TBuffer>.Stride * buffer.Length;
|
int buffer_size = BlittableValueType<TBuffer>.Stride * buffer.Length;
|
||||||
// This is more of a heuristic than a 100% valid check. However, it will work
|
// This is more of a heuristic than a 100% valid check. However, it will work
|
||||||
|
@ -214,7 +222,9 @@ namespace OpenTK.Audio
|
||||||
// be produced with compressed sample formats (which are very rare).
|
// be produced with compressed sample formats (which are very rare).
|
||||||
// Still, this is better than no check at all.
|
// Still, this is better than no check at all.
|
||||||
if (sampleCount * GetSampleSize(SampleFormat) > buffer_size)
|
if (sampleCount * GetSampleSize(SampleFormat) > buffer_size)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("sampleCount");
|
throw new ArgumentOutOfRangeException("sampleCount");
|
||||||
|
}
|
||||||
|
|
||||||
GCHandle buffer_ptr = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
GCHandle buffer_ptr = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
||||||
try { ReadSamples(buffer_ptr.AddrOfPinnedObject(), sampleCount); }
|
try { ReadSamples(buffer_ptr.AddrOfPinnedObject(), sampleCount); }
|
||||||
|
@ -320,7 +330,9 @@ namespace OpenTK.Audio
|
||||||
if (this.Handle != IntPtr.Zero)
|
if (this.Handle != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
if (this.IsRunning)
|
if (this.IsRunning)
|
||||||
|
{
|
||||||
this.Stop();
|
this.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
Alc.CaptureCloseDevice(this.Handle);
|
Alc.CaptureCloseDevice(this.Handle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,13 +205,26 @@ namespace OpenTK.Audio
|
||||||
private void CreateContext(string device, int freq, int refresh, bool sync, bool enableEfx, MaxAuxiliarySends efxAuxiliarySends)
|
private void CreateContext(string device, int freq, int refresh, bool sync, bool enableEfx, MaxAuxiliarySends efxAuxiliarySends)
|
||||||
{
|
{
|
||||||
if (!AudioDeviceEnumerator.IsOpenALSupported)
|
if (!AudioDeviceEnumerator.IsOpenALSupported)
|
||||||
|
{
|
||||||
throw new DllNotFoundException("openal32.dll");
|
throw new DllNotFoundException("openal32.dll");
|
||||||
|
}
|
||||||
|
|
||||||
if (AudioDeviceEnumerator.Version == AudioDeviceEnumerator.AlcVersion.Alc1_1 && AudioDeviceEnumerator.AvailablePlaybackDevices.Count == 0) // Alc 1.0 does not support device enumeration.
|
if (AudioDeviceEnumerator.Version == AudioDeviceEnumerator.AlcVersion.Alc1_1 && AudioDeviceEnumerator.AvailablePlaybackDevices.Count == 0) // Alc 1.0 does not support device enumeration.
|
||||||
|
{
|
||||||
throw new NotSupportedException("No audio hardware is available.");
|
throw new NotSupportedException("No audio hardware is available.");
|
||||||
if (context_exists) throw new NotSupportedException("Multiple AudioContexts are not supported.");
|
}
|
||||||
if (freq < 0) throw new ArgumentOutOfRangeException("freq", freq, "Should be greater than zero.");
|
if (context_exists)
|
||||||
if (refresh < 0) throw new ArgumentOutOfRangeException("refresh", refresh, "Should be greater than zero.");
|
{
|
||||||
|
throw new NotSupportedException("Multiple AudioContexts are not supported.");
|
||||||
|
}
|
||||||
|
if (freq < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("freq", freq, "Should be greater than zero.");
|
||||||
|
}
|
||||||
|
if (refresh < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("refresh", refresh, "Should be greater than zero.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(device))
|
if (!String.IsNullOrEmpty(device))
|
||||||
|
@ -292,7 +305,9 @@ namespace OpenTK.Audio
|
||||||
// an old OpenAL version is detect - it may affect outdated OpenAL versions different than OpenAL SI,
|
// an old OpenAL version is detect - it may affect outdated OpenAL versions different than OpenAL SI,
|
||||||
// but it looks like a good compromise for now.
|
// but it looks like a good compromise for now.
|
||||||
if (AudioDeviceEnumerator.AvailablePlaybackDevices.Count > 0)
|
if (AudioDeviceEnumerator.AvailablePlaybackDevices.Count > 0)
|
||||||
|
{
|
||||||
MakeCurrent();
|
MakeCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
CheckErrors();
|
CheckErrors();
|
||||||
|
|
||||||
|
@ -320,9 +335,11 @@ namespace OpenTK.Audio
|
||||||
lock (audio_context_lock)
|
lock (audio_context_lock)
|
||||||
{
|
{
|
||||||
if (!Alc.MakeContextCurrent(context != null ? context.context_handle : ContextHandle.Zero))
|
if (!Alc.MakeContextCurrent(context != null ? context.context_handle : ContextHandle.Zero))
|
||||||
|
{
|
||||||
throw new AudioContextException(String.Format("ALC {0} error detected at {1}.",
|
throw new AudioContextException(String.Format("ALC {0} error detected at {1}.",
|
||||||
Alc.GetError(context != null ? (IntPtr)context.context_handle : IntPtr.Zero).ToString(),
|
Alc.GetError(context != null ? (IntPtr)context.context_handle : IntPtr.Zero).ToString(),
|
||||||
context != null ? context.ToString() : "null"));
|
context != null ? context.ToString() : "null"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +358,9 @@ namespace OpenTK.Audio
|
||||||
lock (audio_context_lock)
|
lock (audio_context_lock)
|
||||||
{
|
{
|
||||||
if (available_contexts.Count == 0)
|
if (available_contexts.Count == 0)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return AudioContext.CurrentContext == this;
|
return AudioContext.CurrentContext == this;
|
||||||
|
@ -350,8 +369,14 @@ namespace OpenTK.Audio
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value) AudioContext.MakeCurrent(this);
|
if (value)
|
||||||
else AudioContext.MakeCurrent(null);
|
{
|
||||||
|
AudioContext.MakeCurrent(this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AudioContext.MakeCurrent(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +392,9 @@ namespace OpenTK.Audio
|
||||||
public void CheckErrors()
|
public void CheckErrors()
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
new AudioDeviceErrorChecker(Device).Dispose();
|
new AudioDeviceErrorChecker(Device).Dispose();
|
||||||
}
|
}
|
||||||
|
@ -380,7 +407,9 @@ namespace OpenTK.Audio
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
return Alc.GetError(Device);
|
return Alc.GetError(Device);
|
||||||
}
|
}
|
||||||
|
@ -400,7 +429,9 @@ namespace OpenTK.Audio
|
||||||
public void MakeCurrent()
|
public void MakeCurrent()
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
AudioContext.MakeCurrent(this);
|
AudioContext.MakeCurrent(this);
|
||||||
}
|
}
|
||||||
|
@ -416,7 +447,9 @@ namespace OpenTK.Audio
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
return is_processing;
|
return is_processing;
|
||||||
}
|
}
|
||||||
|
@ -433,7 +466,9 @@ namespace OpenTK.Audio
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
return is_synchronized;
|
return is_synchronized;
|
||||||
}
|
}
|
||||||
|
@ -461,7 +496,9 @@ namespace OpenTK.Audio
|
||||||
public void Process()
|
public void Process()
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
Alc.ProcessContext(this.context_handle);
|
Alc.ProcessContext(this.context_handle);
|
||||||
IsProcessing = true;
|
IsProcessing = true;
|
||||||
|
@ -490,7 +527,9 @@ namespace OpenTK.Audio
|
||||||
public void Suspend()
|
public void Suspend()
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
Alc.SuspendContext(this.context_handle);
|
Alc.SuspendContext(this.context_handle);
|
||||||
IsProcessing = false;
|
IsProcessing = false;
|
||||||
|
@ -504,7 +543,9 @@ namespace OpenTK.Audio
|
||||||
public bool SupportsExtension(string extension)
|
public bool SupportsExtension(string extension)
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
return Alc.IsExtensionPresent(this.Device, extension);
|
return Alc.IsExtensionPresent(this.Device, extension);
|
||||||
}
|
}
|
||||||
|
@ -517,7 +558,9 @@ namespace OpenTK.Audio
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (disposed)
|
if (disposed)
|
||||||
|
{
|
||||||
throw new ObjectDisposedException(this.GetType().FullName);
|
throw new ObjectDisposedException(this.GetType().FullName);
|
||||||
|
}
|
||||||
|
|
||||||
return device_name;
|
return device_name;
|
||||||
}
|
}
|
||||||
|
@ -537,7 +580,9 @@ namespace OpenTK.Audio
|
||||||
lock (audio_context_lock)
|
lock (audio_context_lock)
|
||||||
{
|
{
|
||||||
if (available_contexts.Count == 0)
|
if (available_contexts.Count == 0)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AudioContext context;
|
AudioContext context;
|
||||||
|
@ -585,7 +630,9 @@ namespace OpenTK.Audio
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
if (this.IsCurrent)
|
if (this.IsCurrent)
|
||||||
|
{
|
||||||
this.IsCurrent = false;
|
this.IsCurrent = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (context_handle != ContextHandle.Zero)
|
if (context_handle != ContextHandle.Zero)
|
||||||
{
|
{
|
||||||
|
@ -594,7 +641,9 @@ namespace OpenTK.Audio
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Device != IntPtr.Zero)
|
if (Device != IntPtr.Zero)
|
||||||
|
{
|
||||||
Alc.CloseDevice(Device);
|
Alc.CloseDevice(Device);
|
||||||
|
}
|
||||||
|
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,7 +112,9 @@ namespace OpenTK.Audio
|
||||||
}
|
}
|
||||||
AlcError playback_err = Alc.GetError(dummy_device);
|
AlcError playback_err = Alc.GetError(dummy_device);
|
||||||
if (playback_err != AlcError.NoError)
|
if (playback_err != AlcError.NoError)
|
||||||
|
{
|
||||||
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"))
|
||||||
|
@ -126,18 +128,24 @@ namespace OpenTK.Audio
|
||||||
}
|
}
|
||||||
AlcError record_err = Alc.GetError(dummy_device);
|
AlcError record_err = Alc.GetError(dummy_device);
|
||||||
if (record_err != AlcError.NoError)
|
if (record_err != AlcError.NoError)
|
||||||
|
{
|
||||||
throw new AudioContextException("Alc Error occured when querying available recording devices. " + record_err.ToString());
|
throw new AudioContextException("Alc Error occured when querying available recording devices. " + record_err.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Debug.WriteLine("Found playback devices:");
|
Debug.WriteLine("Found playback devices:");
|
||||||
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: " + DefaultPlaybackDevice);
|
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: " + DefaultRecordingDevice);
|
Debug.WriteLine("Default recording device: " + DefaultRecordingDevice);
|
||||||
#endif
|
#endif
|
||||||
|
@ -163,9 +171,13 @@ namespace OpenTK.Audio
|
||||||
// clean up the dummy context
|
// clean up the dummy context
|
||||||
Alc.MakeContextCurrent(ContextHandle.Zero);
|
Alc.MakeContextCurrent(ContextHandle.Zero);
|
||||||
if (dummy_context != ContextHandle.Zero && dummy_context.Handle != IntPtr.Zero)
|
if (dummy_context != ContextHandle.Zero && dummy_context.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
Alc.DestroyContext(dummy_context);
|
Alc.DestroyContext(dummy_context);
|
||||||
|
}
|
||||||
if (dummy_device != IntPtr.Zero)
|
if (dummy_device != IntPtr.Zero)
|
||||||
|
{
|
||||||
Alc.CloseDevice(dummy_device);
|
Alc.CloseDevice(dummy_device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,9 @@ namespace OpenTK.Audio
|
||||||
public AudioDeviceErrorChecker(IntPtr device)
|
public AudioDeviceErrorChecker(IntPtr device)
|
||||||
{
|
{
|
||||||
if (device == IntPtr.Zero)
|
if (device == IntPtr.Zero)
|
||||||
|
{
|
||||||
throw new AudioDeviceException();
|
throw new AudioDeviceException();
|
||||||
|
}
|
||||||
|
|
||||||
Device = device;
|
Device = device;
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,8 +461,14 @@ namespace OpenTK.Audio.OpenAL
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public static void DeleteSources(uint[] sources)
|
public static void DeleteSources(uint[] sources)
|
||||||
{
|
{
|
||||||
if (sources == null) throw new ArgumentNullException();
|
if (sources == null)
|
||||||
if (sources.Length == 0) throw new ArgumentOutOfRangeException();
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
if (sources.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
DeleteBuffers(sources.Length, ref sources[0]);
|
DeleteBuffers(sources.Length, ref sources[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,8 +476,14 @@ namespace OpenTK.Audio.OpenAL
|
||||||
/// <param name="sources">An array of source names identifying the sources to be deleted.</param>
|
/// <param name="sources">An array of source names identifying the sources to be deleted.</param>
|
||||||
public static void DeleteSources(int[] sources)
|
public static void DeleteSources(int[] sources)
|
||||||
{
|
{
|
||||||
if (sources == null) throw new ArgumentNullException();
|
if (sources == null)
|
||||||
if (sources.Length == 0) throw new ArgumentOutOfRangeException();
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
if (sources.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
DeleteBuffers(sources.Length, ref sources[0]);
|
DeleteBuffers(sources.Length, ref sources[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1107,7 +1119,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
/// <param name="numEntries">The number of buffers to be unqueued.</param>
|
/// <param name="numEntries">The number of buffers to be unqueued.</param>
|
||||||
public static int[] SourceUnqueueBuffers(int sid, int numEntries)
|
public static int[] SourceUnqueueBuffers(int sid, int numEntries)
|
||||||
{
|
{
|
||||||
if (numEntries <= 0) throw new ArgumentOutOfRangeException("numEntries", "Must be greater than zero.");
|
if (numEntries <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("numEntries", "Must be greater than zero.");
|
||||||
|
}
|
||||||
int[] buf = new int[numEntries];
|
int[] buf = new int[numEntries];
|
||||||
SourceUnqueueBuffers(sid, numEntries, buf);
|
SourceUnqueueBuffers(sid, numEntries, buf);
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -1247,8 +1262,14 @@ namespace OpenTK.Audio.OpenAL
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public static void DeleteBuffers(uint[] buffers)
|
public static void DeleteBuffers(uint[] buffers)
|
||||||
{
|
{
|
||||||
if (buffers == null) throw new ArgumentNullException();
|
if (buffers == null)
|
||||||
if (buffers.Length == 0) throw new ArgumentOutOfRangeException();
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
if (buffers.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
DeleteBuffers(buffers.Length, ref buffers[0]);
|
DeleteBuffers(buffers.Length, ref buffers[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,8 +1277,14 @@ namespace OpenTK.Audio.OpenAL
|
||||||
/// <param name="buffers">Pointer to an array of buffer names identifying the buffers to be deleted.</param>
|
/// <param name="buffers">Pointer to an array of buffer names identifying the buffers to be deleted.</param>
|
||||||
public static void DeleteBuffers(int[] buffers)
|
public static void DeleteBuffers(int[] buffers)
|
||||||
{
|
{
|
||||||
if (buffers == null) throw new ArgumentNullException();
|
if (buffers == null)
|
||||||
if (buffers.Length == 0) throw new ArgumentOutOfRangeException();
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
if (buffers.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
DeleteBuffers(buffers.Length, ref buffers[0]);
|
DeleteBuffers(buffers.Length, ref buffers[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1323,7 +1350,9 @@ namespace OpenTK.Audio.OpenAL
|
||||||
where TBuffer : struct
|
where TBuffer : struct
|
||||||
{
|
{
|
||||||
if (!BlittableValueType.Check(buffer))
|
if (!BlittableValueType.Check(buffer))
|
||||||
|
{
|
||||||
throw new ArgumentException("buffer");
|
throw new ArgumentException("buffer");
|
||||||
|
}
|
||||||
|
|
||||||
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
||||||
try { BufferData(bid, format, handle.AddrOfPinnedObject(), size, freq); }
|
try { BufferData(bid, format, handle.AddrOfPinnedObject(), size, freq); }
|
||||||
|
|
|
@ -141,7 +141,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public int[] GenEffects(int n)
|
public int[] GenEffects(int n)
|
||||||
{
|
{
|
||||||
if (n <= 0) throw new ArgumentOutOfRangeException("n", "Must be higher than 0.");
|
if (n <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("n", "Must be higher than 0.");
|
||||||
|
}
|
||||||
int[] effects = new int[n];
|
int[] effects = new int[n];
|
||||||
GenEffects(n, out effects[0]);
|
GenEffects(n, out effects[0]);
|
||||||
return effects;
|
return effects;
|
||||||
|
@ -216,7 +219,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
/// <param name="effects">Pointer to n Effect object identifiers.</param>
|
/// <param name="effects">Pointer to n Effect object identifiers.</param>
|
||||||
public void DeleteEffects(int[] effects)
|
public void DeleteEffects(int[] effects)
|
||||||
{
|
{
|
||||||
if (effects == null) throw new ArgumentNullException("effects");
|
if (effects == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("effects");
|
||||||
|
}
|
||||||
DeleteEffects(effects.Length, ref effects[0]);
|
DeleteEffects(effects.Length, ref effects[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +231,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public void DeleteEffects(uint[] effects)
|
public void DeleteEffects(uint[] effects)
|
||||||
{
|
{
|
||||||
if (effects == null) throw new ArgumentNullException("effects");
|
if (effects == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("effects");
|
||||||
|
}
|
||||||
DeleteEffects(effects.Length, ref effects[0]);
|
DeleteEffects(effects.Length, ref effects[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +525,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
public int[] GenFilters(int n)
|
public int[] GenFilters(int n)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (n <= 0) throw new ArgumentOutOfRangeException("n", "Must be higher than 0.");
|
if (n <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("n", "Must be higher than 0.");
|
||||||
|
}
|
||||||
int[] filters = new int[n];
|
int[] filters = new int[n];
|
||||||
GenFilters(filters.Length, out filters[0]);
|
GenFilters(filters.Length, out filters[0]);
|
||||||
return filters;
|
return filters;
|
||||||
|
@ -587,7 +599,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public void DeleteFilters(uint[] filters)
|
public void DeleteFilters(uint[] filters)
|
||||||
{
|
{
|
||||||
if (filters == null) throw new ArgumentNullException("filters");
|
if (filters == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("filters");
|
||||||
|
}
|
||||||
DeleteFilters(filters.Length, ref filters[0]);
|
DeleteFilters(filters.Length, ref filters[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +610,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
/// <param name="filters">Pointer to an filter name/handle identifying the Filter Object to be deleted.</param>
|
/// <param name="filters">Pointer to an filter name/handle identifying the Filter Object to be deleted.</param>
|
||||||
public void DeleteFilters(int[] filters)
|
public void DeleteFilters(int[] filters)
|
||||||
{
|
{
|
||||||
if (filters == null) throw new ArgumentNullException("filters");
|
if (filters == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("filters");
|
||||||
|
}
|
||||||
DeleteFilters(filters.Length, ref filters[0]);
|
DeleteFilters(filters.Length, ref filters[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,7 +835,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
/// <returns>Pointer addressing sufficient memory to store n Effect Slot object identifiers.</returns>
|
/// <returns>Pointer addressing sufficient memory to store n Effect Slot object identifiers.</returns>
|
||||||
public int[] GenAuxiliaryEffectSlots(int n)
|
public int[] GenAuxiliaryEffectSlots(int n)
|
||||||
{
|
{
|
||||||
if (n <= 0) throw new ArgumentOutOfRangeException("n", "Must be higher than 0.");
|
if (n <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("n", "Must be higher than 0.");
|
||||||
|
}
|
||||||
int[] slots = new int[n];
|
int[] slots = new int[n];
|
||||||
GenAuxiliaryEffectSlots(slots.Length, out slots[0]);
|
GenAuxiliaryEffectSlots(slots.Length, out slots[0]);
|
||||||
return slots;
|
return slots;
|
||||||
|
@ -885,7 +906,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
/// <param name="slots">Pointer to n Effect Slot object identifiers.</param>
|
/// <param name="slots">Pointer to n Effect Slot object identifiers.</param>
|
||||||
public void DeleteAuxiliaryEffectSlots(int[] slots)
|
public void DeleteAuxiliaryEffectSlots(int[] slots)
|
||||||
{
|
{
|
||||||
if (slots == null) throw new ArgumentNullException("slots");
|
if (slots == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("slots");
|
||||||
|
}
|
||||||
DeleteAuxiliaryEffectSlots(slots.Length, ref slots[0]);
|
DeleteAuxiliaryEffectSlots(slots.Length, ref slots[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,7 +918,10 @@ namespace OpenTK.Audio.OpenAL
|
||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public void DeleteAuxiliaryEffectSlots(uint[] slots)
|
public void DeleteAuxiliaryEffectSlots(uint[] slots)
|
||||||
{
|
{
|
||||||
if (slots == null) throw new ArgumentNullException("slots");
|
if (slots == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("slots");
|
||||||
|
}
|
||||||
DeleteAuxiliaryEffectSlots(slots.Length, ref slots[0]);
|
DeleteAuxiliaryEffectSlots(slots.Length, ref slots[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,7 +1108,9 @@ namespace OpenTK.Audio.OpenAL
|
||||||
IsInitialized = 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.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!AudioContext.CurrentContext.SupportsExtension("ALC_EXT_EFX"))
|
if (!AudioContext.CurrentContext.SupportsExtension("ALC_EXT_EFX"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,9 @@ namespace OpenTK.Audio.OpenAL
|
||||||
{ // Query if Extension supported and retrieve Tokens/Pointers if it is.
|
{ // Query if Extension supported and retrieve Tokens/Pointers if it is.
|
||||||
IsInitialized = false;
|
IsInitialized = false;
|
||||||
if (AL.IsExtensionPresent("EAX-RAM") == false)
|
if (AL.IsExtensionPresent("EAX-RAM") == false)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AL_EAX_RAM_SIZE = AL.GetEnumValue("AL_EAX_RAM_SIZE");
|
AL_EAX_RAM_SIZE = AL.GetEnumValue("AL_EAX_RAM_SIZE");
|
||||||
AL_EAX_RAM_FREE = AL.GetEnumValue("AL_EAX_RAM_FREE");
|
AL_EAX_RAM_FREE = AL.GetEnumValue("AL_EAX_RAM_FREE");
|
||||||
|
@ -150,9 +152,13 @@ namespace OpenTK.Audio.OpenAL
|
||||||
int tempresult = Imported_GetBufferMode(buffer, IntPtr.Zero); // IntPtr.Zero due to the parameter being unused/reserved atm
|
int tempresult = Imported_GetBufferMode(buffer, IntPtr.Zero); // IntPtr.Zero due to the parameter being unused/reserved atm
|
||||||
|
|
||||||
if (tempresult == AL_STORAGE_ACCESSIBLE)
|
if (tempresult == AL_STORAGE_ACCESSIBLE)
|
||||||
|
{
|
||||||
return XRamStorage.Accessible;
|
return XRamStorage.Accessible;
|
||||||
|
}
|
||||||
if (tempresult == AL_STORAGE_HARDWARE)
|
if (tempresult == AL_STORAGE_HARDWARE)
|
||||||
|
{
|
||||||
return XRamStorage.Hardware;
|
return XRamStorage.Hardware;
|
||||||
|
}
|
||||||
// default:
|
// default:
|
||||||
return XRamStorage.Automatic;
|
return XRamStorage.Automatic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,13 @@ namespace OpenTK
|
||||||
protected static void MarshalPtrToStringBuilder(IntPtr ptr, StringBuilder sb)
|
protected static void MarshalPtrToStringBuilder(IntPtr ptr, StringBuilder sb)
|
||||||
{
|
{
|
||||||
if (ptr == IntPtr.Zero)
|
if (ptr == IntPtr.Zero)
|
||||||
|
{
|
||||||
throw new ArgumentException("ptr");
|
throw new ArgumentException("ptr");
|
||||||
|
}
|
||||||
if (sb == null)
|
if (sb == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("sb");
|
throw new ArgumentNullException("sb");
|
||||||
|
}
|
||||||
|
|
||||||
sb.Length = 0;
|
sb.Length = 0;
|
||||||
for (int i = 0; ; i++)
|
for (int i = 0; ; i++)
|
||||||
|
|
|
@ -80,7 +80,9 @@ namespace OpenTK
|
||||||
public static bool Check(Type type)
|
public static bool Check(Type type)
|
||||||
{
|
{
|
||||||
if (!CheckStructLayoutAttribute(type))
|
if (!CheckStructLayoutAttribute(type))
|
||||||
|
{
|
||||||
Debug.Print("Warning: type {0} does not specify a StructLayoutAttribute with Pack=1. The memory layout of the struct may change between platforms.", type.Name);
|
Debug.Print("Warning: type {0} does not specify a StructLayoutAttribute with Pack=1. The memory layout of the struct may change between platforms.", type.Name);
|
||||||
|
}
|
||||||
|
|
||||||
return CheckType(type);
|
return CheckType(type);
|
||||||
}
|
}
|
||||||
|
@ -91,17 +93,23 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
//Debug.Print("Checking type {0} (size: {1} bytes).", type.Name, Marshal.SizeOf(type));
|
//Debug.Print("Checking type {0} (size: {1} bytes).", type.Name, Marshal.SizeOf(type));
|
||||||
if (type.IsPrimitive)
|
if (type.IsPrimitive)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!type.IsValueType)
|
if (!type.IsValueType)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
foreach (FieldInfo field in fields)
|
foreach (FieldInfo field in fields)
|
||||||
{
|
{
|
||||||
if (!CheckType(field.FieldType))
|
if (!CheckType(field.FieldType))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Debug.Unindent();
|
Debug.Unindent();
|
||||||
|
|
||||||
|
@ -117,7 +125,9 @@ namespace OpenTK
|
||||||
|
|
||||||
if ((attr == null) ||
|
if ((attr == null) ||
|
||||||
(attr != null && attr.Length > 0 && attr[0].Value != LayoutKind.Explicit && attr[0].Pack != 1))
|
(attr != null && attr.Length > 0 && attr[0].Value != LayoutKind.Explicit && attr[0].Pack != 1))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +206,9 @@ namespace OpenTK
|
||||||
public static int StrideOf<T>(T type)
|
public static int StrideOf<T>(T type)
|
||||||
{
|
{
|
||||||
if (!Check(type))
|
if (!Check(type))
|
||||||
|
{
|
||||||
throw new ArgumentException("type");
|
throw new ArgumentException("type");
|
||||||
|
}
|
||||||
|
|
||||||
return BlittableValueType<T>.Stride;
|
return BlittableValueType<T>.Stride;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +224,9 @@ namespace OpenTK
|
||||||
public static int StrideOf<T>(T[] type)
|
public static int StrideOf<T>(T[] type)
|
||||||
{
|
{
|
||||||
if (!Check(type))
|
if (!Check(type))
|
||||||
|
{
|
||||||
throw new ArgumentException("type");
|
throw new ArgumentException("type");
|
||||||
|
}
|
||||||
|
|
||||||
return BlittableValueType<T>.Stride;
|
return BlittableValueType<T>.Stride;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +242,9 @@ namespace OpenTK
|
||||||
public static int StrideOf<T>(T[,] type)
|
public static int StrideOf<T>(T[,] type)
|
||||||
{
|
{
|
||||||
if (!Check(type))
|
if (!Check(type))
|
||||||
|
{
|
||||||
throw new ArgumentException("type");
|
throw new ArgumentException("type");
|
||||||
|
}
|
||||||
|
|
||||||
return BlittableValueType<T>.Stride;
|
return BlittableValueType<T>.Stride;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +260,9 @@ namespace OpenTK
|
||||||
public static int StrideOf<T>(T[, ,] type)
|
public static int StrideOf<T>(T[, ,] type)
|
||||||
{
|
{
|
||||||
if (!Check(type))
|
if (!Check(type))
|
||||||
|
{
|
||||||
throw new ArgumentException("type");
|
throw new ArgumentException("type");
|
||||||
|
}
|
||||||
|
|
||||||
return BlittableValueType<T>.Stride;
|
return BlittableValueType<T>.Stride;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is ContextHandle)
|
if (obj is ContextHandle)
|
||||||
|
{
|
||||||
return this.Equals((ContextHandle)obj);
|
return this.Equals((ContextHandle)obj);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,13 +122,17 @@ namespace OpenTK
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (value && primary_display != null && primary_display != this)
|
if (value && primary_display != null && primary_display != this)
|
||||||
|
{
|
||||||
primary_display.IsPrimary = false;
|
primary_display.IsPrimary = false;
|
||||||
|
}
|
||||||
|
|
||||||
lock (display_lock)
|
lock (display_lock)
|
||||||
{
|
{
|
||||||
primary = value;
|
primary = value;
|
||||||
if (value)
|
if (value)
|
||||||
|
{
|
||||||
primary_display = this;
|
primary_display = this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,11 +157,17 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
DisplayResolution resolution = FindResolution(width, height, bitsPerPixel, refreshRate);
|
DisplayResolution resolution = FindResolution(width, height, bitsPerPixel, refreshRate);
|
||||||
if (resolution == null)
|
if (resolution == null)
|
||||||
|
{
|
||||||
resolution = FindResolution(width, height, bitsPerPixel, 0);
|
resolution = FindResolution(width, height, bitsPerPixel, 0);
|
||||||
|
}
|
||||||
if (resolution == null)
|
if (resolution == null)
|
||||||
|
{
|
||||||
resolution = FindResolution(width, height, 0, 0);
|
resolution = FindResolution(width, height, 0, 0);
|
||||||
|
}
|
||||||
if (resolution == null)
|
if (resolution == null)
|
||||||
|
{
|
||||||
return current_resolution;
|
return current_resolution;
|
||||||
|
}
|
||||||
return resolution;
|
return resolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,21 +191,30 @@ namespace OpenTK
|
||||||
public void ChangeResolution(DisplayResolution resolution)
|
public void ChangeResolution(DisplayResolution resolution)
|
||||||
{
|
{
|
||||||
if (resolution == null)
|
if (resolution == null)
|
||||||
|
{
|
||||||
this.RestoreResolution();
|
this.RestoreResolution();
|
||||||
|
}
|
||||||
|
|
||||||
if (resolution == current_resolution)
|
if (resolution == current_resolution)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//effect.FadeOut();
|
//effect.FadeOut();
|
||||||
|
|
||||||
if (implementation.TryChangeResolution(this, resolution))
|
if (implementation.TryChangeResolution(this, resolution))
|
||||||
{
|
{
|
||||||
if (OriginalResolution == null)
|
if (OriginalResolution == null)
|
||||||
|
{
|
||||||
OriginalResolution = 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}.",
|
||||||
this, resolution));
|
this, resolution));
|
||||||
|
}
|
||||||
|
|
||||||
//effect.FadeIn();
|
//effect.FadeIn();
|
||||||
}
|
}
|
||||||
|
@ -224,7 +243,10 @@ namespace OpenTK
|
||||||
current_resolution = OriginalResolution;
|
current_resolution = OriginalResolution;
|
||||||
OriginalResolution = 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));
|
||||||
|
}
|
||||||
|
|
||||||
//effect.FadeIn();
|
//effect.FadeIn();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,22 @@ namespace OpenTK
|
||||||
internal DisplayResolution(int x, int y, int width, int height, int bitsPerPixel, float refreshRate)
|
internal DisplayResolution(int x, int y, int width, int height, int bitsPerPixel, float refreshRate)
|
||||||
{
|
{
|
||||||
// Refresh rate may be zero, since this information may not be available on some platforms.
|
// Refresh rate may be zero, since this information may not be available on some platforms.
|
||||||
if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
|
if (width <= 0)
|
||||||
if (height <= 0) throw new ArgumentOutOfRangeException("height", "Must be greater than zero.");
|
{
|
||||||
if (bitsPerPixel <= 0) throw new ArgumentOutOfRangeException("bitsPerPixel", "Must be greater than zero.");
|
throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
|
||||||
if (refreshRate < 0) throw new ArgumentOutOfRangeException("refreshRate", "Must be greater than, or equal to zero.");
|
}
|
||||||
|
if (height <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("height", "Must be greater than zero.");
|
||||||
|
}
|
||||||
|
if (bitsPerPixel <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("bitsPerPixel", "Must be greater than 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.BitsPerPixel = bitsPerPixel;
|
this.BitsPerPixel = bitsPerPixel;
|
||||||
|
@ -112,7 +124,10 @@ namespace OpenTK
|
||||||
/// <returns>True if the System.Object is an equal DisplayResolution; false otherwise.</returns>
|
/// <returns>True if the System.Object is an equal DisplayResolution; false otherwise.</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj == null) return false;
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (this.GetType() == obj.GetType())
|
if (this.GetType() == obj.GetType())
|
||||||
{
|
{
|
||||||
DisplayResolution res = (DisplayResolution)obj;
|
DisplayResolution res = (DisplayResolution)obj;
|
||||||
|
@ -144,10 +159,14 @@ namespace OpenTK
|
||||||
public static bool operator== (DisplayResolution left, DisplayResolution right)
|
public static bool operator== (DisplayResolution left, DisplayResolution right)
|
||||||
{
|
{
|
||||||
if (((object)left) == null && ((object)right) == null)
|
if (((object)left) == null && ((object)right) == null)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
else if ((((object)left) == null && ((object)right) != null) ||
|
else if ((((object)left) == null && ((object)right) != null) ||
|
||||||
(((object)left) != null && ((object)right) == null))
|
(((object)left) != null && ((object)right) == null))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return left.Equals(right);
|
return left.Equals(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,9 @@ namespace OpenTK
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (value <= 0)
|
if (value <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
elapsed = value;
|
elapsed = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,11 +310,15 @@ namespace OpenTK
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (updates_per_second < 0.0 || updates_per_second > 200.0)
|
if (updates_per_second < 0.0 || updates_per_second > 200.0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("updates_per_second", updates_per_second,
|
throw new ArgumentOutOfRangeException("updates_per_second", updates_per_second,
|
||||||
"Parameter should be inside the range [0.0, 200.0]");
|
"Parameter should be inside the range [0.0, 200.0]");
|
||||||
|
}
|
||||||
if (frames_per_second < 0.0 || frames_per_second > 200.0)
|
if (frames_per_second < 0.0 || frames_per_second > 200.0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("frames_per_second", frames_per_second,
|
throw new ArgumentOutOfRangeException("frames_per_second", frames_per_second,
|
||||||
"Parameter should be inside the range [0.0, 200.0]");
|
"Parameter should be inside the range [0.0, 200.0]");
|
||||||
|
}
|
||||||
|
|
||||||
if (updates_per_second != 0)
|
if (updates_per_second != 0)
|
||||||
{
|
{
|
||||||
|
@ -342,9 +346,13 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
ProcessEvents();
|
ProcessEvents();
|
||||||
if (Exists && !IsExiting)
|
if (Exists && !IsExiting)
|
||||||
|
{
|
||||||
DispatchUpdateAndRenderFrame(this, EventArgs.Empty);
|
DispatchUpdateAndRenderFrame(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -494,7 +502,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
EnsureUndisposed();
|
EnsureUndisposed();
|
||||||
if (render_period == 0.0)
|
if (render_period == 0.0)
|
||||||
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
}
|
||||||
return 1.0 / render_period;
|
return 1.0 / render_period;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -541,7 +551,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
EnsureUndisposed();
|
EnsureUndisposed();
|
||||||
if (TargetRenderPeriod == 0.0)
|
if (TargetRenderPeriod == 0.0)
|
||||||
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
}
|
||||||
return 1.0 / TargetRenderPeriod;
|
return 1.0 / TargetRenderPeriod;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
@ -555,7 +567,10 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
TargetRenderPeriod = 1.0 / value;
|
TargetRenderPeriod = 1.0 / value;
|
||||||
}
|
}
|
||||||
else Debug.Print("Target render frequency clamped to {0}Hz.", MaxFrequency);
|
else
|
||||||
|
{
|
||||||
|
Debug.Print("Target render frequency clamped to {0}Hz.", MaxFrequency);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,7 +599,10 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
target_render_period = value;
|
target_render_period = value;
|
||||||
}
|
}
|
||||||
else Debug.Print("Target render period clamped to 1.0 seconds.");
|
else
|
||||||
|
{
|
||||||
|
Debug.Print("Target render period clamped to 1.0 seconds.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +619,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
EnsureUndisposed();
|
EnsureUndisposed();
|
||||||
if (TargetUpdatePeriod == 0.0)
|
if (TargetUpdatePeriod == 0.0)
|
||||||
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
}
|
||||||
return 1.0 / TargetUpdatePeriod;
|
return 1.0 / TargetUpdatePeriod;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
@ -615,7 +635,10 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
TargetUpdatePeriod = 1.0 / value;
|
TargetUpdatePeriod = 1.0 / value;
|
||||||
}
|
}
|
||||||
else Debug.Print("Target render frequency clamped to {0}Hz.", MaxFrequency);
|
else
|
||||||
|
{
|
||||||
|
Debug.Print("Target render frequency clamped to {0}Hz.", MaxFrequency);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +667,10 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
target_update_period = value;
|
target_update_period = value;
|
||||||
}
|
}
|
||||||
else Debug.Print("Target update period clamped to 1.0 seconds.");
|
else
|
||||||
|
{
|
||||||
|
Debug.Print("Target update period clamped to 1.0 seconds.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +683,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
EnsureUndisposed();
|
EnsureUndisposed();
|
||||||
if (update_period == 0.0)
|
if (update_period == 0.0)
|
||||||
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
}
|
||||||
return 1.0 / update_period;
|
return 1.0 / update_period;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -744,7 +772,9 @@ namespace OpenTK
|
||||||
Debug.Print("Updating Context after setting WindowState to {0}", value);
|
Debug.Print("Updating Context after setting WindowState to {0}", value);
|
||||||
|
|
||||||
if (Context != null)
|
if (Context != null)
|
||||||
|
{
|
||||||
Context.Update(WindowInfo);
|
Context.Update(WindowInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -823,11 +853,19 @@ namespace OpenTK
|
||||||
OnLoad(e);
|
OnLoad(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRenderFrameInternal(FrameEventArgs e) { if (Exists && !isExiting) OnRenderFrame(e); }
|
private void OnRenderFrameInternal(FrameEventArgs e) { if (Exists && !isExiting)
|
||||||
|
{
|
||||||
|
OnRenderFrame(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnUnloadInternal(EventArgs e) { OnUnload(e); }
|
private void OnUnloadInternal(EventArgs e) { OnUnload(e); }
|
||||||
|
|
||||||
private void OnUpdateFrameInternal(FrameEventArgs e) { if (Exists && !isExiting) OnUpdateFrame(e); }
|
private void OnUpdateFrameInternal(FrameEventArgs e) { if (Exists && !isExiting)
|
||||||
|
{
|
||||||
|
OnUpdateFrame(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnWindowInfoChangedInternal(EventArgs e)
|
private void OnWindowInfoChangedInternal(EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -159,7 +159,9 @@ namespace OpenTK.Graphics
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Color4))
|
if (!(obj is Color4))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return Equals((Color4)obj);
|
return Equals((Color4)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,9 @@ namespace OpenTK.Graphics
|
||||||
public ColorFormat(int bpp)
|
public ColorFormat(int bpp)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -96,7 +98,9 @@ namespace OpenTK.Graphics
|
||||||
public ColorFormat(int red, int green, int blue, int alpha)
|
public ColorFormat(int red, int green, int blue, int alpha)
|
||||||
{
|
{
|
||||||
if (red < 0 || green < 0 || blue < 0 || alpha < 0)
|
if (red < 0 || green < 0 || blue < 0 || alpha < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("Arguments must be greater or equal to zero.");
|
throw new ArgumentOutOfRangeException("Arguments must be greater or equal to zero.");
|
||||||
|
}
|
||||||
this.red = (byte)red;
|
this.red = (byte)red;
|
||||||
this.green = (byte)green;
|
this.green = (byte)green;
|
||||||
this.blue = (byte)blue;
|
this.blue = (byte)blue;
|
||||||
|
@ -104,7 +108,9 @@ namespace OpenTK.Graphics
|
||||||
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>
|
||||||
|
@ -154,10 +160,14 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
int result = BitsPerPixel.CompareTo(other.BitsPerPixel);
|
int result = BitsPerPixel.CompareTo(other.BitsPerPixel);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
result = IsIndexed.CompareTo(other.IsIndexed);
|
result = IsIndexed.CompareTo(other.IsIndexed);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
result = Alpha.CompareTo(other.Alpha);
|
result = Alpha.CompareTo(other.Alpha);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,13 +52,17 @@ namespace OpenTK.Graphics.ES10
|
||||||
public ErrorHelper(IGraphicsContext context)
|
public ErrorHelper(IGraphicsContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
|
|
||||||
Context = (GraphicsContext)context;
|
Context = (GraphicsContext)context;
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
if (!ContextErrors.ContainsKey(Context))
|
if (!ContextErrors.ContainsKey(Context))
|
||||||
|
{
|
||||||
ContextErrors.Add(Context, new List<ErrorCode>());
|
ContextErrors.Add(Context, new List<ErrorCode>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ResetErrors();
|
ResetErrors();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +105,9 @@ namespace OpenTK.Graphics.ES10
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,17 @@ namespace OpenTK.Graphics.ES11
|
||||||
public ErrorHelper(IGraphicsContext context)
|
public ErrorHelper(IGraphicsContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
|
|
||||||
Context = (GraphicsContext)context;
|
Context = (GraphicsContext)context;
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
if (!ContextErrors.ContainsKey(Context))
|
if (!ContextErrors.ContainsKey(Context))
|
||||||
|
{
|
||||||
ContextErrors.Add(Context, new List<ErrorCode>());
|
ContextErrors.Add(Context, new List<ErrorCode>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ResetErrors();
|
ResetErrors();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +105,9 @@ namespace OpenTK.Graphics.ES11
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,17 @@ namespace OpenTK.Graphics.ES20
|
||||||
public ErrorHelper(IGraphicsContext context)
|
public ErrorHelper(IGraphicsContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
|
|
||||||
Context = (GraphicsContext)context;
|
Context = (GraphicsContext)context;
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
if (!ContextErrors.ContainsKey(Context))
|
if (!ContextErrors.ContainsKey(Context))
|
||||||
|
{
|
||||||
ContextErrors.Add(Context, new List<ErrorCode>());
|
ContextErrors.Add(Context, new List<ErrorCode>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ResetErrors();
|
ResetErrors();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +105,9 @@ namespace OpenTK.Graphics.ES20
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,9 @@ namespace OpenTK.Graphics.ES20
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector2* ptr = &vector)
|
fixed (Vector2* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +313,9 @@ namespace OpenTK.Graphics.ES20
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector3* ptr = &vector)
|
fixed (Vector3* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +324,9 @@ namespace OpenTK.Graphics.ES20
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector4* ptr = &vector)
|
fixed (Vector4* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +335,9 @@ namespace OpenTK.Graphics.ES20
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Matrix4* ptr = &matrix)
|
fixed (Matrix4* ptr = &matrix)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,17 @@ namespace OpenTK.Graphics.ES30
|
||||||
public ErrorHelper(IGraphicsContext context)
|
public ErrorHelper(IGraphicsContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
|
|
||||||
Context = (GraphicsContext)context;
|
Context = (GraphicsContext)context;
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
if (!ContextErrors.ContainsKey(Context))
|
if (!ContextErrors.ContainsKey(Context))
|
||||||
|
{
|
||||||
ContextErrors.Add(Context, new List<ErrorCode>());
|
ContextErrors.Add(Context, new List<ErrorCode>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ResetErrors();
|
ResetErrors();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +105,9 @@ namespace OpenTK.Graphics.ES30
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
||||||
|
|
||||||
|
|
|
@ -297,7 +297,9 @@ namespace OpenTK.Graphics.ES30
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector2* ptr = &vector)
|
fixed (Vector2* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +308,9 @@ namespace OpenTK.Graphics.ES30
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector3* ptr = &vector)
|
fixed (Vector3* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +319,9 @@ namespace OpenTK.Graphics.ES30
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector4* ptr = &vector)
|
fixed (Vector4* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +330,9 @@ namespace OpenTK.Graphics.ES30
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Matrix4* ptr = &matrix)
|
fixed (Matrix4* ptr = &matrix)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,9 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
var context = GraphicsContext.CurrentContext as IGraphicsContextInternal;
|
var context = GraphicsContext.CurrentContext as IGraphicsContextInternal;
|
||||||
if (context == null)
|
if (context == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
return context != null ? context.GetAddress(funcname) : IntPtr.Zero;
|
return context != null ? context.GetAddress(funcname) : IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +73,9 @@ namespace OpenTK.Graphics
|
||||||
|
|
||||||
IGraphicsContext context = GraphicsContext.CurrentContext;
|
IGraphicsContext context = GraphicsContext.CurrentContext;
|
||||||
if (context == null)
|
if (context == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
|
|
||||||
IGraphicsContextInternal context_internal = context as IGraphicsContextInternal;
|
IGraphicsContextInternal context_internal = context as IGraphicsContextInternal;
|
||||||
unsafe
|
unsafe
|
||||||
|
|
|
@ -110,15 +110,27 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
bool designMode = false;
|
bool designMode = false;
|
||||||
if (mode == null && window == null)
|
if (mode == null && window == null)
|
||||||
|
{
|
||||||
designMode = true;
|
designMode = true;
|
||||||
else if (mode == null) throw new ArgumentNullException("mode", "Must be a valid GraphicsMode.");
|
}
|
||||||
else if (window == null) throw new ArgumentNullException("window", "Must point to a valid window.");
|
else if (mode == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("mode", "Must be a valid GraphicsMode.");
|
||||||
|
}
|
||||||
|
else if (window == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("window", "Must point to a valid window.");
|
||||||
|
}
|
||||||
|
|
||||||
// Silently ignore invalid major and minor versions.
|
// Silently ignore invalid major and minor versions.
|
||||||
if (major <= 0)
|
if (major <= 0)
|
||||||
|
{
|
||||||
major = 1;
|
major = 1;
|
||||||
|
}
|
||||||
if (minor < 0)
|
if (minor < 0)
|
||||||
|
{
|
||||||
minor = 0;
|
minor = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Angle needs an embedded context
|
// Angle needs an embedded context
|
||||||
const GraphicsContextFlags useAngleFlag = GraphicsContextFlags.Angle
|
const GraphicsContextFlags useAngleFlag = GraphicsContextFlags.Angle
|
||||||
|
@ -209,7 +221,9 @@ namespace OpenTK.Graphics
|
||||||
public GraphicsContext(ContextHandle handle, GetAddressDelegate getAddress, GetCurrentContextDelegate getCurrent)
|
public GraphicsContext(ContextHandle handle, GetAddressDelegate getAddress, GetCurrentContextDelegate getCurrent)
|
||||||
{
|
{
|
||||||
if (getAddress == null || getCurrent == null)
|
if (getAddress == null || getCurrent == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure OpenTK has been initialized.
|
// Make sure OpenTK has been initialized.
|
||||||
// Fixes https://github.com/opentk/opentk/issues/52
|
// Fixes https://github.com/opentk/opentk/issues/52
|
||||||
|
@ -334,7 +348,9 @@ namespace OpenTK.Graphics
|
||||||
// making this return null even if another valid context exists.
|
// making this return null even if another valid context exists.
|
||||||
// The workaround is to simply ignore null targets.
|
// The workaround is to simply ignore null targets.
|
||||||
if (target != null)
|
if (target != null)
|
||||||
|
{
|
||||||
return target;
|
return target;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -347,7 +363,9 @@ namespace OpenTK.Graphics
|
||||||
public static void Assert()
|
public static void Assert()
|
||||||
{
|
{
|
||||||
if (GraphicsContext.CurrentContext == null)
|
if (GraphicsContext.CurrentContext == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static GetCurrentContextDelegate GetCurrentContext;
|
internal static GetCurrentContextDelegate GetCurrentContext;
|
||||||
|
@ -377,7 +395,9 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
ContextHandle handle = CurrentContextHandle;
|
ContextHandle handle = CurrentContextHandle;
|
||||||
if (handle.Handle != IntPtr.Zero)
|
if (handle.Handle != IntPtr.Zero)
|
||||||
|
{
|
||||||
return (IGraphicsContext)available_contexts[handle];
|
return (IGraphicsContext)available_contexts[handle];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -483,7 +503,9 @@ namespace OpenTK.Graphics
|
||||||
public void LoadAll()
|
public void LoadAll()
|
||||||
{
|
{
|
||||||
if (GraphicsContext.CurrentContext != this)
|
if (GraphicsContext.CurrentContext != this)
|
||||||
|
{
|
||||||
throw new GraphicsContextException();
|
throw new GraphicsContextException();
|
||||||
|
}
|
||||||
|
|
||||||
implementation.LoadAll();
|
implementation.LoadAll();
|
||||||
}
|
}
|
||||||
|
@ -578,7 +600,9 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
Debug.Print("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString());
|
Debug.Print("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString());
|
||||||
if (implementation != null)
|
if (implementation != null)
|
||||||
|
{
|
||||||
implementation.Dispose();
|
implementation.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,9 +53,13 @@ namespace OpenTK.Graphics
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value && SwapInterval <= 0)
|
if (value && SwapInterval <= 0)
|
||||||
|
{
|
||||||
SwapInterval = 1;
|
SwapInterval = 1;
|
||||||
|
}
|
||||||
else if (!value && SwapInterval > 0)
|
else if (!value && SwapInterval > 0)
|
||||||
|
{
|
||||||
SwapInterval = 0;
|
SwapInterval = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,22 @@ namespace OpenTK.Graphics
|
||||||
internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int samples, ColorFormat accum,
|
internal GraphicsMode(IntPtr? index, ColorFormat color, int depth, int stencil, int samples, ColorFormat accum,
|
||||||
int buffers, bool stereo)
|
int buffers, bool stereo)
|
||||||
{
|
{
|
||||||
if (depth < 0) throw new ArgumentOutOfRangeException("depth", "Must be greater than, or equal to zero.");
|
if (depth < 0)
|
||||||
if (stencil < 0) throw new ArgumentOutOfRangeException("stencil", "Must be greater than, or equal to zero.");
|
{
|
||||||
if (buffers < 0) throw new ArgumentOutOfRangeException("buffers", "Must be greater than, or equal to zero.");
|
throw new ArgumentOutOfRangeException("depth", "Must be greater than, or equal to zero.");
|
||||||
if (samples < 0) throw new ArgumentOutOfRangeException("samples", "Must be greater than, or equal to zero.");
|
}
|
||||||
|
if (stencil < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("stencil", "Must be greater than, or equal to zero.");
|
||||||
|
}
|
||||||
|
if (buffers < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("buffers", "Must be greater than, or equal to zero.");
|
||||||
|
}
|
||||||
|
if (samples < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("samples", "Must be greater than, or equal to zero.");
|
||||||
|
}
|
||||||
|
|
||||||
this.Index = index;
|
this.Index = index;
|
||||||
this.ColorFormat = color;
|
this.ColorFormat = color;
|
||||||
|
|
|
@ -35,22 +35,34 @@ namespace OpenTK.Graphics
|
||||||
{
|
{
|
||||||
int result = x.ColorFormat.CompareTo(y.ColorFormat);
|
int result = x.ColorFormat.CompareTo(y.ColorFormat);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
result = x.Depth.CompareTo(y.Depth);
|
result = x.Depth.CompareTo(y.Depth);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
result = x.Stencil.CompareTo(y.Stencil);
|
result = x.Stencil.CompareTo(y.Stencil);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
result = x.Samples.CompareTo(y.Samples);
|
result = x.Samples.CompareTo(y.Samples);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
result = x.Stereo.CompareTo(y.Stereo);
|
result = x.Stereo.CompareTo(y.Stereo);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
result = x.Buffers.CompareTo(y.Buffers);
|
result = x.Buffers.CompareTo(y.Buffers);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
|
{
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
return x.AccumulatorFormat.CompareTo(y.AccumulatorFormat);
|
return x.AccumulatorFormat.CompareTo(y.AccumulatorFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,13 +52,17 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
public ErrorHelper(IGraphicsContext context)
|
public ErrorHelper(IGraphicsContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
|
|
||||||
Context = (GraphicsContext)context;
|
Context = (GraphicsContext)context;
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
if (!ContextErrors.ContainsKey(Context))
|
if (!ContextErrors.ContainsKey(Context))
|
||||||
|
{
|
||||||
ContextErrors.Add(Context, new List<ErrorCode>());
|
ContextErrors.Add(Context, new List<ErrorCode>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ResetErrors();
|
ResetErrors();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +105,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
||||||
|
|
||||||
|
|
|
@ -1132,7 +1132,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector2* ptr = &vector)
|
fixed (Vector2* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1141,7 +1143,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector3* ptr = &vector)
|
fixed (Vector3* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,7 +1154,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector4* ptr = &vector)
|
fixed (Vector4* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,7 +1165,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Matrix4* ptr = &matrix)
|
fixed (Matrix4* ptr = &matrix)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1168,7 +1176,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector2d* ptr = &vector)
|
fixed (Vector2d* ptr = &vector)
|
||||||
|
{
|
||||||
GetDouble(pname, (double*)ptr);
|
GetDouble(pname, (double*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1177,7 +1187,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector3d* ptr = &vector)
|
fixed (Vector3d* ptr = &vector)
|
||||||
|
{
|
||||||
GetDouble(pname, (double*)ptr);
|
GetDouble(pname, (double*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1186,7 +1198,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector4d* ptr = &vector)
|
fixed (Vector4d* ptr = &vector)
|
||||||
|
{
|
||||||
GetDouble(pname, (double*)ptr);
|
GetDouble(pname, (double*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,7 +1209,9 @@ namespace OpenTK.Graphics.OpenGL
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Matrix4d* ptr = &matrix)
|
fixed (Matrix4d* ptr = &matrix)
|
||||||
|
{
|
||||||
GetDouble(pname, (double*)ptr);
|
GetDouble(pname, (double*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,17 @@ namespace OpenTK.Graphics.OpenGL4
|
||||||
public ErrorHelper(IGraphicsContext context)
|
public ErrorHelper(IGraphicsContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
|
{
|
||||||
throw new GraphicsContextMissingException();
|
throw new GraphicsContextMissingException();
|
||||||
|
}
|
||||||
|
|
||||||
Context = (GraphicsContext)context;
|
Context = (GraphicsContext)context;
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
if (!ContextErrors.ContainsKey(Context))
|
if (!ContextErrors.ContainsKey(Context))
|
||||||
|
{
|
||||||
ContextErrors.Add(Context, new List<ErrorCode>());
|
ContextErrors.Add(Context, new List<ErrorCode>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ResetErrors();
|
ResetErrors();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +105,9 @@ namespace OpenTK.Graphics.OpenGL4
|
||||||
sb.Append(", ");
|
sb.Append(", ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
sb.Remove(sb.Length - 2, 2); // Remove the last comma
|
||||||
|
|
||||||
|
|
|
@ -373,7 +373,9 @@ namespace OpenTK.Graphics.OpenGL4
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector2* ptr = &vector)
|
fixed (Vector2* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +384,9 @@ namespace OpenTK.Graphics.OpenGL4
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector3* ptr = &vector)
|
fixed (Vector3* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +395,9 @@ namespace OpenTK.Graphics.OpenGL4
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Vector4* ptr = &vector)
|
fixed (Vector4* ptr = &vector)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +406,9 @@ namespace OpenTK.Graphics.OpenGL4
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
fixed (Matrix4* ptr = &matrix)
|
fixed (Matrix4* ptr = &matrix)
|
||||||
|
{
|
||||||
GetFloat(pname, (float*)ptr);
|
GetFloat(pname, (float*)ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,9 @@ namespace OpenTK.Input
|
||||||
public static GamePadCapabilities GetCapabilities(int index)
|
public static GamePadCapabilities GetCapabilities(int index)
|
||||||
{
|
{
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
|
{
|
||||||
throw new IndexOutOfRangeException();
|
throw new IndexOutOfRangeException();
|
||||||
|
}
|
||||||
|
|
||||||
return driver.GetCapabilities(index);
|
return driver.GetCapabilities(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,29 +171,53 @@ namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||||
if (A == ButtonState.Pressed)
|
if (A == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("A");
|
sb.Append("A");
|
||||||
|
}
|
||||||
if (B == ButtonState.Pressed)
|
if (B == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("B");
|
sb.Append("B");
|
||||||
|
}
|
||||||
if (X == ButtonState.Pressed)
|
if (X == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("X");
|
sb.Append("X");
|
||||||
|
}
|
||||||
if (Y == ButtonState.Pressed)
|
if (Y == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("Y");
|
sb.Append("Y");
|
||||||
|
}
|
||||||
if (Back == ButtonState.Pressed)
|
if (Back == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("Bk");
|
sb.Append("Bk");
|
||||||
|
}
|
||||||
if (Start == ButtonState.Pressed)
|
if (Start == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("St");
|
sb.Append("St");
|
||||||
|
}
|
||||||
if (BigButton == ButtonState.Pressed)
|
if (BigButton == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("Gd");
|
sb.Append("Gd");
|
||||||
|
}
|
||||||
if (Back == ButtonState.Pressed)
|
if (Back == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("Bk");
|
sb.Append("Bk");
|
||||||
|
}
|
||||||
if (LeftShoulder == ButtonState.Pressed)
|
if (LeftShoulder == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("L");
|
sb.Append("L");
|
||||||
|
}
|
||||||
if (RightShoulder == ButtonState.Pressed)
|
if (RightShoulder == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("R");
|
sb.Append("R");
|
||||||
|
}
|
||||||
if (LeftStick == ButtonState.Pressed)
|
if (LeftStick == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("Ls");
|
sb.Append("Ls");
|
||||||
|
}
|
||||||
if (RightStick == ButtonState.Pressed)
|
if (RightStick == ButtonState.Pressed)
|
||||||
|
{
|
||||||
sb.Append("Rs");
|
sb.Append("Rs");
|
||||||
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,14 +44,20 @@ namespace OpenTK.Input
|
||||||
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)
|
||||||
{
|
{
|
||||||
if (axis_count < 0 || axis_count > JoystickState.MaxAxes)
|
if (axis_count < 0 || axis_count > JoystickState.MaxAxes)
|
||||||
|
{
|
||||||
Debug.Print("[{0}] Axis count {1} out of range (0, {2})",
|
Debug.Print("[{0}] Axis count {1} out of range (0, {2})",
|
||||||
typeof(JoystickCapabilities).Name, axis_count, JoystickState.MaxAxes);
|
typeof(JoystickCapabilities).Name, axis_count, JoystickState.MaxAxes);
|
||||||
|
}
|
||||||
if (button_count < 0 || button_count > JoystickState.MaxButtons)
|
if (button_count < 0 || button_count > JoystickState.MaxButtons)
|
||||||
|
{
|
||||||
Debug.Print("[{0}] Button count {1} out of range (0, {2})",
|
Debug.Print("[{0}] Button count {1} out of range (0, {2})",
|
||||||
typeof(JoystickCapabilities).Name, button_count, JoystickState.MaxButtons);
|
typeof(JoystickCapabilities).Name, button_count, JoystickState.MaxButtons);
|
||||||
|
}
|
||||||
if (hat_count < 0 || hat_count > JoystickState.MaxHats)
|
if (hat_count < 0 || hat_count > JoystickState.MaxHats)
|
||||||
|
{
|
||||||
Debug.Print("[{0}] Hat count {1} out of range (0, {2})",
|
Debug.Print("[{0}] Hat count {1} out of range (0, {2})",
|
||||||
typeof(JoystickCapabilities).Name, hat_count, JoystickState.MaxHats);
|
typeof(JoystickCapabilities).Name, hat_count, JoystickState.MaxHats);
|
||||||
|
}
|
||||||
|
|
||||||
axis_count = MathHelper.Clamp(axis_count, 0, JoystickState.MaxAxes);
|
axis_count = MathHelper.Clamp(axis_count, 0, JoystickState.MaxAxes);
|
||||||
button_count = MathHelper.Clamp(button_count, 0, JoystickState.MaxButtons);
|
button_count = MathHelper.Clamp(button_count, 0, JoystickState.MaxButtons);
|
||||||
|
|
|
@ -39,10 +39,14 @@ namespace OpenTK.Input
|
||||||
internal JoystickDevice(int id, int axes, int buttons)
|
internal JoystickDevice(int id, int axes, int buttons)
|
||||||
{
|
{
|
||||||
if (axes < 0)
|
if (axes < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("axes");
|
throw new ArgumentOutOfRangeException("axes");
|
||||||
|
}
|
||||||
|
|
||||||
if (buttons < 0)
|
if (buttons < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("buttons");
|
throw new ArgumentOutOfRangeException("buttons");
|
||||||
|
}
|
||||||
|
|
||||||
Id = id;
|
Id = id;
|
||||||
Axis = new JoystickAxisCollection(axes);
|
Axis = new JoystickAxisCollection(axes);
|
||||||
|
@ -112,9 +116,13 @@ namespace OpenTK.Input
|
||||||
button_args.Button = button;
|
button_args.Button = button;
|
||||||
Button[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
|
||||||
|
{
|
||||||
ButtonUp(this, button_args);
|
ButtonUp(this, button_args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +219,9 @@ namespace OpenTK.Input
|
||||||
internal JoystickButtonCollection(int numButtons)
|
internal JoystickButtonCollection(int numButtons)
|
||||||
{
|
{
|
||||||
if (numButtons < 0)
|
if (numButtons < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("numButtons");
|
throw new ArgumentOutOfRangeException("numButtons");
|
||||||
|
}
|
||||||
|
|
||||||
button_state = new bool[numButtons];
|
button_state = new bool[numButtons];
|
||||||
}
|
}
|
||||||
|
@ -246,7 +256,9 @@ namespace OpenTK.Input
|
||||||
internal JoystickAxisCollection(int numAxes)
|
internal JoystickAxisCollection(int numAxes)
|
||||||
{
|
{
|
||||||
if (numAxes < 0)
|
if (numAxes < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("numAxes");
|
throw new ArgumentOutOfRangeException("numAxes");
|
||||||
|
}
|
||||||
|
|
||||||
axis_state = new float[numAxes];
|
axis_state = new float[numAxes];
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,9 @@ namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
int index = axis;
|
int index = axis;
|
||||||
if (index < 0 || index >= MaxAxes)
|
if (index < 0 || index >= MaxAxes)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("axis");
|
throw new ArgumentOutOfRangeException("axis");
|
||||||
|
}
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
|
@ -223,7 +225,9 @@ namespace OpenTK.Input
|
||||||
internal void SetButton(int button, bool value)
|
internal void SetButton(int button, bool value)
|
||||||
{
|
{
|
||||||
if (button < 0 || button >= MaxButtons)
|
if (button < 0 || button >= MaxButtons)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("button");
|
throw new ArgumentOutOfRangeException("button");
|
||||||
|
}
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,7 +59,9 @@ namespace OpenTK.Input
|
||||||
public static KeyboardState GetState(int index)
|
public static KeyboardState GetState(int index)
|
||||||
{
|
{
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("index");
|
throw new ArgumentOutOfRangeException("index");
|
||||||
|
}
|
||||||
|
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
|
|
|
@ -215,7 +215,9 @@ namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
int hashcode = 0;
|
int hashcode = 0;
|
||||||
for (int i = 0; i < NumInts; i++)
|
for (int i = 0; i < NumInts; i++)
|
||||||
|
{
|
||||||
hashcode ^= (k + i)->GetHashCode();
|
hashcode ^= (k + i)->GetHashCode();
|
||||||
|
}
|
||||||
return hashcode;
|
return hashcode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +279,9 @@ namespace OpenTK.Input
|
||||||
fixed (int* k1 = Keys)
|
fixed (int* k1 = Keys)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NumInts; i++)
|
for (int i = 0; i < NumInts; i++)
|
||||||
|
{
|
||||||
*(k1 + i) |= *(k2 + i);
|
*(k1 + i) |= *(k2 + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IsConnected |= other.IsConnected;
|
IsConnected |= other.IsConnected;
|
||||||
|
@ -291,7 +295,9 @@ namespace OpenTK.Input
|
||||||
private static void ValidateOffset(int offset)
|
private static void ValidateOffset(int offset)
|
||||||
{
|
{
|
||||||
if (offset < 0 || offset >= NumInts * IntSize)
|
if (offset < 0 || offset >= NumInts * IntSize)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -308,7 +314,9 @@ namespace OpenTK.Input
|
||||||
fixed (int* k1 = Keys)
|
fixed (int* k1 = Keys)
|
||||||
{
|
{
|
||||||
for (int i = 0; equal && i < NumInts; i++)
|
for (int i = 0; equal && i < NumInts; i++)
|
||||||
|
{
|
||||||
equal &= *(k1 + i) == *(k2 + i);
|
equal &= *(k1 + i) == *(k2 + i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return equal;
|
return equal;
|
||||||
|
|
|
@ -71,7 +71,9 @@ namespace OpenTK.Input
|
||||||
public static MouseState GetState(int index)
|
public static MouseState GetState(int index)
|
||||||
{
|
{
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("index");
|
throw new ArgumentOutOfRangeException("index");
|
||||||
|
}
|
||||||
|
|
||||||
lock (SyncRoot)
|
lock (SyncRoot)
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,7 +78,9 @@ namespace OpenTK.Input
|
||||||
internal void SetButton(MouseButton button, ButtonState state)
|
internal void SetButton(MouseButton button, ButtonState state)
|
||||||
{
|
{
|
||||||
if (button < 0 || button > MouseButton.LastButton)
|
if (button < 0 || button > MouseButton.LastButton)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +97,9 @@ namespace OpenTK.Input
|
||||||
internal ButtonState GetButton(MouseButton button)
|
internal ButtonState GetButton(MouseButton button)
|
||||||
{
|
{
|
||||||
if (button < 0 || button > MouseButton.LastButton)
|
if (button < 0 || button > MouseButton.LastButton)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
state.ReadBit((int)button) ?
|
state.ReadBit((int)button) ?
|
||||||
|
|
|
@ -51,9 +51,13 @@ namespace OpenTK.Input
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
|
{
|
||||||
EnableBit((int)button);
|
EnableBit((int)button);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
DisableBit((int)button);
|
DisableBit((int)button);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +326,9 @@ namespace OpenTK.Input
|
||||||
private static void ValidateOffset(int offset)
|
private static void ValidateOffset(int offset)
|
||||||
{
|
{
|
||||||
if (offset < 0 || offset >= 16)
|
if (offset < 0 || offset >= 16)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("offset");
|
throw new ArgumentOutOfRangeException("offset");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -48,7 +48,9 @@ namespace OpenTK
|
||||||
public BezierCurve(IEnumerable<Vector2> points)
|
public BezierCurve(IEnumerable<Vector2> points)
|
||||||
{
|
{
|
||||||
if (points == null)
|
if (points == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("points", "Must point to a valid list of Vector2 structures.");
|
throw new ArgumentNullException("points", "Must point to a valid list of Vector2 structures.");
|
||||||
|
}
|
||||||
|
|
||||||
this.points = new List<Vector2>(points);
|
this.points = new List<Vector2>(points);
|
||||||
this.Parallel = 0.0f;
|
this.Parallel = 0.0f;
|
||||||
|
@ -61,7 +63,9 @@ namespace OpenTK
|
||||||
public BezierCurve(params Vector2[] points)
|
public BezierCurve(params Vector2[] points)
|
||||||
{
|
{
|
||||||
if (points == null)
|
if (points == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("points", "Must point to a valid list of Vector2 structures.");
|
throw new ArgumentNullException("points", "Must point to a valid list of Vector2 structures.");
|
||||||
|
}
|
||||||
|
|
||||||
this.points = new List<Vector2>(points);
|
this.points = new List<Vector2>(points);
|
||||||
this.Parallel = 0.0f;
|
this.Parallel = 0.0f;
|
||||||
|
@ -75,7 +79,9 @@ namespace OpenTK
|
||||||
public BezierCurve(float parallel, params Vector2[] points)
|
public BezierCurve(float parallel, params Vector2[] points)
|
||||||
{
|
{
|
||||||
if (points == null)
|
if (points == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("points", "Must point to a valid list of Vector2 structures.");
|
throw new ArgumentNullException("points", "Must point to a valid list of Vector2 structures.");
|
||||||
|
}
|
||||||
|
|
||||||
this.Parallel = parallel;
|
this.Parallel = parallel;
|
||||||
this.points = new List<Vector2>(points);
|
this.points = new List<Vector2>(points);
|
||||||
|
@ -89,7 +95,9 @@ namespace OpenTK
|
||||||
public BezierCurve(float parallel, IEnumerable<Vector2> points)
|
public BezierCurve(float parallel, IEnumerable<Vector2> points)
|
||||||
{
|
{
|
||||||
if (points == null)
|
if (points == null)
|
||||||
|
{
|
||||||
throw new ArgumentNullException("points", "Must point to a valid list of Vector2 structures.");
|
throw new ArgumentNullException("points", "Must point to a valid list of Vector2 structures.");
|
||||||
|
}
|
||||||
|
|
||||||
this.Parallel = parallel;
|
this.Parallel = parallel;
|
||||||
this.points = new List<Vector2>(points);
|
this.points = new List<Vector2>(points);
|
||||||
|
@ -198,14 +206,20 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parallel == 0.0f)
|
if (parallel == 0.0f)
|
||||||
|
{
|
||||||
return r;
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 perpendicular = new Vector2();
|
Vector2 perpendicular = new Vector2();
|
||||||
|
|
||||||
if (t != 0.0f)
|
if (t != 0.0f)
|
||||||
|
{
|
||||||
perpendicular = r - BezierCurve.CalculatePointOfDerivative(points, t);
|
perpendicular = r - BezierCurve.CalculatePointOfDerivative(points, t);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
perpendicular = points[1] - points[0];
|
perpendicular = points[1] - points[0];
|
||||||
|
}
|
||||||
|
|
||||||
return r + Vector2.Normalize(perpendicular).PerpendicularRight * parallel;
|
return r + Vector2.Normalize(perpendicular).PerpendicularRight * parallel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,14 +96,20 @@ namespace OpenTK
|
||||||
+ EndAnchor.Y * t * t * t;
|
+ EndAnchor.Y * t * t * t;
|
||||||
|
|
||||||
if (Parallel == 0.0f)
|
if (Parallel == 0.0f)
|
||||||
|
{
|
||||||
return r;
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 perpendicular = new Vector2();
|
Vector2 perpendicular = new Vector2();
|
||||||
|
|
||||||
if (t == 0.0f)
|
if (t == 0.0f)
|
||||||
|
{
|
||||||
perpendicular = FirstControlPoint - StartAnchor;
|
perpendicular = FirstControlPoint - StartAnchor;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
perpendicular = r - CalculatePointOfDerivative(t);
|
perpendicular = r - CalculatePointOfDerivative(t);
|
||||||
|
}
|
||||||
|
|
||||||
return r + Vector2.Normalize(perpendicular).PerpendicularRight * Parallel;
|
return r + Vector2.Normalize(perpendicular).PerpendicularRight * Parallel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,14 +85,20 @@ namespace OpenTK
|
||||||
r.Y = (c * c * StartAnchor.Y) + (2 * t * c * ControlPoint.Y) + (t * t * EndAnchor.Y);
|
r.Y = (c * c * StartAnchor.Y) + (2 * t * c * ControlPoint.Y) + (t * t * EndAnchor.Y);
|
||||||
|
|
||||||
if (Parallel == 0.0f)
|
if (Parallel == 0.0f)
|
||||||
|
{
|
||||||
return r;
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 perpendicular = new Vector2();
|
Vector2 perpendicular = new Vector2();
|
||||||
|
|
||||||
if (t == 0.0f)
|
if (t == 0.0f)
|
||||||
|
{
|
||||||
perpendicular = ControlPoint - StartAnchor;
|
perpendicular = ControlPoint - StartAnchor;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
perpendicular = r - CalculatePointOfDerivative(t);
|
perpendicular = r - CalculatePointOfDerivative(t);
|
||||||
|
}
|
||||||
|
|
||||||
return r + Vector2.Normalize(perpendicular).PerpendicularRight * Parallel;
|
return r + Vector2.Normalize(perpendicular).PerpendicularRight * Parallel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,13 +114,28 @@ namespace OpenTK
|
||||||
if (throwOnError)
|
if (throwOnError)
|
||||||
{
|
{
|
||||||
// handle cases that cause overflow rather than silently ignoring it
|
// handle cases that cause overflow rather than silently ignoring it
|
||||||
if (f > Half.MaxValue) throw new ArithmeticException("Half: Positive maximum value exceeded.");
|
if (f > Half.MaxValue)
|
||||||
if (f < -Half.MaxValue) throw new ArithmeticException("Half: Negative minimum value exceeded.");
|
{
|
||||||
|
throw new ArithmeticException("Half: Positive maximum value exceeded.");
|
||||||
|
}
|
||||||
|
if (f < -Half.MaxValue)
|
||||||
|
{
|
||||||
|
throw new ArithmeticException("Half: Negative minimum value exceeded.");
|
||||||
|
}
|
||||||
|
|
||||||
// handle cases that make no sense
|
// handle cases that make no sense
|
||||||
if (Single.IsNaN(f)) throw new ArithmeticException("Half: Input is not a number (NaN).");
|
if (Single.IsNaN(f))
|
||||||
if (Single.IsPositiveInfinity(f)) throw new ArithmeticException("Half: Input is positive infinity.");
|
{
|
||||||
if (Single.IsNegativeInfinity(f)) throw new ArithmeticException("Half: Input is negative infinity.");
|
throw new ArithmeticException("Half: Input is not a number (NaN).");
|
||||||
|
}
|
||||||
|
if (Single.IsPositiveInfinity(f))
|
||||||
|
{
|
||||||
|
throw new ArithmeticException("Half: Input is positive infinity.");
|
||||||
|
}
|
||||||
|
if (Single.IsNegativeInfinity(f))
|
||||||
|
{
|
||||||
|
throw new ArithmeticException("Half: Input is negative infinity.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +234,10 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
|
|
||||||
// exponent overflow
|
// exponent overflow
|
||||||
if (exponent > 30) throw new ArithmeticException("Half: Hardware floating-point overflow.");
|
if (exponent > 30)
|
||||||
|
{
|
||||||
|
throw new ArithmeticException("Half: Hardware floating-point overflow.");
|
||||||
|
}
|
||||||
|
|
||||||
// Assemble the half from S, E and M.
|
// Assemble the half from S, E and M.
|
||||||
|
|
||||||
|
@ -412,16 +430,22 @@ namespace OpenTK
|
||||||
|
|
||||||
// Make aInt lexicographically ordered as a twos-complement int
|
// Make aInt lexicographically ordered as a twos-complement int
|
||||||
if (aInt < 0)
|
if (aInt < 0)
|
||||||
|
{
|
||||||
aInt = (short)(0x8000 - aInt);
|
aInt = (short)(0x8000 - aInt);
|
||||||
|
}
|
||||||
|
|
||||||
// Make bInt lexicographically ordered as a twos-complement int
|
// Make bInt lexicographically ordered as a twos-complement int
|
||||||
if (bInt < 0)
|
if (bInt < 0)
|
||||||
|
{
|
||||||
bInt = (short)(0x8000 - bInt);
|
bInt = (short)(0x8000 - bInt);
|
||||||
|
}
|
||||||
|
|
||||||
short intDiff = System.Math.Abs((short)(aInt - bInt));
|
short intDiff = System.Math.Abs((short)(aInt - bInt));
|
||||||
|
|
||||||
if (intDiff <= maxUlps)
|
if (intDiff <= maxUlps)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,10 @@ namespace OpenTK
|
||||||
/// <returns>The next power of two.</returns>
|
/// <returns>The next power of two.</returns>
|
||||||
public static long NextPowerOfTwo(long n)
|
public static long NextPowerOfTwo(long n)
|
||||||
{
|
{
|
||||||
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
if (n < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
||||||
|
}
|
||||||
return (long)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
return (long)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +89,10 @@ namespace OpenTK
|
||||||
/// <returns>The next power of two.</returns>
|
/// <returns>The next power of two.</returns>
|
||||||
public static int NextPowerOfTwo(int n)
|
public static int NextPowerOfTwo(int n)
|
||||||
{
|
{
|
||||||
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
if (n < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
||||||
|
}
|
||||||
return (int)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
return (int)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +103,10 @@ namespace OpenTK
|
||||||
/// <returns>The next power of two.</returns>
|
/// <returns>The next power of two.</returns>
|
||||||
public static float NextPowerOfTwo(float n)
|
public static float NextPowerOfTwo(float n)
|
||||||
{
|
{
|
||||||
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
if (n < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
||||||
|
}
|
||||||
return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +117,10 @@ namespace OpenTK
|
||||||
/// <returns>The next power of two.</returns>
|
/// <returns>The next power of two.</returns>
|
||||||
public static double NextPowerOfTwo(double n)
|
public static double NextPowerOfTwo(double n)
|
||||||
{
|
{
|
||||||
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
if (n < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
||||||
|
}
|
||||||
return System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
return System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +133,9 @@ namespace OpenTK
|
||||||
long result = 1;
|
long result = 1;
|
||||||
|
|
||||||
for (; n > 1; n--)
|
for (; n > 1; n--)
|
||||||
|
{
|
||||||
result *= n;
|
result *= n;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -311,11 +325,15 @@ namespace OpenTK
|
||||||
// we use longs here, otherwise we run into a two's complement problem, causing this to fail with -2 and 2.0
|
// we use longs here, otherwise we run into a two's complement problem, causing this to fail with -2 and 2.0
|
||||||
long aInt = FloatToInt32Bits(a);
|
long aInt = FloatToInt32Bits(a);
|
||||||
if (aInt < 0)
|
if (aInt < 0)
|
||||||
|
{
|
||||||
aInt = Int32.MinValue - aInt;
|
aInt = Int32.MinValue - aInt;
|
||||||
|
}
|
||||||
|
|
||||||
long bInt = FloatToInt32Bits(b);
|
long bInt = FloatToInt32Bits(b);
|
||||||
if (bInt < 0)
|
if (bInt < 0)
|
||||||
|
{
|
||||||
bInt = Int32.MinValue - bInt;
|
bInt = Int32.MinValue - bInt;
|
||||||
|
}
|
||||||
|
|
||||||
long intDiff = Math.Abs(aInt - bInt);
|
long intDiff = Math.Abs(aInt - bInt);
|
||||||
return intDiff <= (1 << maxDeltaBits);
|
return intDiff <= (1 << maxDeltaBits);
|
||||||
|
|
|
@ -156,15 +156,30 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
Row0[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +498,9 @@ namespace OpenTK
|
||||||
float det = mat.Determinant;
|
float det = mat.Determinant;
|
||||||
|
|
||||||
if (det == 0)
|
if (det == 0)
|
||||||
|
{
|
||||||
throw new InvalidOperationException("Matrix is singular and cannot be inverted.");
|
throw new InvalidOperationException("Matrix is singular and cannot be inverted.");
|
||||||
|
}
|
||||||
|
|
||||||
float invDet = 1f / det;
|
float invDet = 1f / det;
|
||||||
|
|
||||||
|
@ -660,7 +677,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix2))
|
if (!(obj is Matrix2))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix2)obj);
|
return this.Equals((Matrix2)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,15 +156,30 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
Row0[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,7 +498,9 @@ namespace OpenTK
|
||||||
double det = mat.Determinant;
|
double det = mat.Determinant;
|
||||||
|
|
||||||
if (det == 0)
|
if (det == 0)
|
||||||
|
{
|
||||||
throw new InvalidOperationException("Matrix is singular and cannot be inverted.");
|
throw new InvalidOperationException("Matrix is singular and cannot be inverted.");
|
||||||
|
}
|
||||||
|
|
||||||
double invDet = 1f / det;
|
double invDet = 1f / det;
|
||||||
|
|
||||||
|
@ -659,7 +676,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix2d))
|
if (!(obj is Matrix2d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix2d)obj);
|
return this.Equals((Matrix2d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,15 +158,30 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
Row0[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +645,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix2x3))
|
if (!(obj is Matrix2x3))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix2x3)obj);
|
return this.Equals((Matrix2x3)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,15 +158,30 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
Row0[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +645,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix2x3d))
|
if (!(obj is Matrix2x3d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix2x3d)obj);
|
return this.Equals((Matrix2x3d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,15 +179,30 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
Row0[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,7 +685,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix2x4))
|
if (!(obj is Matrix2x4))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix2x4)obj);
|
return this.Equals((Matrix2x4)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,15 +179,30 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
Row0[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,7 +685,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix2x4d))
|
if (!(obj is Matrix2x4d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix2x4d)obj);
|
return this.Equals((Matrix2x4d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,17 +223,38 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +305,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
Matrix3 m = this;
|
Matrix3 m = this;
|
||||||
if (m.Determinant != 0)
|
if (m.Determinant != 0)
|
||||||
|
{
|
||||||
m.Invert();
|
m.Invert();
|
||||||
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,7 +797,9 @@ namespace OpenTK
|
||||||
float oneOverPivot = 1.0f / pivot;
|
float oneOverPivot = 1.0f / pivot;
|
||||||
inverse[icol, icol] = 1.0f;
|
inverse[icol, icol] = 1.0f;
|
||||||
for (int k = 0; k < 3; ++k)
|
for (int k = 0; k < 3; ++k)
|
||||||
|
{
|
||||||
inverse[icol, k] *= oneOverPivot;
|
inverse[icol, k] *= oneOverPivot;
|
||||||
|
}
|
||||||
|
|
||||||
for (int j = 0; j < 3; ++j)
|
for (int j = 0; j < 3; ++j)
|
||||||
{
|
{
|
||||||
|
@ -783,7 +808,9 @@ namespace OpenTK
|
||||||
float f = inverse[j, icol];
|
float f = inverse[j, icol];
|
||||||
inverse[j, icol] = 0.0f;
|
inverse[j, icol] = 0.0f;
|
||||||
for (int k = 0; k < 3; ++k)
|
for (int k = 0; k < 3; ++k)
|
||||||
|
{
|
||||||
inverse[j, k] -= inverse[icol, k] * f;
|
inverse[j, k] -= inverse[icol, k] * f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -929,7 +956,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix3))
|
if (!(obj is Matrix3))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix3)obj);
|
return this.Equals((Matrix3)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,17 +217,38 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +299,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
Matrix3d m = this;
|
Matrix3d m = this;
|
||||||
if (m.Determinant != 0)
|
if (m.Determinant != 0)
|
||||||
|
{
|
||||||
m.Invert();
|
m.Invert();
|
||||||
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,7 +792,9 @@ namespace OpenTK
|
||||||
double oneOverPivot = 1.0 / pivot;
|
double oneOverPivot = 1.0 / pivot;
|
||||||
inverse[icol, icol] = 1.0;
|
inverse[icol, icol] = 1.0;
|
||||||
for (int k = 0; k < 3; ++k)
|
for (int k = 0; k < 3; ++k)
|
||||||
|
{
|
||||||
inverse[icol, k] *= oneOverPivot;
|
inverse[icol, k] *= oneOverPivot;
|
||||||
|
}
|
||||||
|
|
||||||
for (int j = 0; j < 3; ++j)
|
for (int j = 0; j < 3; ++j)
|
||||||
{
|
{
|
||||||
|
@ -778,7 +803,9 @@ namespace OpenTK
|
||||||
double f = inverse[j, icol];
|
double f = inverse[j, icol];
|
||||||
inverse[j, icol] = 0.0;
|
inverse[j, icol] = 0.0;
|
||||||
for (int k = 0; k < 3; ++k)
|
for (int k = 0; k < 3; ++k)
|
||||||
|
{
|
||||||
inverse[j, k] -= inverse[icol, k] * f;
|
inverse[j, k] -= inverse[icol, k] * f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -918,7 +945,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix3d))
|
if (!(obj is Matrix3d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix3d)obj);
|
return this.Equals((Matrix3d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,17 +158,38 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +665,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix3x2))
|
if (!(obj is Matrix3x2))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix3x2)obj);
|
return this.Equals((Matrix3x2)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,17 +158,38 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +665,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix3x2d))
|
if (!(obj is Matrix3x2d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix3x2d)obj);
|
return this.Equals((Matrix3x2d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,17 +211,38 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,7 +908,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix3x4))
|
if (!(obj is Matrix3x4))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix3x4)obj);
|
return this.Equals((Matrix3x4)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,17 +211,38 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,7 +908,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix3x4d))
|
if (!(obj is Matrix3x4d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix3x4d)obj);
|
return this.Equals((Matrix3x4d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,19 +301,46 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
else if (rowIndex == 3) return Row3[columnIndex];
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
return Row3[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else if (rowIndex == 3) Row3[columnIndex] = value;
|
}
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
Row3[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,7 +389,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
Matrix4 m = this;
|
Matrix4 m = this;
|
||||||
if (m.Determinant != 0)
|
if (m.Determinant != 0)
|
||||||
|
{
|
||||||
m.Invert();
|
m.Invert();
|
||||||
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -887,13 +916,21 @@ namespace OpenTK
|
||||||
public static void CreatePerspectiveFieldOfView(float fovy, float aspect, float zNear, float zFar, out Matrix4 result)
|
public static void CreatePerspectiveFieldOfView(float fovy, float aspect, float zNear, float zFar, out Matrix4 result)
|
||||||
{
|
{
|
||||||
if (fovy <= 0 || fovy > Math.PI)
|
if (fovy <= 0 || fovy > Math.PI)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("fovy");
|
throw new ArgumentOutOfRangeException("fovy");
|
||||||
|
}
|
||||||
if (aspect <= 0)
|
if (aspect <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("aspect");
|
throw new ArgumentOutOfRangeException("aspect");
|
||||||
|
}
|
||||||
if (zNear <= 0)
|
if (zNear <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zNear");
|
throw new ArgumentOutOfRangeException("zNear");
|
||||||
|
}
|
||||||
if (zFar <= 0)
|
if (zFar <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zFar");
|
throw new ArgumentOutOfRangeException("zFar");
|
||||||
|
}
|
||||||
|
|
||||||
float yMax = zNear * (float)System.Math.Tan(0.5f * fovy);
|
float yMax = zNear * (float)System.Math.Tan(0.5f * fovy);
|
||||||
float yMin = -yMax;
|
float yMin = -yMax;
|
||||||
|
@ -949,11 +986,17 @@ namespace OpenTK
|
||||||
public static void CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float zNear, float zFar, out Matrix4 result)
|
public static void CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float zNear, float zFar, out Matrix4 result)
|
||||||
{
|
{
|
||||||
if (zNear <= 0)
|
if (zNear <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zNear");
|
throw new ArgumentOutOfRangeException("zNear");
|
||||||
|
}
|
||||||
if (zFar <= 0)
|
if (zFar <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zFar");
|
throw new ArgumentOutOfRangeException("zFar");
|
||||||
|
}
|
||||||
if (zNear >= zFar)
|
if (zNear >= zFar)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zNear");
|
throw new ArgumentOutOfRangeException("zNear");
|
||||||
|
}
|
||||||
|
|
||||||
float x = (2.0f * zNear) / (right - left);
|
float x = (2.0f * zNear) / (right - left);
|
||||||
float y = (2.0f * zNear) / (top - bottom);
|
float y = (2.0f * zNear) / (top - bottom);
|
||||||
|
@ -1262,7 +1305,9 @@ namespace OpenTK
|
||||||
float oneOverPivot = 1.0f / pivot;
|
float oneOverPivot = 1.0f / pivot;
|
||||||
inverse[icol, icol] = 1.0f;
|
inverse[icol, icol] = 1.0f;
|
||||||
for (int k = 0; k < 4; ++k)
|
for (int k = 0; k < 4; ++k)
|
||||||
|
{
|
||||||
inverse[icol, k] *= oneOverPivot;
|
inverse[icol, k] *= oneOverPivot;
|
||||||
|
}
|
||||||
|
|
||||||
// Do elimination of non-diagonal elements
|
// Do elimination of non-diagonal elements
|
||||||
for (int j = 0; j < 4; ++j)
|
for (int j = 0; j < 4; ++j)
|
||||||
|
@ -1273,7 +1318,9 @@ namespace OpenTK
|
||||||
float f = inverse[j, icol];
|
float f = inverse[j, icol];
|
||||||
inverse[j, icol] = 0.0f;
|
inverse[j, icol] = 0.0f;
|
||||||
for (int k = 0; k < 4; ++k)
|
for (int k = 0; k < 4; ++k)
|
||||||
|
{
|
||||||
inverse[j, k] -= inverse[icol, k] * f;
|
inverse[j, k] -= inverse[icol, k] * f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1444,7 +1491,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix4))
|
if (!(obj is Matrix4))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix4)obj);
|
return this.Equals((Matrix4)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,19 +288,46 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
else if (rowIndex == 3) return Row3[columnIndex];
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
return Row3[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else if (rowIndex == 3) Row3[columnIndex] = value;
|
}
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
Row3[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +376,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
Matrix4d m = this;
|
Matrix4d m = this;
|
||||||
if (m.Determinant != 0)
|
if (m.Determinant != 0)
|
||||||
|
{
|
||||||
m.Invert();
|
m.Invert();
|
||||||
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,13 +794,21 @@ namespace OpenTK
|
||||||
public static void CreatePerspectiveFieldOfView(double fovy, double aspect, double zNear, double zFar, out Matrix4d result)
|
public static void CreatePerspectiveFieldOfView(double fovy, double aspect, double zNear, double zFar, out Matrix4d result)
|
||||||
{
|
{
|
||||||
if (fovy <= 0 || fovy > Math.PI)
|
if (fovy <= 0 || fovy > Math.PI)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("fovy");
|
throw new ArgumentOutOfRangeException("fovy");
|
||||||
|
}
|
||||||
if (aspect <= 0)
|
if (aspect <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("aspect");
|
throw new ArgumentOutOfRangeException("aspect");
|
||||||
|
}
|
||||||
if (zNear <= 0)
|
if (zNear <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zNear");
|
throw new ArgumentOutOfRangeException("zNear");
|
||||||
|
}
|
||||||
if (zFar <= 0)
|
if (zFar <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zFar");
|
throw new ArgumentOutOfRangeException("zFar");
|
||||||
|
}
|
||||||
|
|
||||||
double yMax = zNear * System.Math.Tan(0.5 * fovy);
|
double yMax = zNear * System.Math.Tan(0.5 * fovy);
|
||||||
double yMin = -yMax;
|
double yMin = -yMax;
|
||||||
|
@ -827,11 +864,17 @@ namespace OpenTK
|
||||||
public static void CreatePerspectiveOffCenter(double left, double right, double bottom, double top, double zNear, double zFar, out Matrix4d result)
|
public static void CreatePerspectiveOffCenter(double left, double right, double bottom, double top, double zNear, double zFar, out Matrix4d result)
|
||||||
{
|
{
|
||||||
if (zNear <= 0)
|
if (zNear <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zNear");
|
throw new ArgumentOutOfRangeException("zNear");
|
||||||
|
}
|
||||||
if (zFar <= 0)
|
if (zFar <= 0)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zFar");
|
throw new ArgumentOutOfRangeException("zFar");
|
||||||
|
}
|
||||||
if (zNear >= zFar)
|
if (zNear >= zFar)
|
||||||
|
{
|
||||||
throw new ArgumentOutOfRangeException("zNear");
|
throw new ArgumentOutOfRangeException("zNear");
|
||||||
|
}
|
||||||
|
|
||||||
double x = (2.0 * zNear) / (right - left);
|
double x = (2.0 * zNear) / (right - left);
|
||||||
double y = (2.0 * zNear) / (top - bottom);
|
double y = (2.0 * zNear) / (top - bottom);
|
||||||
|
@ -1305,7 +1348,9 @@ namespace OpenTK
|
||||||
double oneOverPivot = 1.0 / pivot;
|
double oneOverPivot = 1.0 / pivot;
|
||||||
inverse[icol, icol] = 1.0;
|
inverse[icol, icol] = 1.0;
|
||||||
for (int k = 0; k < 4; ++k)
|
for (int k = 0; k < 4; ++k)
|
||||||
|
{
|
||||||
inverse[icol, k] *= oneOverPivot;
|
inverse[icol, k] *= oneOverPivot;
|
||||||
|
}
|
||||||
|
|
||||||
// Do elimination of non-diagonal elements
|
// Do elimination of non-diagonal elements
|
||||||
for (int j = 0; j < 4; ++j)
|
for (int j = 0; j < 4; ++j)
|
||||||
|
@ -1316,7 +1361,9 @@ namespace OpenTK
|
||||||
double f = inverse[j, icol];
|
double f = inverse[j, icol];
|
||||||
inverse[j, icol] = 0.0;
|
inverse[j, icol] = 0.0;
|
||||||
for (int k = 0; k < 4; ++k)
|
for (int k = 0; k < 4; ++k)
|
||||||
|
{
|
||||||
inverse[j, k] -= inverse[icol, k] * f;
|
inverse[j, k] -= inverse[icol, k] * f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1463,7 +1510,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix4d))
|
if (!(obj is Matrix4d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix4d)obj);
|
return this.Equals((Matrix4d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,19 +180,46 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
else if (rowIndex == 3) return Row3[columnIndex];
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
return Row3[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else if (rowIndex == 3) Row3[columnIndex] = value;
|
}
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
Row3[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +724,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix4x2))
|
if (!(obj is Matrix4x2))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix4x2)obj);
|
return this.Equals((Matrix4x2)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,19 +180,46 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
else if (rowIndex == 3) return Row3[columnIndex];
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
return Row3[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else if (rowIndex == 3) Row3[columnIndex] = value;
|
}
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
Row3[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +724,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix4x2d))
|
if (!(obj is Matrix4x2d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix4x2d)obj);
|
return this.Equals((Matrix4x2d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,19 +212,46 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
else if (rowIndex == 3) return Row3[columnIndex];
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
return Row3[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else if (rowIndex == 3) Row3[columnIndex] = value;
|
}
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
Row3[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,7 +923,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix4x3))
|
if (!(obj is Matrix4x3))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix4x3)obj);
|
return this.Equals((Matrix4x3)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,19 +212,46 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) return Row0[columnIndex];
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) return Row1[columnIndex];
|
{
|
||||||
else if (rowIndex == 2) return Row2[columnIndex];
|
return Row0[columnIndex];
|
||||||
else if (rowIndex == 3) return Row3[columnIndex];
|
}
|
||||||
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
return Row1[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
return Row2[columnIndex];
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
return Row3[columnIndex];
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
throw new IndexOutOfRangeException("You tried to access this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (rowIndex == 0) Row0[columnIndex] = value;
|
if (rowIndex == 0)
|
||||||
else if (rowIndex == 1) Row1[columnIndex] = value;
|
{
|
||||||
else if (rowIndex == 2) Row2[columnIndex] = value;
|
Row0[columnIndex] = value;
|
||||||
else if (rowIndex == 3) Row3[columnIndex] = value;
|
}
|
||||||
else throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
else if (rowIndex == 1)
|
||||||
|
{
|
||||||
|
Row1[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 2)
|
||||||
|
{
|
||||||
|
Row2[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else if (rowIndex == 3)
|
||||||
|
{
|
||||||
|
Row3[columnIndex] = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this matrix at: (" + rowIndex + ", " + columnIndex + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,7 +923,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Matrix4x3d))
|
if (!(obj is Matrix4x3d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Matrix4x3d)obj);
|
return this.Equals((Matrix4x3d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
Quaternion q = this;
|
Quaternion q = this;
|
||||||
if (Math.Abs(q.W) > 1.0f)
|
if (Math.Abs(q.W) > 1.0f)
|
||||||
|
{
|
||||||
q.Normalize();
|
q.Normalize();
|
||||||
|
}
|
||||||
|
|
||||||
Vector4 result = new Vector4();
|
Vector4 result = new Vector4();
|
||||||
|
|
||||||
|
@ -414,7 +416,9 @@ namespace OpenTK
|
||||||
public static Quaternion FromAxisAngle(Vector3 axis, float angle)
|
public static Quaternion FromAxisAngle(Vector3 axis, float angle)
|
||||||
{
|
{
|
||||||
if (axis.LengthSquared == 0.0f)
|
if (axis.LengthSquared == 0.0f)
|
||||||
|
{
|
||||||
return Identity;
|
return Identity;
|
||||||
|
}
|
||||||
|
|
||||||
Quaternion result = Identity;
|
Quaternion result = Identity;
|
||||||
|
|
||||||
|
@ -594,9 +598,13 @@ namespace OpenTK
|
||||||
|
|
||||||
Quaternion result = new Quaternion(blendA * q1.Xyz + blendB * q2.Xyz, blendA * q1.W + blendB * q2.W);
|
Quaternion result = new Quaternion(blendA * q1.Xyz + blendB * q2.Xyz, blendA * q1.W + blendB * q2.W);
|
||||||
if (result.LengthSquared > 0.0f)
|
if (result.LengthSquared > 0.0f)
|
||||||
|
{
|
||||||
return Normalize(result);
|
return Normalize(result);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return Identity;
|
return Identity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -698,8 +706,11 @@ namespace OpenTK
|
||||||
/// <returns>True if both objects are Quaternions of equal value. Otherwise it returns false.</returns>
|
/// <returns>True if both objects are Quaternions of equal value. Otherwise it returns false.</returns>
|
||||||
public override bool Equals(object other)
|
public override bool Equals(object other)
|
||||||
{
|
{
|
||||||
if (other is Quaternion == false) return false;
|
if (other is Quaternion == false)
|
||||||
return this == (Quaternion)other;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this == (Quaternion)other;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -137,7 +137,9 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
Quaterniond q = this;
|
Quaterniond q = this;
|
||||||
if (Math.Abs(q.W) > 1.0f)
|
if (Math.Abs(q.W) > 1.0f)
|
||||||
|
{
|
||||||
q.Normalize();
|
q.Normalize();
|
||||||
|
}
|
||||||
|
|
||||||
Vector4d result = new Vector4d();
|
Vector4d result = new Vector4d();
|
||||||
|
|
||||||
|
@ -414,7 +416,9 @@ namespace OpenTK
|
||||||
public static Quaterniond FromAxisAngle(Vector3d axis, double angle)
|
public static Quaterniond FromAxisAngle(Vector3d axis, double angle)
|
||||||
{
|
{
|
||||||
if (axis.LengthSquared == 0.0f)
|
if (axis.LengthSquared == 0.0f)
|
||||||
|
{
|
||||||
return Identity;
|
return Identity;
|
||||||
|
}
|
||||||
|
|
||||||
Quaterniond result = Identity;
|
Quaterniond result = Identity;
|
||||||
|
|
||||||
|
@ -594,9 +598,13 @@ namespace OpenTK
|
||||||
|
|
||||||
Quaterniond result = new Quaterniond(blendA * q1.Xyz + blendB * q2.Xyz, blendA * q1.W + blendB * q2.W);
|
Quaterniond result = new Quaterniond(blendA * q1.Xyz + blendB * q2.Xyz, blendA * q1.W + blendB * q2.W);
|
||||||
if (result.LengthSquared > 0.0f)
|
if (result.LengthSquared > 0.0f)
|
||||||
|
{
|
||||||
return Normalize(result);
|
return Normalize(result);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return Identity;
|
return Identity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -698,7 +706,10 @@ namespace OpenTK
|
||||||
/// <returns>True if both objects are Quaternions of equal value. Otherwise it returns false.</returns>
|
/// <returns>True if both objects are Quaternions of equal value. Otherwise it returns false.</returns>
|
||||||
public override bool Equals(object other)
|
public override bool Equals(object other)
|
||||||
{
|
{
|
||||||
if (other is Quaterniond == false) return false;
|
if (other is Quaterniond == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return this == (Quaterniond)other;
|
return this == (Quaterniond)other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,13 +70,28 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float this[int index] {
|
public float this[int index] {
|
||||||
get{
|
get{
|
||||||
if(index == 0) return X;
|
if(index == 0)
|
||||||
else if(index == 1) return Y;
|
{
|
||||||
|
return X;
|
||||||
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
return Y;
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
||||||
} set{
|
} set{
|
||||||
if(index == 0) X = value;
|
if(index == 0)
|
||||||
else if(index == 1) Y = value;
|
{
|
||||||
else throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
X = value;
|
||||||
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
Y = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +843,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Vector2))
|
if (!(obj is Vector2))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Vector2)obj);
|
return this.Equals((Vector2)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,13 +86,28 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double this[int index] {
|
public double this[int index] {
|
||||||
get{
|
get{
|
||||||
if(index == 0) return X;
|
if(index == 0)
|
||||||
else if(index == 1) return Y;
|
{
|
||||||
|
return X;
|
||||||
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
return Y;
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
||||||
} set{
|
} set{
|
||||||
if(index == 0) X = value;
|
if(index == 0)
|
||||||
else if(index == 1) Y = value;
|
{
|
||||||
else throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
X = value;
|
||||||
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
Y = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,7 +830,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Vector2d))
|
if (!(obj is Vector2d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Vector2d)obj);
|
return this.Equals((Vector2d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,15 +114,36 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float this[int index] {
|
public float this[int index] {
|
||||||
get{
|
get{
|
||||||
if(index == 0) return X;
|
if(index == 0)
|
||||||
else if(index == 1) return Y;
|
{
|
||||||
else if(index == 2) return Z;
|
return X;
|
||||||
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
return Y;
|
||||||
|
}
|
||||||
|
else if(index == 2)
|
||||||
|
{
|
||||||
|
return Z;
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
||||||
} set{
|
} set{
|
||||||
if(index == 0) X = value;
|
if(index == 0)
|
||||||
else if(index == 1) Y = value;
|
{
|
||||||
else if(index == 2) Z = value;
|
X = value;
|
||||||
else throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
Y = value;
|
||||||
|
}
|
||||||
|
else if(index == 2)
|
||||||
|
{
|
||||||
|
Z = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,7 +1350,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Vector3))
|
if (!(obj is Vector3))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Vector3)obj);
|
return this.Equals((Vector3)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,15 +111,36 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double this[int index] {
|
public double this[int index] {
|
||||||
get{
|
get{
|
||||||
if(index == 0) return X;
|
if(index == 0)
|
||||||
else if(index == 1) return Y;
|
{
|
||||||
else if(index == 2) return Z;
|
return X;
|
||||||
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
return Y;
|
||||||
|
}
|
||||||
|
else if(index == 2)
|
||||||
|
{
|
||||||
|
return Z;
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
||||||
} set{
|
} set{
|
||||||
if(index == 0) X = value;
|
if(index == 0)
|
||||||
else if(index == 1) Y = value;
|
{
|
||||||
else if(index == 2) Z = value;
|
X = value;
|
||||||
else throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
Y = value;
|
||||||
|
}
|
||||||
|
else if(index == 2)
|
||||||
|
{
|
||||||
|
Z = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,7 +1191,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Vector3d))
|
if (!(obj is Vector3d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Vector3d)obj);
|
return this.Equals((Vector3d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,17 +172,44 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float this[int index] {
|
public float this[int index] {
|
||||||
get{
|
get{
|
||||||
if(index == 0) return X;
|
if(index == 0)
|
||||||
else if(index == 1) return Y;
|
{
|
||||||
else if(index == 2) return Z;
|
return X;
|
||||||
else if(index == 3) return W;
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
return Y;
|
||||||
|
}
|
||||||
|
else if(index == 2)
|
||||||
|
{
|
||||||
|
return Z;
|
||||||
|
}
|
||||||
|
else if(index == 3)
|
||||||
|
{
|
||||||
|
return W;
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
||||||
} set{
|
} set{
|
||||||
if(index == 0) X = value;
|
if(index == 0)
|
||||||
else if(index == 1) Y = value;
|
{
|
||||||
else if(index == 2) Z = value;
|
X = value;
|
||||||
else if(index == 3) W = value;
|
}
|
||||||
else throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
Y = value;
|
||||||
|
}
|
||||||
|
else if(index == 2)
|
||||||
|
{
|
||||||
|
Z = value;
|
||||||
|
}
|
||||||
|
else if(index == 3)
|
||||||
|
{
|
||||||
|
W = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1433,7 +1460,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Vector4))
|
if (!(obj is Vector4))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Vector4)obj);
|
return this.Equals((Vector4)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,17 +169,44 @@ namespace OpenTK
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double this[int index] {
|
public double this[int index] {
|
||||||
get{
|
get{
|
||||||
if(index == 0) return X;
|
if(index == 0)
|
||||||
else if(index == 1) return Y;
|
{
|
||||||
else if(index == 2) return Z;
|
return X;
|
||||||
else if(index == 3) return W;
|
}
|
||||||
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
return Y;
|
||||||
|
}
|
||||||
|
else if(index == 2)
|
||||||
|
{
|
||||||
|
return Z;
|
||||||
|
}
|
||||||
|
else if(index == 3)
|
||||||
|
{
|
||||||
|
return W;
|
||||||
|
}
|
||||||
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
throw new IndexOutOfRangeException("You tried to access this vector at index: " + index);
|
||||||
} set{
|
} set{
|
||||||
if(index == 0) X = value;
|
if(index == 0)
|
||||||
else if(index == 1) Y = value;
|
{
|
||||||
else if(index == 2) Z = value;
|
X = value;
|
||||||
else if(index == 3) W = value;
|
}
|
||||||
else throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
else if(index == 1)
|
||||||
|
{
|
||||||
|
Y = value;
|
||||||
|
}
|
||||||
|
else if(index == 2)
|
||||||
|
{
|
||||||
|
Z = value;
|
||||||
|
}
|
||||||
|
else if(index == 3)
|
||||||
|
{
|
||||||
|
W = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IndexOutOfRangeException("You tried to set this vector at index: " + index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1379,7 +1406,9 @@ namespace OpenTK
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (!(obj is Vector4d))
|
if (!(obj is Vector4d))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return this.Equals((Vector4d)obj);
|
return this.Equals((Vector4d)obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,9 @@ namespace OpenTK
|
||||||
: base(width, height, data)
|
: base(width, height, data)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -91,7 +93,9 @@ namespace OpenTK
|
||||||
: base(width, height, data)
|
: base(width, height, data)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue