mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-07 19:20:41 +00:00
Updated to use the ExampleAttribute instead of the old IExample interface.
This commit is contained in:
parent
a1a2de03c9
commit
e7c3fbd1b5
|
@ -12,13 +12,15 @@ using System.Drawing;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using Examples.Shapes;
|
using Examples.Shapes;
|
||||||
|
using OpenTK.Math;
|
||||||
|
|
||||||
namespace Examples.Tutorial
|
namespace Examples.Tutorial
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Demonstrates fixed-function OpenGL lighting. Example is incomplete (documentation).
|
/// Demonstrates fixed-function OpenGL lighting. Example is incomplete (documentation).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class T04_Vertex_Lighting : GameWindow, IExample
|
[Example("Vertex Lighting", ExampleCategory.OpenGL)]
|
||||||
|
public class T04_Vertex_Lighting : GameWindow
|
||||||
{
|
{
|
||||||
float x_angle, zoom;
|
float x_angle, zoom;
|
||||||
Shape shape = new Plane(16, 16, 4.0f, 4.0f);
|
Shape shape = new Plane(16, 16, 4.0f, 4.0f);
|
||||||
|
@ -116,13 +118,11 @@ namespace Examples.Tutorial
|
||||||
WindowState = WindowState.Normal;
|
WindowState = WindowState.Normal;
|
||||||
|
|
||||||
if (Mouse[OpenTK.Input.MouseButton.Left])
|
if (Mouse[OpenTK.Input.MouseButton.Left])
|
||||||
x_angle += Mouse.XDelta;
|
x_angle = Mouse.X;
|
||||||
else
|
else
|
||||||
x_angle += 0.5f;
|
x_angle += 0.5f;
|
||||||
|
|
||||||
// zoom = Mouse.Wheel * 0.5f; // Mouse.Wheel is broken on both Linux and Windows.
|
zoom = Mouse.Wheel * 0.5f; // Mouse.Wheel is broken on both Linux and Windows.
|
||||||
if (Mouse[OpenTK.Input.MouseButton.Right])
|
|
||||||
zoom += Mouse.YDelta;
|
|
||||||
|
|
||||||
// Do not leave x_angle drift too far away, as this will cause inaccuracies.
|
// Do not leave x_angle drift too far away, as this will cause inaccuracies.
|
||||||
if (x_angle > 360.0f)
|
if (x_angle > 360.0f)
|
||||||
|
@ -149,9 +149,13 @@ namespace Examples.Tutorial
|
||||||
0.0, 1.0, 0.0);
|
0.0, 1.0, 0.0);
|
||||||
GL.Rotate(x_angle, 0.0f, 1.0f, 0.0f);
|
GL.Rotate(x_angle, 0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
//GL.DrawElements(GL.Enums.BeginMode.TRIANGLES, shape.Indices.Length,
|
GL.Begin(BeginMode.Triangles);
|
||||||
// GL.Enums.All.UNSIGNED_INT, shape.Indices);
|
foreach (int index in shape.Indices)
|
||||||
GL.DrawArrays(BeginMode.Points, 0, shape.Vertices.Length);
|
{
|
||||||
|
GL.Normal3(shape.Normals[index]);
|
||||||
|
GL.Vertex3(shape.Vertices[index]);
|
||||||
|
}
|
||||||
|
GL.End();
|
||||||
|
|
||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
}
|
}
|
||||||
|
@ -166,14 +170,15 @@ namespace Examples.Tutorial
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Provides a simple way for the example launcher to launch the examples.
|
/// Provides a simple way for the example launcher to launch the examples.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void Launch()
|
public static void Main()
|
||||||
{
|
{
|
||||||
// Lock UpdateFrame and RenderFrame at 60Hz.
|
using (T04_Vertex_Lighting example = new T04_Vertex_Lighting())
|
||||||
Run(60.0, 60.0);
|
{
|
||||||
|
Utilities.SetWindowTitle(example);
|
||||||
|
example.Run(30.0, 0.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static readonly int order = 4;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue