Skip to content

Commit

Permalink
Merge branch 'master' of github.com:opentk/opentk
Browse files Browse the repository at this point in the history
  • Loading branch information
varon committed Nov 21, 2020
2 parents 81c7847 + eb0b9c8 commit d16e4f2
Show file tree
Hide file tree
Showing 17 changed files with 380 additions and 345 deletions.
8 changes: 8 additions & 0 deletions src/Generator.Bind/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Security;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -37,6 +38,13 @@ internal static class MainClass

private static void Main(string[] arguments)
{
// These prevent us to accidently generate wrong code because of
// locale dependent string functions.
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

Debug.AutoFlush = true;
Trace.Listeners.Clear();
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
Expand Down
10 changes: 10 additions & 0 deletions src/Generator.Converter/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Xml;
Expand Down Expand Up @@ -66,6 +67,15 @@ internal class EntryPoint

private static void Main(string[] args)
{
// These prevent us to accidently generate wrong code because of
// locale dependent string functions. Whether it actually affects
// this program in particular have not been tested yet, but better
// be safe than sorry.
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

Parser.Default.ParseArguments<Options>(args)
.WithParsed(result => CLIOptions = result)
.WithNotParsed(error => Environment.Exit(-1));
Expand Down
10 changes: 10 additions & 0 deletions src/Generator.Rewrite/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using CommandLine;
Expand All @@ -33,6 +34,15 @@ internal class Program

private static void Main(string[] args)
{
// These prevent us to accidently generate wrong code because of
// locale dependent string functions (probably not relevant here
// since this program supposed just rewrite IL bytecode but we do it
// anyway just to be safe).
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

Parser.Default.ParseArguments<Options>(args)
.WithParsed(result => Options = result)
.WithNotParsed(error => Environment.Exit(-1));
Expand Down
8 changes: 8 additions & 0 deletions src/Generator/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ open Constants
open System.IO
open System.Runtime
open CommandLine
open System.Globalization

type options =
{ [<Option('i', "input", Required = true,
Expand Down Expand Up @@ -289,6 +290,13 @@ let generateCode basePath (typecheckAndAggregateResults: TypecheckAndAggregateRe

[<EntryPoint>]
let main argv =
// These prevent us to accidently generate wrong code because of
// locale dependent string functions.
CultureInfo.CurrentCulture <- CultureInfo.InvariantCulture
CultureInfo.CurrentUICulture <- CultureInfo.InvariantCulture
CultureInfo.DefaultThreadCurrentCulture <- CultureInfo.InvariantCulture
CultureInfo.DefaultThreadCurrentUICulture <- CultureInfo.InvariantCulture

printfn
"Welcome to the OpenTK4.0 binding generator F#ast edition!"
let result = CommandLine.Parser.Default.ParseArguments<options>(argv)
Expand Down
13 changes: 7 additions & 6 deletions src/OpenTK.Mathematics/Matrix/Matrix3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ public static Matrix3 CreateFromAxisAngle(Vector3 axis, float angle)
public static void CreateFromQuaternion(in Quaternion q, out Matrix3 result)
{
// Adapted from https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Quaternion-derived_rotation_matrix
// with the caviat that opentk uses row-major matrices so the matrix we create is transposed
float sqx = q.X * q.X;
float sqy = q.Y * q.Y;
float sqz = q.Z * q.Z;
Expand All @@ -535,14 +536,14 @@ public static void CreateFromQuaternion(in Quaternion q, out Matrix3 result)
result.Row1.Y = 1f - (s2 * (sqx + sqz));
result.Row2.Z = 1f - (s2 * (sqx + sqy));

result.Row0.Y = s2 * (xy - zw);
result.Row1.X = s2 * (xy + zw);
result.Row0.Y = s2 * (xy + zw);
result.Row1.X = s2 * (xy - zw);

result.Row2.X = s2 * (xz - yw);
result.Row0.Z = s2 * (xz + yw);
result.Row2.X = s2 * (xz + yw);
result.Row0.Z = s2 * (xz - yw);

result.Row2.Y = s2 * (yz + xw);
result.Row1.Z = s2 * (yz - xw);
result.Row2.Y = s2 * (yz - xw);
result.Row1.Z = s2 * (yz + xw);
}

/// <summary>
Expand Down
13 changes: 7 additions & 6 deletions src/OpenTK.Mathematics/Matrix/Matrix3d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ public static Matrix3d CreateFromAxisAngle(Vector3d axis, double angle)
public static void CreateFromQuaternion(in Quaterniond q, out Matrix3d result)
{
// Adapted from https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Quaternion-derived_rotation_matrix
// with the caviat that opentk uses row-major matrices so the matrix we create is transposed
double sqx = q.X * q.X;
double sqy = q.Y * q.Y;
double sqz = q.Z * q.Z;
Expand All @@ -531,14 +532,14 @@ public static void CreateFromQuaternion(in Quaterniond q, out Matrix3d result)
result.Row1.Y = 1d - (s2 * (sqx + sqz));
result.Row2.Z = 1d - (s2 * (sqx + sqy));

result.Row0.Y = s2 * (xy - zw);
result.Row1.X = s2 * (xy + zw);
result.Row0.Y = s2 * (xy + zw);
result.Row1.X = s2 * (xy - zw);

result.Row2.X = s2 * (xz - yw);
result.Row0.Z = s2 * (xz + yw);
result.Row2.X = s2 * (xz + yw);
result.Row0.Z = s2 * (xz - yw);

result.Row2.Y = s2 * (yz + xw);
result.Row1.Z = s2 * (yz - xw);
result.Row2.Y = s2 * (yz - xw);
result.Row1.Z = s2 * (yz + xw);
}

/// <summary>
Expand Down
13 changes: 7 additions & 6 deletions src/OpenTK.Mathematics/Matrix/Matrix4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ public static Matrix4 CreateFromAxisAngle(Vector3 axis, float angle)
public static void CreateFromQuaternion(in Quaternion q, out Matrix4 result)
{
// Adapted from https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Quaternion-derived_rotation_matrix
// with the caviat that opentk uses row-major matrices so the matrix we create is transposed
float sqx = q.X * q.X;
float sqy = q.Y * q.Y;
float sqz = q.Z * q.Z;
Expand All @@ -743,14 +744,14 @@ public static void CreateFromQuaternion(in Quaternion q, out Matrix4 result)
result.Row1.Y = 1f - (s2 * (sqx + sqz));
result.Row2.Z = 1f - (s2 * (sqx + sqy));

result.Row0.Y = s2 * (xy - zw);
result.Row1.X = s2 * (xy + zw);
result.Row0.Y = s2 * (xy + zw);
result.Row1.X = s2 * (xy - zw);

result.Row2.X = s2 * (xz - yw);
result.Row0.Z = s2 * (xz + yw);
result.Row2.X = s2 * (xz + yw);
result.Row0.Z = s2 * (xz - yw);

result.Row2.Y = s2 * (yz + xw);
result.Row1.Z = s2 * (yz - xw);
result.Row2.Y = s2 * (yz - xw);
result.Row1.Z = s2 * (yz + xw);

result.Row0.W = 0;
result.Row1.W = 0;
Expand Down
13 changes: 7 additions & 6 deletions src/OpenTK.Mathematics/Matrix/Matrix4d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ double depthFar
public static void CreateFromQuaternion(in Quaterniond q, out Matrix4d result)
{
// Adapted from https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Quaternion-derived_rotation_matrix
// with the caviat that opentk uses row-major matrices so the matrix we create is transposed
double sqx = q.X * q.X;
double sqy = q.Y * q.Y;
double sqz = q.Z * q.Z;
Expand All @@ -1126,14 +1127,14 @@ public static void CreateFromQuaternion(in Quaterniond q, out Matrix4d result)
result.Row1.Y = 1d - (s2 * (sqx + sqz));
result.Row2.Z = 1d - (s2 * (sqx + sqy));

result.Row0.Y = s2 * (xy - zw);
result.Row1.X = s2 * (xy + zw);
result.Row0.Y = s2 * (xy + zw);
result.Row1.X = s2 * (xy - zw);

result.Row2.X = s2 * (xz - yw);
result.Row0.Z = s2 * (xz + yw);
result.Row2.X = s2 * (xz + yw);
result.Row0.Z = s2 * (xz - yw);

result.Row2.Y = s2 * (yz + xw);
result.Row1.Z = s2 * (yz - xw);
result.Row2.Y = s2 * (yz - xw);
result.Row1.Z = s2 * (yz + xw);

result.Row0.W = 0;
result.Row1.W = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/OpenTK.Windowing.Common/Enums/ContextProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
namespace OpenTK.Windowing.Common
{
/// <summary>
/// Selects the profile for the context's graphics API. This only applies on OpenGL 3.2 upwards, and has no effect on older versions.
/// Selects the profile for the context's graphics API.
/// For versions below 3.2 the <see cref="Any"/> option needs to be used.
/// </summary>
public enum ContextProfile
{
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTK.Windowing.Common/Events/MonitorEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace OpenTK.Windowing.Common
/// </summary>
/// <param name="monitor">The <see cref="Monitor"/> which triggered the event.</param>
/// <param name="isConnected">Whether the <see cref="Monitor"/> is connected.</param>
public MonitorEventArgs(Monitor monitor, bool isConnected)
public MonitorEventArgs(MonitorHandle monitor, bool isConnected)
{
Monitor = monitor;
IsConnected = isConnected;
Expand All @@ -28,7 +28,7 @@ public MonitorEventArgs(Monitor monitor, bool isConnected)
/// <summary>
/// Gets the <see cref="Monitor"/> which triggered the event.
/// </summary>
public Monitor Monitor { get; }
public MonitorHandle Monitor { get; }

/// <summary>
/// Gets a value indicating whether the <see cref="Monitor"/> that triggered this event is connected or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ namespace OpenTK.Windowing.Common
/// <summary>
/// Wrapper around an implementation-defined monitor struct.
/// </summary>
public struct Monitor
public struct MonitorHandle
{
/// <summary>
/// Initializes a new instance of the <see cref="Monitor"/> struct.
/// Initializes a new instance of the <see cref="MonitorHandle"/> struct.
/// </summary>
/// <param name="ptr">A pointer to the underlying native Monitor.</param>
public Monitor(IntPtr ptr)
public MonitorHandle(IntPtr ptr)
{
Pointer = ptr;
}
Expand Down
Loading

0 comments on commit d16e4f2

Please sign in to comment.