tags:

views:

644

answers:

3

I am working on an OpenGL project for a computer graphics course, and I have not been actively programming for around a years time (military training). I am drawing an absolute blank on how to include a source file in C#. I know in C++ you use #include . I have no clue how to use the figure class I made in my form.

A: 
  1. Add the Tao.OpenGL DLL as a project reference.
  2. Add any using statements at the top of your C# file, such as:

    using Tao.OpenGL;

The first option is what actually "includes" the DLL so it can be found. The second step is technically optionally, but without it, you'll need to make every GL call like Tao.OpenGL.GL.GlMethodGoesHere(); instead of just GL.GlMethodGoesHere();

Reed Copsey
A: 

haha, I meant including my own class that I made, but I figured it out. Had to use "using myClass," not the file name..

Spenser
A: 

Also look at http://www.opentk.com as it is better suited for C#. For example it uses native enums for the OpenGL constants. I usually add a reference

using gl = OpenTK.Graphics.OpenGL.GL;
using vec3 = OpenTK.Vector3d;
using col = System.Drawing.Color;

and then in my code I just type

        ...
        vec3 pos = new vec3(10f,0f,0f);
        gl.Disable(EnableCap.Lighting);
        gl.LineWidth(2f);
        gl.Color3(col.DimGray);
        gl.Begin(BeginMode.Lines);
        gl.Vertex3(0.0, 0.0, 0.0);
        gl.Vertex3(pos);
        gl.End();
        gl.Enable(EnableCap.Lighting);
        ...
jalexiou