60 likes | 161 Views
Using OpenGL in C#. by Joshua Shelfer. Setting It Up. www.taoframework.com Install the Setup file Or Download the Zip file Open libwin32deps and copy freeglut.dll Paste freeglut.dll into WINDOWSSystem. Getting Started. Open your .NET solution Click Project > Add Reference
E N D
Using OpenGL in C# by Joshua Shelfer
Setting It Up • www.taoframework.com • Install the Setup file • Or • Download the Zip file • Open lib\win32deps and copy freeglut.dll • Paste freeglut.dll into WINDOWS\System
Getting Started • Open your .NET solution • Click Project > Add Reference • If you installed, find the three Tao GL and GLUT files under .NET tab • If not, find these dlls under the browse tab (located in the bin folder of the Zip file). Keep in mind, the dlls will have to be in the same directory as the Exe file in order for it to run. • Tao.Freeglut.dll • Tao.OpenGL.dll • Tao.OpenGL.Glu.dll
Required Code • Add these lines of code • using Tao.FreeGlut; • using Tao.OpenGl;
Example Code Main function Glut.glutInit(); Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB); Glut.glutInitWindowSize(INITIAL_WIDTH, INITIAL_HEIGHT); Glut.glutInitWindowPosition(0, 0); Glut.glutCreateWindow("Tic Tac Toe"); Glut.glutDisplayFunc(tictactoe.display); Glut.glutMouseFunc(tictactoe.mouseHandler); Glut.glutMotionFunc(tictactoe.motionHandler); Glut.glutReshapeFunc(tictactoe.reshapeHandler); Init function Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); Gl.glColor3f(0.0f, 0.0f, 0.0f); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Glu.gluOrtho2D(0.0, 50.0, 0.0, 50.0); Gl.glMatrixMode(Gl.GL_MODELVIEW);
Pros and Cons • Pros: • Inherent benefits of C# • OOP • Easy to set up • Cons: • Gl., Glut., And Glu. can be cumbersome to type • User must have freeglut.dll in WINDOWS\System folder