flopoloco's picture

Super Lazy OpenTK Initialization

This is a simple test I make just to test delegates and having a glimpse of C# Lamba glamour. I don't know if it useful but it's for sure very easy and minimalistic.

using System;
using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
 
namespace LearningOpenTK
{
	// Super Lazy
	class Program
	{
		public static void Main(string[] args)
		{
			GameWindow g = new GameWindow(800, 600);
 
			g.KeyPress += delegate {
				g.Exit();
			};
 
			g.Load += delegate {
				GL.ClearColor(Color.Red);
			};
 
			g.RenderFrame += delegate(object sender, FrameEventArgs e) { 
				GL.Clear(ClearBufferMask.ColorBufferBit);
				System.Diagnostics.Debug.WriteLine(e.Time.ToString());
				((GameWindow)sender).SwapBuffers();
			};
 
			g.Run();
			g.Dispose();
		}
	}
}

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
n8dog's picture

Interesting! Thanks for sharing this!