mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-11 20:55:45 +00:00
Added ordering information.
This commit is contained in:
parent
25bf4396c5
commit
a78449d6f2
|
@ -37,9 +37,8 @@ namespace Examples.Tests
|
||||||
|
|
||||||
void LaunchGameWindow()
|
void LaunchGameWindow()
|
||||||
{
|
{
|
||||||
hidden = new GameWindow();
|
hidden = new GameWindow(new DisplayMode(30, 30), "OpenTK | Hidden input window");
|
||||||
hidden.Load += hidden_Load;
|
hidden.Load += hidden_Load;
|
||||||
hidden.CreateWindow(new DisplayMode(30, 30), "OpenTK | Hidden input window");
|
|
||||||
hidden.Run(60.0, 1.0);
|
hidden.Run(60.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +119,8 @@ namespace Examples.Tests
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly int order = 2;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void ChooseMouse_SelectedIndexChanged(object sender, EventArgs e)
|
private void ChooseMouse_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
|
|
@ -20,9 +20,8 @@ namespace Examples.Tutorial
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class T01_Simple_Window : GameWindow, IExample
|
public class T01_Simple_Window : GameWindow, IExample
|
||||||
{
|
{
|
||||||
public T01_Simple_Window()
|
public T01_Simple_Window() : base(new DisplayMode(800, 600), "OpenTK | Tutorial 1: Simple Window")
|
||||||
{
|
{
|
||||||
this.CreateWindow(new DisplayMode(800, 600), "OpenTK | Tutorial 1: Simple Window");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region OnLoad
|
#region OnLoad
|
||||||
|
@ -113,6 +112,8 @@ namespace Examples.Tutorial
|
||||||
this.Run(30.0, 5.0);
|
this.Run(30.0, 5.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly int order = 1;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ using System.Threading;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.OpenGL;
|
using OpenTK.OpenGL;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace Examples.Tutorial
|
namespace Examples.Tutorial
|
||||||
{
|
{
|
||||||
|
@ -21,20 +22,31 @@ namespace Examples.Tutorial
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class T02_Vertex_Arrays : GameWindow, IExample
|
class T02_Vertex_Arrays : GameWindow, IExample
|
||||||
{
|
{
|
||||||
float angle_speed = 3.0f;
|
float rotation_speed = 3.0f;
|
||||||
float angle = 0.0f;
|
float angle = 0.0f;
|
||||||
|
|
||||||
Shapes.Shape shape = new Examples.Shapes.Plane(16, 16, 2.0f, 2.0f);
|
Shapes.Shape shape = new Examples.Shapes.Plane(16, 16, 2.0f, 2.0f);
|
||||||
|
|
||||||
System.Threading.Timer info_timer;
|
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
|
|
||||||
public T02_Vertex_Arrays()
|
public T02_Vertex_Arrays() : base(new DisplayMode(800, 600), "OpenTK Tutorial 2: Vertex Arrays")
|
||||||
{
|
{
|
||||||
this.CreateWindow(new DisplayMode(800, 600));
|
this.VSync = VSyncMode.On;
|
||||||
//Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
|
this.Keyboard.KeyUp += new KeyUpEvent(Keyboard_KeyUp);
|
||||||
//this.VSync = VSyncMode.Off;
|
}
|
||||||
|
|
||||||
|
void Keyboard_KeyUp(KeyboardDevice sender, Key key)
|
||||||
|
{
|
||||||
|
// F4 cycles between available VSync modes.
|
||||||
|
if (key == Key.F4)
|
||||||
|
{
|
||||||
|
if (this.VSync == VSyncMode.Off)
|
||||||
|
this.VSync = VSyncMode.On;
|
||||||
|
else if (this.VSync == VSyncMode.On)
|
||||||
|
this.VSync = VSyncMode.Adaptive;
|
||||||
|
else
|
||||||
|
this.VSync = VSyncMode.Off;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -45,34 +57,17 @@ namespace Examples.Tutorial
|
||||||
{
|
{
|
||||||
base.OnLoad(e);
|
base.OnLoad(e);
|
||||||
|
|
||||||
GL.ClearColor(Color.MidnightBlue);
|
GL.ClearColor(Color.CadetBlue);
|
||||||
GL.Enable(GL.Enums.EnableCap.DEPTH_TEST);
|
GL.Enable(GL.Enums.EnableCap.DEPTH_TEST);
|
||||||
|
|
||||||
GL.EnableClientState(GL.Enums.EnableCap.VERTEX_ARRAY);
|
GL.EnableClientState(GL.Enums.EnableCap.VERTEX_ARRAY);
|
||||||
//GL.EnableClientState(GL.Enums.EnableCap.COLOR_ARRAY);
|
//GL.EnableClientState(GL.Enums.EnableCap.COLOR_ARRAY);
|
||||||
GL.VertexPointer(3, GL.Enums.VertexPointerType.FLOAT, 0, shape.Vertices);
|
GL.VertexPointer(3, GL.Enums.VertexPointerType.FLOAT, 0, shape.Vertices);
|
||||||
//GL.ColorPointer(4, GL.Enums.ColorPointerType.UNSIGNED_BYTE, 0, shape.Colors);
|
//GL.ColorPointer(4, GL.Enums.ColorPointerType.UNSIGNED_BYTE, 0, shape.Colors);
|
||||||
|
|
||||||
factor_target = TargetRenderPeriod / TargetUpdatePeriod;
|
|
||||||
info_timer = new Timer(new TimerCallback(PrintDebugInfo), null, 1000, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
double factor_target;
|
|
||||||
void PrintDebugInfo(object o)
|
|
||||||
{
|
|
||||||
double factor = RenderPeriod / UpdatePeriod;
|
|
||||||
Debug.Print("NORMAL: Frame: {0} ({1}), Update: {2} ({3}), Factor: {4}, Error: {5}",
|
|
||||||
RenderPeriod.ToString("g8"), RenderFrequency.ToString("g3"), UpdatePeriod.ToString("g8"), UpdateFrequency.ToString("g3"),
|
|
||||||
factor.ToString("g8"), Math.Abs(factor_target - factor).ToString("g8"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public override void OnUnload(EventArgs e)
|
|
||||||
{
|
|
||||||
info_timer.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region OnResize
|
#region OnResize
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -108,33 +103,29 @@ namespace Examples.Tutorial
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||||
{
|
{
|
||||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
// Escape quits.
|
||||||
|
if (Keyboard[Key.Escape])
|
||||||
{
|
{
|
||||||
this.Exit();
|
this.Exit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Keyboard[OpenTK.Input.Key.AltLeft] || Keyboard[OpenTK.Input.Key.AltRight]) &&
|
// Alt+Enter toggles fullscreen mode.
|
||||||
Keyboard[OpenTK.Input.Key.Enter])
|
if ((Keyboard[Key.AltLeft] || Keyboard[Key.AltRight]) && Keyboard[Key.Enter])
|
||||||
{
|
{
|
||||||
Fullscreen = !Fullscreen;
|
Fullscreen = !Fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Keyboard[OpenTK.Input.Key.Plus])
|
// Plus/Minus change the target render frequency.
|
||||||
TargetRenderFrequency++;
|
// PageUp/PageDown change the target update frequency.
|
||||||
else if (Keyboard[OpenTK.Input.Key.Minus])
|
if (Keyboard[Key.Plus] || Keyboard[Key.KeypadAdd]) TargetRenderFrequency++;
|
||||||
TargetRenderFrequency--;
|
if (Keyboard[Key.Minus] || Keyboard[Key.KeypadSubtract]) TargetRenderFrequency--;
|
||||||
else if (Keyboard[OpenTK.Input.Key.PageUp])
|
if (Keyboard[Key.PageUp]) TargetUpdateFrequency++;
|
||||||
TargetUpdateFrequency++;
|
if (Keyboard[Key.PageDown]) TargetUpdateFrequency--;
|
||||||
else if (Keyboard[OpenTK.Input.Key.PageDown])
|
|
||||||
TargetUpdateFrequency--;
|
|
||||||
|
|
||||||
if (Keyboard[OpenTK.Input.Key.Space])
|
// Right/Left control the rotation speed and direction.
|
||||||
angle_speed = 12.0f;
|
if (Keyboard[Key.Right]) rotation_speed += 0.5f;
|
||||||
else
|
if (Keyboard[Key.Left]) rotation_speed -= 0.5f;
|
||||||
angle_speed = 3.0f;
|
|
||||||
|
|
||||||
//angle += angle_speed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -156,16 +147,8 @@ namespace Examples.Tutorial
|
||||||
0.0, 1.0, 0.0
|
0.0, 1.0, 0.0
|
||||||
);
|
);
|
||||||
|
|
||||||
//angle += angle_speed * (float)(UpdateFrequency / RenderFrequency);
|
angle += rotation_speed * (float)e.ScaleFactor;
|
||||||
//if (e.Time != 0.0)
|
|
||||||
if (Math.Abs(e.ScaleFactor - factor_target) > 0.5)
|
|
||||||
{
|
|
||||||
/*Debug.Print("JITTER: Frame: {0} ({1}), Update: {2} ({3}), Factor: {4}, Error: {5}",
|
|
||||||
RenderPeriod.ToString("g8"), RenderFrequency.ToString("g3"), UpdatePeriod.ToString("g8"), UpdateFrequency.ToString("g3"),
|
|
||||||
e.ScaleFactor.ToString("g8"), Math.Abs(factor_target - e.ScaleFactor).ToString("g8"));*/
|
|
||||||
}
|
|
||||||
angle += angle_speed * (float)e.ScaleFactor;
|
|
||||||
//angle += angle_speed * (float)e.Time;
|
|
||||||
if (angle >= 360.0f)
|
if (angle >= 360.0f)
|
||||||
angle -= 360.0f;
|
angle -= 360.0f;
|
||||||
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
|
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
|
||||||
|
@ -183,12 +166,7 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
GL.End();
|
GL.End();
|
||||||
|
|
||||||
int zero = GC.CollectionCount(0);
|
|
||||||
int one = GC.CollectionCount(1);
|
|
||||||
int two = GC.CollectionCount(2);
|
|
||||||
|
|
||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
//Thread.Sleep(25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -204,9 +182,12 @@ namespace Examples.Tutorial
|
||||||
public void Launch()
|
public void Launch()
|
||||||
{
|
{
|
||||||
// Lock UpdateFrame rate at 30Hz and RenderFrame rate 85Hz.
|
// Lock UpdateFrame rate at 30Hz and RenderFrame rate 85Hz.
|
||||||
Run(30.0, 20.0);
|
//Run(60.0, 85.0);
|
||||||
|
Run(30.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static readonly int order = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,9 +194,11 @@ namespace Examples.Tutorial
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void Launch()
|
public void Launch()
|
||||||
{
|
{
|
||||||
Run(60.0, 60.0);
|
Run(85.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static readonly int order = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,8 @@ namespace Examples.Tutorial
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
|
|
||||||
public T04_Vertex_Lighting()
|
public T04_Vertex_Lighting() : base(new DisplayMode(800, 600), "OpenTK | Vertex Lighting example")
|
||||||
{
|
{
|
||||||
this.CreateWindow(new DisplayMode(800, 600), "OpenTK | Vertex Lighting example");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -173,5 +172,7 @@ namespace Examples.Tutorial
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static readonly int order = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,5 +155,7 @@ namespace Examples.Tutorial
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static readonly int order = 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -243,5 +243,7 @@ namespace Examples.Tutorial
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static readonly int order = 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,8 @@ void main()
|
||||||
|
|
||||||
#region --- Constructors ---
|
#region --- Constructors ---
|
||||||
|
|
||||||
public T10_GLSL_Cube()
|
public T10_GLSL_Cube() : base(new DisplayMode(800, 600), "OpenTK | GLSL Example 1")
|
||||||
{
|
{
|
||||||
this.CreateWindow(new DisplayMode(800, 600), "OpenTK | GLSL Example 1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -232,6 +231,8 @@ void main()
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IExample members
|
||||||
|
|
||||||
#region public void Launch()
|
#region public void Launch()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -247,5 +248,9 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static readonly int order = 10;
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,8 @@ namespace Examples.WinForms
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly int order = 1;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,8 @@ namespace Examples.WinForms
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly int order = 2;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void glControl_Layout(object sender, LayoutEventArgs e)
|
private void glControl_Layout(object sender, LayoutEventArgs e)
|
||||||
|
|
|
@ -106,10 +106,9 @@ namespace Examples.WinForms
|
||||||
|
|
||||||
#region IExample Members
|
#region IExample Members
|
||||||
|
|
||||||
public void Launch()
|
public void Launch() { }
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public static readonly int order = 3;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue