Glut functions. Use a glut functions leads to a drop of a program

701 views Asked by At

I use Tao Framework for lerning openGL. I included all libraries what that need, including Tao.FreeGlut.dll. At a execution stage program at the point of use glut function terminates. Why this is so? errors at compile time does not occur, the program just closes.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using Tao.DevIl;
using Tao.OpenGl;
using Tao.FreeGlut;

        private void Form1_Load(object sender, EventArgs e)
    {
        Gl.glMatrixMode(Gl.GL_PROJECTION);           
        Gl.glLoadIdentity();             

        Glu.gluPerspective(45, (float)AnT.Width / (float)AnT.Height, 0.1, 200);

        Gl.glMatrixMode(Gl.GL_MODELVIEW);          
        Gl.glLoadIdentity();              


        Draw();
    }
    public void Draw() {
        Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
        Gl.glLoadIdentity();
        float[] color = new float[4] { 1, 0, 0, 1 };
        float[] shininess = new float[1] { 30 };
        Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, color); 
        Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, color);
        Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SHININESS, shininess);
        //----------------------------
        Gl.glPushMatrix();
        Gl.glTranslated(0, 0, -6);
        Gl.glRotated(45, 1, 1, 0);

        Glut.glutSolidTeapot(1);  // <- exit
        Gl.glPopMatrix();
        Gl.glFlush();
        AnT.Invalidate();
    }
1

There are 1 answers

2
Evgeny Gerbut On

Andon M. Coleman, thanks. Glut library must be initialized before using