当前位置: 首页>>代码示例>>C#>>正文


C# OpenGL.PopName方法代码示例

本文整理汇总了C#中OpenGL.PopName方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.PopName方法的具体用法?C# OpenGL.PopName怎么用?C# OpenGL.PopName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenGL的用法示例。


在下文中一共展示了OpenGL.PopName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        /// <summary>
        /// This function draws the polygon.
        /// </summary>
        /// <param name="gl">OpenGL.</param>
        public override void Draw(OpenGL gl)
        {
            if(DoPreDraw(gl))
            {
                polyAttributes.Set(gl);

                foreach(Face face in faces)
                {
                    //	Begin drawing a polygon.
                    if(face.Indices.Count == 2)
                        gl.Begin(OpenGL.LINES);
                    else
                        gl.Begin(OpenGL.POLYGON);

                    foreach(Index index in face.Indices)
                    {
                        //	Set a texture coord (if any).
                        if(index.UV != -1)
                            gl.TexCoord(uvs[index.UV]);

                        //	Set a normal, or generate one.
                        if(index.Normal != -1)
                            gl.Normal(normals[index.Normal]);
                        else
                        {
                            //	Do we have enough vertices for a normal?
                            if(face.Indices.Count >= 3)
                            {
                                //	Create a normal.
                                Vertex vNormal = face.GetSurfaceNormal(this);
                                vNormal.UnitLength();

                                //	Add it to the normals, setting the index for next time.
                                index.Normal = normals.Add(new Normal(vNormal));

                                gl.Normal(vNormal);
                            }
                        }

                        //	Set the vertex.
                        gl.Vertex(vertices[index.Vertex]);
                    }

                    gl.End();
                }

                //	If the current context is edit vertices, draw the vertices.
                if(currentContext == Context.EditVertices)
                {
                    //	Push all the attributes.
                    gl.PushAttrib(OpenGL.ALL_ATTRIB_BITS);

                    //	Set the colour to red, large points, no lighting.
                    gl.Color(1, 0, 0, 1);
                    gl.PointSize(5);
                    gl.Disable(OpenGL.LIGHTING);

                    //	Draw the control points.
                    for(int point = 0; point < vertices.Count; point++)
                    {
                        //	Name the point, then draw it.
                        gl.PushName((uint)point);

                        gl.Begin(OpenGL.POINTS);
                        gl.Vertex(vertices[point]);
                        gl.End();
                        gl.PopName();
                    }

                    //	Restore the attributes.
                    gl.PopAttrib();
                }

                //	If the current context is edit normals, draw the normals.
                if(currentContext == Context.EditNormals)
                {
                    //	We're going to disable lighting.
                    Attributes.Lighting lighting = new Attributes.Lighting();
                    lighting.Enable = false;
                    lighting.Set(gl);

                    gl.Color(1, 0, 0);
                    gl.Begin(OpenGL.LINES);

                    //	Draw the normals points.
                    foreach(Face face in faces)
                    {
                        foreach(Index index in face.Indices)
                        {
                            if(index.Normal == -1)
                                continue;
                            //	Translate to that vertex.
                            Vertex v = vertices[index.Vertex];
                            gl.PushName((uint)index.Normal);
                            gl.Vertex(v);
                            gl.Vertex(v + normals[index.Normal]);
//.........这里部分代码省略.........
开发者ID:nromik,项目名称:sharpgl,代码行数:101,代码来源:Polygon.cs

示例2: Draw

		/// <summary>
		/// Use this to draw the vertex grid.
		/// </summary>
		/// <param name="gl">OpenGL object.</param>
		/// <param name="points">Draw each individual vertex (with selection names).</param>
		/// <param name="lines">Draw the lines connecting the points.</param>
		public virtual void Draw(OpenGL gl, bool points, bool lines)
		{
			//	Save the attributes.
            gl.PushAttrib(OpenGL.GL_ALL_ATTRIB_BITS);
            gl.Disable(OpenGL.GL_LIGHTING);
			gl.Color(1, 0, 0, 1);

			if(points)
			{
                int name = 0;

				gl.PointSize(5);

				//	Add a new name (the vertex name).
				gl.PushName(0);

				foreach(Vertex v in vertices)
				{
					//	Set the name, draw the vertex.
					gl.LoadName((uint)name++);
					//todo draw vertex
                    //((IInteractable)v).DrawPick(gl);
				}

				//	Pop the name.
				gl.PopName();
			}

			if(lines)
			{
				//	Draw lines along each row, then along each column.
                gl.DepthFunc(OpenGL.GL_ALWAYS);

				gl.LineWidth(1);
                gl.Disable(OpenGL.GL_LINE_SMOOTH);

				for(int col=0; col < y; col++)
				{
					for(int row=0; row < x; row++)
					{
						//	Create vertex indicies.
						int nTopLeft = (col * x) + row;
						int nBottomLeft = ((col + 1) * x) + row;

                        gl.Begin(OpenGL.GL_LINES);
						if(row < (x-1))
						{
							gl.Vertex(vertices[nTopLeft]);
							gl.Vertex(vertices[nTopLeft + 1]);
						}
						if(col < (y-1))
						{
							gl.Vertex(vertices[nTopLeft]);
							gl.Vertex(vertices[nBottomLeft]);
						}
						gl.End();
					}
				}
                gl.DepthFunc(OpenGL.GL_LESS);
			}

			gl.PopAttrib();
		}
开发者ID:hhool,项目名称:sharpgl,代码行数:69,代码来源:VertexGrid.cs

示例3: Polygon

        void IInteractable.DrawPick(OpenGL gl)
        {
            if(on)
            {
                if(DoPreDraw(gl))
                {

                    Polygon poly = new Polygon();
                    poly.CreateCube();
                    poly.Scale = new Vertex(0.2f, 0.2f, 0.2f);
                    poly.Draw(gl);

                    gl.PushName(0);
                    gl.Vertex(direction);
                    gl.PopName();

                    DoPostDraw(gl);
                }
            }
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:20,代码来源:Light.cs


注:本文中的OpenGL.PopName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。