mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-27 21:15:36 +00:00
0e02f67749
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).
173 lines
5.6 KiB
C#
173 lines
5.6 KiB
C#
#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
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
using OpenTK;
|
|
using OpenTK.Graphics;
|
|
using OpenTK.Graphics.OpenGL;
|
|
using OpenTK.Input;
|
|
using System.Drawing;
|
|
|
|
namespace Examples
|
|
{
|
|
[Example("Fullscreen Antialiasing", ExampleCategory.OpenTK, "GameWindow", Documentation = "GameWindowFsaa")]
|
|
public class FullscreenAntialias : GameWindow
|
|
{
|
|
public FullscreenAntialias()
|
|
: base(800, 600, new GraphicsMode(32, 0, 0, 4))
|
|
{
|
|
Keyboard.KeyDown += delegate(KeyboardDevice sender, Key key)
|
|
{
|
|
if (sender[Key.Escape])
|
|
this.Exit();
|
|
|
|
if ((sender[Key.AltLeft] || sender[Key.AltRight]) && (sender[Key.Enter] || sender[Key.KeypadEnter]))
|
|
if (this.WindowState == WindowState.Fullscreen)
|
|
this.WindowState = WindowState.Normal;
|
|
else
|
|
this.WindowState = WindowState.Fullscreen;
|
|
};
|
|
}
|
|
|
|
#region Keyboard_KeyDown
|
|
|
|
/// <summary>
|
|
/// Occurs when a key is pressed.
|
|
/// </summary>
|
|
/// <param name="sender">The KeyboardDevice which generated this event.</param>
|
|
/// <param name="key">The key that was pressed.</param>
|
|
void Keyboard_KeyDown(KeyboardDevice sender, Key key)
|
|
{
|
|
if (sender[Key.Escape])
|
|
this.Exit();
|
|
|
|
if ((sender[Key.AltLeft] || sender[Key.AltRight]) && (sender[Key.Enter] || sender[Key.KeypadEnter]))
|
|
if (this.WindowState == WindowState.Fullscreen)
|
|
this.WindowState = WindowState.Normal;
|
|
else
|
|
this.WindowState = WindowState.Fullscreen;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region OnLoad
|
|
|
|
/// <summary>
|
|
/// Setup OpenGL and load resources here.
|
|
/// </summary>
|
|
/// <param name="e">Not used.</param>
|
|
public override void OnLoad(EventArgs e)
|
|
{
|
|
GL.ClearColor(Color.MidnightBlue);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region OnResize
|
|
|
|
/// <summary>
|
|
/// Respond to resize events here.
|
|
/// </summary>
|
|
/// <param name="e">Contains information on the new GameWindow size.</param>
|
|
/// <remarks>There is no need to call the base implementation.</remarks>
|
|
protected override void OnResize(EventArgs e)
|
|
{
|
|
GL.Viewport(0, 0, Width, Height);
|
|
|
|
GL.MatrixMode(MatrixMode.Projection);
|
|
GL.LoadIdentity();
|
|
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
|
|
|
|
base.OnResize(e);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region OnUpdateFrame
|
|
|
|
/// <summary>
|
|
/// Add your game logic here.
|
|
/// </summary>
|
|
/// <param name="e">Contains timing information.</param>
|
|
/// <remarks>There is no need to call the base implementation.</remarks>
|
|
protected override void OnUpdateFrame(FrameEventArgs e)
|
|
{
|
|
// Nothing to do!
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region OnRenderFrame
|
|
|
|
/// <summary>
|
|
/// Add your game rendering code here.
|
|
/// </summary>
|
|
/// <param name="e">Contains timing information.</param>
|
|
/// <remarks>There is no need to call the base implementation.</remarks>
|
|
protected override void OnRenderFrame(FrameEventArgs e)
|
|
{
|
|
GL.Clear(ClearBufferMask.ColorBufferBit);
|
|
|
|
GL.Begin(BeginMode.Triangles);
|
|
|
|
GL.Color3(Color.MidnightBlue);
|
|
GL.Vertex2(-1.0f, 1.0f);
|
|
GL.Color3(Color.SpringGreen);
|
|
GL.Vertex2(0.0f, -1.0f);
|
|
GL.Color3(Color.Ivory);
|
|
GL.Vertex2(1.0f, 1.0f);
|
|
|
|
GL.End();
|
|
|
|
this.SwapBuffers();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region public static void Main()
|
|
|
|
/// <summary>
|
|
/// Entry point of this example.
|
|
/// </summary>
|
|
[STAThread]
|
|
public static void Main()
|
|
{
|
|
using (FullscreenAntialias example = new FullscreenAntialias())
|
|
{
|
|
// Get the title and category of this example using reflection.
|
|
Utilities.SetWindowTitle(example);
|
|
example.Run(30.0, 0.0);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|