Hi everybody,
I am trying learn something in OpenGL. I choose TAO framework for programming in C#. I just know how can I draw some shapes, change colors etc. but now I would like move with scene and I can't find out how. I am using component SimpleOpenGlControl from TAO Framework and I need redraw all scene after some event for example MoveMouse.
In constructor of Form I have all initial needs.
double xrot = 0;
public Form1()
{
InitializeComponent();
int height = simpleOpenGlControl1.Height;
int width = simpleOpenGlControl1.Width;
simpleOpenGlControl1.InitializeContexts();
Gl.glViewport(0, 0, width, height);
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Glu.gluPerspective(45.0f, (double)width / (double)height, 0.01f, 5000.0f);
Gl.glClearColor(1, 1, 1, 0);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
}
Very simple drawing function.
private void Draw()
{
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
Gl.glTranslated(0, 0, -3);
Gl.glRotated(xrot++, 1, 0, 0);
Gl.glBegin(Gl.GL_TRIANGLES);
Gl.glColor3d(1, 0, 0);
Gl.glVertex2d(0, 0.5);
Gl.glColor3d(0, 1, 0);
Gl.glVertex2d(-0.5, -0.5);
Gl.glColor3d(0, 0, 1);
Gl.glVertex2d(+0.5, -0.5);
Gl.glEnd();
Gl.glFlush();
}
And calling function in Load and MouseMove events.
private void simpleOpenGlControl1_Load(object sender, EventArgs e)
{
Draw();
}
private void simpleOpenGlControl1_MouseMove(object sender, MouseEventArgs e)
{
Draw();
}
Imidiatelly after start program is all right (scene is painted without move), but it doesn't do anything on MouseMove event - scene is still the same, without any move. I tryed any others events like KeyPress, MouseClick but still without succesfull. I tryed debug it as well but everything looks good. Can you tell me what's wrong?