📅 2013-Jun-18 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ csharp, freeglut, glu, glut, opengl, opentk, tao framework, visual studio ⬩ 📚 Archive
The Tao Framework is a .Net wrapper library for the OpenGL, GLU, FreeGLUT and Cg libraries. It is now deprecated and its functionality has been superseded by the OpenTK project. However, it is perfect for writing simple OpenGL or GLUT programs in .Net languages like C#.
Getting started on the Tao Framework using C# is easy:
Download and install the last version of Tao Framework from here. The installer will add its .Net assemblies to the GAC.
Create an empty C# console application project in Visual Studio.
Add references to Tao.OpenGL.dll and Tao.FreeGLUT.dll to the project. These files can be found in **C:Files (x86)*
Paste the source code given below into the C# source file.
Copy FreeGLUT.dll from **C:Files (x86)* to directory of the generated EXE file.
Run the program. You should see a grey teapot!
Whether you are porting an existing C or C++ OpenGL application or writing your own, it should be easy to build upon this program.
// C# program that uses Tao framework to call
// OpenGL, GLU and FreeGLUT functions.
//
// Steps:
// 1. Install Tao framework. Its .Net assemblies will be added to GAC.
// 2. Create an empty C# console application project in Visual Studio
// 3. Add references to Tao.OpenGL.dll and Tao.FreeGLUT.dll to the project.
// These files are in C:\Program Files (x86)\TaoFramework\bin
// 4. Paste this source code into the C# source file
// 5. Copy FreeGLUT.dll from C:\Program Files (x86)\TaoFramework\lib to
// directory of the generated EXE file
// 6. Run. You should see a grey teapot.
//
// Copyright (c) 2013 Ashwin Nanjappa
// Released under the MIT License
using System;
using Tao.OpenGl;
using Tao.FreeGlut;
namespace TaoExample
{class Program
{static void init_graphics()
{glEnable(Gl.GL_LIGHTING);
Gl.glEnable(Gl.GL_LIGHT0);
Gl.float[] light_pos = new float[3] {1, 0.5F, 1};
glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, light_pos);
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glClearColor(1, 1, 1, 1);
Gl.
}
static void on_display()
{glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glLoadIdentity();
Gl.gluLookAt(0, 0, 5, 0, 0, 1, 0, 1, 0);
Glu.glutSolidTeapot(1);
Glut.glutSwapBuffers();
Glut.
}
static void on_reshape(int w, int h)
{glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Gl.glViewport(0, 0, w, h);
Gl.gluPerspective(40, w / h, 1, 100);
Glu.glMatrixMode(Gl.GL_MODELVIEW);
Gl.
}
static void Main()
{glutInit();
Glut.glutInitWindowSize(500, 500);
Glut.glutCreateWindow("Tao Example");
Glut.init_graphics();
glutDisplayFunc(on_display);
Glut.glutReshapeFunc(on_reshape);
Glut.glutMainLoop();
Glut.
}
} }
Tried with: Tao Framework 2.1.0, Visual Studio 2012 and Windows 7 x64