mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-12 23:05:26 +00:00
Added several overloads for the OpenTK.Math Vector[234] structs.
This commit is contained in:
parent
be4351b2ef
commit
9587321f10
|
@ -1,5 +1,6 @@
|
||||||
#region --- License ---
|
#region --- License ---
|
||||||
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
||||||
|
* Contributions by Andy Gill.
|
||||||
* See license.txt for license info
|
* See license.txt for license info
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -13,6 +14,7 @@ using System.Runtime.InteropServices;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
|
using OpenTK.Math;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -325,29 +327,6 @@ namespace OpenTK.OpenGL
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public static void Color[34]() overloads
|
|
||||||
|
|
||||||
public static void Color4(System.Drawing.Color color)
|
|
||||||
{
|
|
||||||
GL.Color4(color.R, color.G, color.B, color.A);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Color3(System.Drawing.Color color)
|
|
||||||
{
|
|
||||||
GL.Color3(color.R, color.G, color.B);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public static void ClearColor() overloads
|
|
||||||
|
|
||||||
public static void ClearColor(System.Drawing.Color color)
|
|
||||||
{
|
|
||||||
GL.ClearColor(color.R/255.0f, color.G/255.0f, color.B/255.0f, color.A/255.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region --- GetProcAddress ---
|
#region --- GetProcAddress ---
|
||||||
|
|
||||||
private static IGetProcAddress getProcAddress;
|
private static IGetProcAddress getProcAddress;
|
||||||
|
@ -483,5 +462,96 @@ namespace OpenTK.OpenGL
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region --- GL Overloads ---
|
||||||
|
|
||||||
|
#region public static void Color[34]() overloads
|
||||||
|
|
||||||
|
public static void Color4(System.Drawing.Color color)
|
||||||
|
{
|
||||||
|
GL.Color4(color.R, color.G, color.B, color.A);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Color3(System.Drawing.Color color)
|
||||||
|
{
|
||||||
|
GL.Color3(color.R, color.G, color.B);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public static void ClearColor() overloads
|
||||||
|
|
||||||
|
public static void ClearColor(System.Drawing.Color color)
|
||||||
|
{
|
||||||
|
GL.ClearColor(color.R/255.0f, color.G/255.0f, color.B/255.0f, color.A/255.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region overloads using OpenTK.Math classes
|
||||||
|
|
||||||
|
public static
|
||||||
|
void Normal3(Vector3 normal)
|
||||||
|
{
|
||||||
|
Delegates.glNormal3f(normal.X, normal.Y, normal.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void RasterPos2(Vector2 pos)
|
||||||
|
{
|
||||||
|
Delegates.glRasterPos2f(pos.X, pos.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void RasterPos3(Vector3 pos)
|
||||||
|
{
|
||||||
|
Delegates.glRasterPos3f(pos.X, pos.Y, pos.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void RasterPos4(Vector4 pos)
|
||||||
|
{
|
||||||
|
Delegates.glRasterPos4f(pos.X, pos.Y, pos.Z, pos.W);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void Vertex2(Vector2 v)
|
||||||
|
{
|
||||||
|
Delegates.glVertex2f(v.X, v.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void Vertex3(Vector3 v)
|
||||||
|
{
|
||||||
|
Delegates.glVertex3f(v.X, v.Y, v.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void Vertex4(Vector4 v)
|
||||||
|
{
|
||||||
|
Delegates.glVertex4f(v.X, v.Y, v.Z, v.W);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void Rotate(Single angle, Vector3 axis)
|
||||||
|
{
|
||||||
|
Delegates.glRotatef((Single)angle, axis.X, axis.Y, axis.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void Scale(Vector3 scale)
|
||||||
|
{
|
||||||
|
Delegates.glScalef(scale.X, scale.Y, scale.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void Translate(Vector3 trans)
|
||||||
|
{
|
||||||
|
Delegates.glTranslatef(trans.X, trans.Y, trans.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#region --- License ---
|
#region --- License ---
|
||||||
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
||||||
|
* Contributions by Andy Gill.
|
||||||
* See license.txt for license info
|
* See license.txt for license info
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -9,6 +10,7 @@ using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenTK.Platform;
|
using OpenTK.Platform;
|
||||||
|
using OpenTK.Math;
|
||||||
|
|
||||||
namespace OpenTK.OpenGL
|
namespace OpenTK.OpenGL
|
||||||
{
|
{
|
||||||
|
@ -209,5 +211,84 @@ namespace OpenTK.OpenGL
|
||||||
public class GLUquadric
|
public class GLUquadric
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Overloads using OpenTK.Math classes
|
||||||
|
|
||||||
|
public static
|
||||||
|
void LookAt(Vector3 eye, Vector3 center, Vector3 up)
|
||||||
|
{
|
||||||
|
Delegates.gluLookAt((double)eye.X, (double)eye.Y, (double)eye.Z, (double)center.X, (double)center.Y, (double)center.Z, (double)up.X, (double)up.Y, (double)up.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
// One token Project overload, I picked this one because it's CLS compliant, and it
|
||||||
|
// makes reasonably clear which args are inputs and which are outputs.
|
||||||
|
public static
|
||||||
|
Int32 Project(Vector3 obj, double[] model, double[] proj, Int32[] view, out Vector3 win)
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
double winX, winY, winZ;
|
||||||
|
double* winX_ptr = &winX;
|
||||||
|
double* winY_ptr = &winY;
|
||||||
|
double* winZ_ptr = &winZ;
|
||||||
|
fixed (double* model_ptr = model)
|
||||||
|
fixed (double* proj_ptr = proj)
|
||||||
|
fixed (Int32* view_ptr = view)
|
||||||
|
{
|
||||||
|
Int32 retval = Delegates.gluProject((double)obj.X, (double)obj.Y, (double)obj.Z, (double*)model_ptr, (double*)proj_ptr, (Int32*)view_ptr, (double*)winX_ptr, (double*)winY_ptr, (double*)winZ_ptr);
|
||||||
|
win = new Vector3((float)*winX_ptr, (float)*winY_ptr, (float)*winZ_ptr);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
void TessNormal(int tess, Vector3 normal)
|
||||||
|
{
|
||||||
|
Delegates.gluTessNormal((int)tess, (double)normal.X, (double)normal.Y, (double)normal.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
Int32 UnProject(Vector3 win, double[] model, double[] proj, Int32[] view, out Vector3 obj)
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
double objX, objY, objZ;
|
||||||
|
double* objX_ptr = &objX;
|
||||||
|
double* objY_ptr = &objY;
|
||||||
|
double* objZ_ptr = &objZ;
|
||||||
|
fixed (double* model_ptr = model)
|
||||||
|
fixed (double* proj_ptr = proj)
|
||||||
|
fixed (Int32* view_ptr = view)
|
||||||
|
{
|
||||||
|
Int32 retval = Delegates.gluUnProject((double)win.X, (double)win.Y, (double)win.Z, (double*)model_ptr, (double*)proj_ptr, (Int32*)view_ptr, (double*)objX_ptr, (double*)objY_ptr, (double*)objZ_ptr);
|
||||||
|
obj = new Vector3((float)*objX_ptr, (float)*objY_ptr, (float)*objZ_ptr);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
Int32 UnProject4(Vector4 win, double[] model, double[] proj, Int32[] view, double near, double far, out Vector4 obj)
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
double objX, objY, objZ, objW;
|
||||||
|
double* objX_ptr = &objX;
|
||||||
|
double* objY_ptr = &objY;
|
||||||
|
double* objZ_ptr = &objZ;
|
||||||
|
double* objW_ptr = &objW;
|
||||||
|
fixed (double* model_ptr = model)
|
||||||
|
fixed (double* proj_ptr = proj)
|
||||||
|
fixed (Int32* view_ptr = view)
|
||||||
|
{
|
||||||
|
Int32 retval = Delegates.gluUnProject4((double)win.X, (double)win.Y, (double)win.Z, (double)win.W, (double*)model_ptr, (double*)proj_ptr, (Int32*)view_ptr, (double)near, (double)far, (double*)objX_ptr, (double*)objY_ptr, (double*)objZ_ptr, (double*)objW_ptr);
|
||||||
|
obj = new Vector4((float)*objX_ptr, (float)*objY_ptr, (float)*objZ_ptr, (float)*objW_ptr);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue