Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
85 lines (71 sloc) 1.9 KB
using System;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL4;
namespace OpenTKProj
{
public class Main : GameWindow
{
private RedPoint _redPoint;
public Main() :
base(
GameSettings.kWidth,
GameSettings.kHeight,
GraphicsMode.Default,
GameSettings.kTitle,
GameWindowFlags.FixedWindow,
DisplayDevice.Default,
4,
0,
GraphicsContextFlags.ForwardCompatible)
{
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, Width, Height);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
LoadContent();
}
private void LoadContent()
{
_redPoint = new RedPoint();
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
Update(e.Time);
}
private void Update(double time)
{
}
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
Draw(e.Time);
}
private void Draw(double time)
{
SetBackColour(0f, 0f, 1f, 1f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
_redPoint.Draw();
SwapBuffers();
}
private void SetBackColour(float r, float g, float b, float a)
{
Color4 backColor;
backColor.A = a;
backColor.R = r;
backColor.G = g;
backColor.B = b;
GL.ClearColor(backColor);
}
protected override void Dispose(bool manual)
{
base.Dispose(manual);
}
}
}