I think it is how you have your control declared in the constructor. If you added the SimpleOpenGlControl to the form then the constructor code you are using is pointing to a new reference not the one in the controls collection. If I use the code below I get a white background and it looks like a fuscia colored square. As I suspected Gl variable is a static class in the library...
As you see in the form2_load method I am generating a new object of SimpleOpenGlControl, initializing its context and then adding a handler to the paint event and finally adding the control to the forms control collection. I am not familiar with the OpenGL libraries so cannot give you any advice on drawing, but at least this will show you what you expected to see previously (although I am filling with white instead of black in the glClearColor method)...
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 Tao.OpenGl;
using Tao.Platform.Windows;
namespace Testing
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Tao.Platform.Windows.SimpleOpenGlControl gl = new Tao.Platform.Windows.SimpleOpenGlControl();
gl.InitializeContexts();
gl.Paint += new PaintEventHandler(gl_Paint);
this.Controls.Add(gl);
}
void gl_Paint(object sender, PaintEventArgs e)
{
Gl.glClearColor(255.0f, 255.0f, 255.0f, 255.0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
Gl.glBegin(Gl.GL_POLYGON);
Gl.glColor3f(1.0f, 0.0f, 1.0f);
Gl.glVertex3f(0.25f, 0.25f, 0.0f);
Gl.glVertex3f(0.75f, 0.25f, 0.0f);
Gl.glVertex3f(0.75f, 0.75f, 0.0f);
Gl.glVertex3f(0.25f, 0.75f, 0.25f);
Gl.glEnd();
Gl.glFlush();
}
}
}