mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-26 12:35:37 +00:00
3462e80978
Removed OpenTK.Graphics.Glu class (reason: deprecated upstream; most functionality provided by OpenTK math; not compatible with OpenGL 3.0+.) OpenTK.Graphics.Glu can be accessed through OpenTK.Compatibility. Added OpenGL|ES-specific ErrorHelper classes. Moved OpenTK.Graphics.DisplayDevice and OpenTK.Graphics.DisplayResolution to the root OpenTK namespace (reason: their functionality is not specific and does not depend on OpenTK.Graphics). Split Graphics*Exception classes into different files. Made GraphicsErrorException public (reason: necessary for OpenTK.Compatibility).
106 lines
2.6 KiB
C#
106 lines
2.6 KiB
C#
#region --- License ---
|
|
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
|
* See license.txt for license info
|
|
*/
|
|
#endregion
|
|
|
|
#region --- Using directives ---
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
using OpenTK;
|
|
using OpenTK.Graphics.OpenGL;
|
|
|
|
#endregion
|
|
|
|
namespace Examples.WinForms
|
|
{
|
|
[Example("Simple GLControl", ExampleCategory.OpenTK, "GLControl", 1, Documentation="SimpleGLControl")]
|
|
public partial class SimpleForm : Form
|
|
{
|
|
public SimpleForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region Events
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
glControl1_Resize(this, EventArgs.Empty); // Ensure the Viewport is set up correctly
|
|
GL.ClearColor(Color.Crimson);
|
|
}
|
|
|
|
private void redButton_Click(object sender, EventArgs e)
|
|
{
|
|
GL.ClearColor(Color.Crimson);
|
|
glControl1.Invalidate();
|
|
}
|
|
|
|
private void greenButton_Click(object sender, EventArgs e)
|
|
{
|
|
GL.ClearColor(Color.ForestGreen);
|
|
glControl1.Invalidate();
|
|
}
|
|
|
|
private void blueButton_Click(object sender, EventArgs e)
|
|
{
|
|
GL.ClearColor(Color.RoyalBlue);
|
|
glControl1.Invalidate();
|
|
}
|
|
|
|
private void glControl1_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
glControl1.MakeCurrent();
|
|
|
|
GL.Clear(ClearBufferMask.ColorBufferBit);
|
|
glControl1.SwapBuffers();
|
|
}
|
|
|
|
private void glControl1_Resize(object sender, EventArgs e)
|
|
{
|
|
if (glControl1.ClientSize.Height == 0)
|
|
glControl1.ClientSize = new System.Drawing.Size(glControl1.ClientSize.Width, 1);
|
|
|
|
GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
|
|
}
|
|
|
|
private void glControl1_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
switch (e.KeyData)
|
|
{
|
|
case Keys.Escape:
|
|
this.Close();
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region public static void Main()
|
|
|
|
/// <summary>
|
|
/// Entry point of this example.
|
|
/// </summary>
|
|
[STAThread]
|
|
public static void Main()
|
|
{
|
|
using (SimpleForm example = new SimpleForm())
|
|
{
|
|
Utilities.SetWindowTitle(example);
|
|
example.ShowDialog();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|