mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 16:25:37 +00:00
Added OpenGL|ES 2.0 sample.
This commit is contained in:
parent
c1f41d1eb9
commit
bb49daff4c
192
Source/Examples/OpenGLES/2.0/SimpleWindow20.cs
Normal file
192
Source/Examples/OpenGLES/2.0/SimpleWindow20.cs
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
#region License
|
||||||
|
//
|
||||||
|
// The Open Toolkit Library License
|
||||||
|
//
|
||||||
|
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights to
|
||||||
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
// the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
// so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Using Directives
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
using OpenTK;
|
||||||
|
using OpenTK.Graphics;
|
||||||
|
using OpenTK.Graphics.ES20;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Examples.Tutorial
|
||||||
|
{
|
||||||
|
[Example("Immediate mode", ExampleCategory.OpenGLES, "2.0", Documentation = "SimpleES20Window")]
|
||||||
|
public class SimpleES20Window : GameWindow
|
||||||
|
{
|
||||||
|
#region --- Fields ---
|
||||||
|
|
||||||
|
float rotation_speed = 3.0f;
|
||||||
|
float angle;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --- Constructor ---
|
||||||
|
|
||||||
|
public SimpleES20Window()
|
||||||
|
: base(800, 600, new GraphicsMode(16, 16), "", GameWindowFlags.Default, DisplayDevice.Default, 2, 0, GraphicsContextFlags.Embedded)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region OnLoad
|
||||||
|
|
||||||
|
public override void OnLoad(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnLoad(e);
|
||||||
|
|
||||||
|
Color color = Color.MidnightBlue;
|
||||||
|
GL.ClearColor(color.R, color.G, color.B, color.A);
|
||||||
|
GL.Enable((All)EnableCap.DepthTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region OnResize
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the user resizes the window.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">Contains the new width/height of the window.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// You want the OpenGL viewport to match the window. This is the place to do it!
|
||||||
|
/// </remarks>
|
||||||
|
protected override void OnResize(EventArgs e)
|
||||||
|
{
|
||||||
|
GL.Viewport(0, 0, Width, Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region OnUpdateFrame
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prepares the next frame for rendering.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Place your control logic here. This is the place to respond to user input,
|
||||||
|
/// update object positions etc.
|
||||||
|
/// </remarks>
|
||||||
|
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||||
|
{
|
||||||
|
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||||
|
{
|
||||||
|
this.Exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region OnRenderFrame
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Place your rendering code here.
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnRenderFrame(FrameEventArgs e)
|
||||||
|
{
|
||||||
|
GL.Clear((uint)(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit));
|
||||||
|
|
||||||
|
this.SwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region private void DrawCube()
|
||||||
|
|
||||||
|
private void DrawCube()
|
||||||
|
{
|
||||||
|
#if false
|
||||||
|
GL.Begin(BeginMode.Quads);
|
||||||
|
|
||||||
|
GL.Color3(Color.Silver);
|
||||||
|
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||||
|
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||||
|
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||||
|
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||||
|
|
||||||
|
GL.Color3(Color.Honeydew);
|
||||||
|
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||||
|
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||||
|
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||||
|
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||||
|
|
||||||
|
GL.Color3(Color.Moccasin);
|
||||||
|
|
||||||
|
GL.Vertex3(-1.0f, -1.0f, -1.0f);
|
||||||
|
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||||
|
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||||
|
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||||
|
|
||||||
|
GL.Color3(Color.IndianRed);
|
||||||
|
GL.Vertex3(-1.0f, -1.0f, 1.0f);
|
||||||
|
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||||
|
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||||
|
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
GL.Color3(Color.PaleVioletRed);
|
||||||
|
GL.Vertex3(-1.0f, 1.0f, -1.0f);
|
||||||
|
GL.Vertex3(-1.0f, 1.0f, 1.0f);
|
||||||
|
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||||
|
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||||
|
|
||||||
|
GL.Color3(Color.ForestGreen);
|
||||||
|
GL.Vertex3(1.0f, -1.0f, -1.0f);
|
||||||
|
GL.Vertex3(1.0f, 1.0f, -1.0f);
|
||||||
|
GL.Vertex3(1.0f, 1.0f, 1.0f);
|
||||||
|
GL.Vertex3(1.0f, -1.0f, 1.0f);
|
||||||
|
|
||||||
|
GL.End();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public static void Main()
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entry point of this example.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
using (SimpleES20Window example = new SimpleES20Window())
|
||||||
|
{
|
||||||
|
Utilities.SetWindowTitle(example);
|
||||||
|
example.Run(30.0, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
0
Source/Examples/OpenGLES/SimpleWindow20.cs
Normal file
0
Source/Examples/OpenGLES/SimpleWindow20.cs
Normal file
Loading…
Reference in a new issue