Hi, a simple code of C# using OpenTK doesn’t work (the form is not painted). What I have to fix? thanks.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenTK.Graphics;
namespace gltest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void glControl1_Load(object sender, EventArgs e)
{
InitGL();
}
private void InitGL()
{
GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(-20, 20, -20, 20, -1, 1);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.Viewport(0, 0, 297, 270);
}
private void glControl1_Paint(object sender, PaintEventArgs e)
{
double ang;
double x, y;
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.Begin(BeginMode.Polygon);
for (ang = 0; ang < Math.PI; ang += (Math.PI / 3))
{
x = 10 * Math.Cos(ang);
y = 10 * Math.Sin(ang);
GL.Vertex2(x, y);
}
GL.End();
}
}
}