Click here to Skip to main content
15,885,985 members
Articles / Multimedia / OpenGL

Creating a Window - Building a 3D Engine

Rate me:
Please Sign up or sign in to vote.
3.67/5 (4 votes)
7 Feb 2009CPOL4 min read 50.4K   2K   35  
This article describes the creation of an OpenGL window or OpenGL control with C# and Tao Framework
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tao.OpenGl;

namespace AGE_Engine3D.RenderObjects
{
    class TriangleGroup : IRenderOpenGL
    {
        #region Fields
        public List<Vertex> Vetices = new List<Vertex>();
        public bool IsFan = false; 
        #endregion

        #region Methods
        public void RenderOpenGL()
        {
            if (this.IsFan)
                Gl.glBegin(Gl.GL_TRIANGLE_FAN);
            else
                Gl.glBegin(Gl.GL_TRIANGLE_STRIP);

            foreach (Vertex tmpV in this.Vetices)
            {
                if(tmpV.IsColor)
                    Gl.glColor4fv(tmpV.Color.ToArray4f());
                if(tmpV.IsTextured)
                    Gl.glTexCoord2fv(tmpV.TextureCoor.ToArray2f());
                if(tmpV.IsNormal)
                    Gl.glNormal3fv(tmpV.Normal.ToArray3f());
                Gl.glVertex3fv(tmpV.Position.ToArray3f());
            }
            Gl.glEnd();
        } 
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer Lea+Elliott, Inc.
United States United States
I am a licensed Electrical Engineer at Lea+Elliott, Inc. We specialize in the planning, procurement and implementation of transportation systems, with special emphasis on automated and emerging technologies.

Comments and Discussions