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


C# OpenGL.End方法代码示例

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


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

示例1: Render

        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public override void Render(OpenGL gl, RenderMode renderMode)
        {
            //	Create the evaluator.
            gl.Map1(OpenGL.GL_MAP1_VERTEX_3,//	Use and produce 3D points.
                0,								//	Low order value of 'u'.
                1,								//	High order value of 'u'.
                3,								//	Size (bytes) of a control point.
                ControlPoints.Width,			//	Order (i.e degree plus one).
                ControlPoints.ToFloatArray());	//	The control points.

            //	Enable the type of evaluator we wish to use.
            gl.Enable(OpenGL.GL_MAP1_VERTEX_3);

            //	Beging drawing a line strip.
            gl.Begin(OpenGL.GL_LINE_STRIP);

            //	Now draw it.
            for (int i = 0; i <= segments; i++)
                gl.EvalCoord1((float)i / segments);

            gl.End();

            //	Draw the control points.
            ControlPoints.Draw(gl, DrawControlPoints, DrawControlGrid);
        }
开发者ID:hhool,项目名称:sharpgl,代码行数:30,代码来源:Evaluator1D.cs

示例2: CreateDisplayList

        /// <summary>
        /// Creates the display list. This function draws the
        /// geometry as well as compiling it.
        /// </summary>
        private void CreateDisplayList(OpenGL gl)
        {
            //  Create the display list. 
            displayList = new DisplayList();

            //  Generate the display list and 
            displayList.Generate(gl);
            displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);

            //  Push attributes, set the color.
            gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
                OpenGL.GL_LINE_BIT);
            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.LineWidth(1.0f);

            //  Draw the grid lines.
            gl.Begin(OpenGL.GL_LINES);
            for (int i = -10; i <= 10; i++)
            {
                float fcol = ((i % 10) == 0) ? 0.3f : 0.15f;
                gl.Color(fcol, fcol, fcol);
                gl.Vertex(i, -10, 0);
                gl.Vertex(i, 10, 0);
                gl.Vertex(-10, i, 0);
                gl.Vertex(10, i, 0);
            }
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            //  End the display list.
            displayList.End(gl);
        }
开发者ID:hhool,项目名称:sharpgl,代码行数:39,代码来源:Grid.cs

示例3: CreateDisplayList

        /// <summary>
        /// Creates the display list. This function draws the
        /// geometry as well as compiling it.
        /// </summary>
        private void CreateDisplayList(OpenGL gl)
        {
            //  Create the display list. 
            displayList = new DisplayList();

            //  Generate the display list and 
            displayList.Generate(gl);
            displayList.New(gl, DisplayList.DisplayListMode.CompileAndExecute);

            //  Push all attributes, disable lighting and depth testing.
            gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
                OpenGL.GL_LINE_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.DepthFunc(OpenGL.GL_ALWAYS);

            //  Set a nice fat line width.
            gl.LineWidth(1.50f);

            //  Draw the axies.
            gl.Begin(OpenGL.GL_LINES);
            gl.Color(1f, 0f, 0f, 1f);
            gl.Vertex(0, 0, 0);
            gl.Vertex(3, 0, 0);
            gl.Color(0f, 1f, 0f, 1f);
            gl.Vertex(0, 0, 0);
            gl.Vertex(0, 3, 0);
            gl.Color(0f, 0f, 1f, 1f);
            gl.Vertex(0, 0, 0);
            gl.Vertex(0, 0, 3);
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            //  End the display list.
            displayList.End(gl);
        }
开发者ID:cvanherk,项目名称:3d-engine,代码行数:42,代码来源:Axies.cs

示例4: Draw

        /// <summary>
        /// This is the function that you must override to draw the line.
        /// The code is commented step by step.
        /// </summary>
        public override void Draw(OpenGL gl)
        {
            //	This is the first function that must be called, DoPreDraw. It basicly
            //	sets up certain settings and organises the stack so that what you draw
            //	now doesn't interfere with what you will draw next.
            DoPreDraw(gl);

            //	This next code saves the current line attributes, then sets the line
            //	attributes for this line.
            lineAttributes.Set(gl);

            //	Begin drawing lines.
            gl.Begin(OpenGL.LINES);

            //	Add the two vertices.
            gl.Vertex(point1);
            gl.Vertex(point2);

            //	End the drawing.
            gl.End();

            //	Restore the previous line settings.
            lineAttributes.Restore(gl);

            //	Finalise the drawing process.
            DoPostDraw(gl);
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:31,代码来源:Line.cs

示例5: Draw

        /// <summary>
        /// Draw the points.
        /// </summary>
        public override void Draw(OpenGL gl)
        {
            if(pointsRaw == null)
                return;

            //	If you want you're custom object to be drawn, then override this function.

            //	The drawing of points is very simple, go through the point array, set
            //	the intensity, draw the point.

            //	This is the first function that must be called, DoPreDraw. It basicly
            //	sets up certain settings and organises the stack so that what you draw
            //	now doesn't interfere with what you will draw next. You actually
            //	only need to draw it it returns true, when it returns false
            //	the object is actually drawn via a display list.
            if(DoPreDraw(gl))
            {
                //	This next code saves the current point attributes, then sets the point
                //	attributes for this set of points, so that the previous attributes
                //	are not lost (we restore them later).
                pointAttributes.Set(gl);

                //	Begin drawing lines.
                gl.Begin(OpenGL.POINTS);

                //	Get the points count.
                int count = pointsRaw.Length / 4;
                for(int i=0, index=0; i < count; i++,index+=4)
                {
                    //	Set the colour.
                    float intensity = pointsRaw[index + 3];
                    gl.Color(intensity, intensity, intensity, intensity);

                    //	Draw the point.
                    gl.Vertex(pointsRaw[index], pointsRaw[index+1], pointsRaw[index+2]);
                }

                //	End the drawing.
                gl.End();

                //	Restore the previous point settings.
                pointAttributes.Restore(gl);

                //	Finalise the drawing process.
                DoPostDraw(gl);
            }
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:50,代码来源:Points.cs

示例6: DrawGrid

        public virtual void DrawGrid(OpenGL gl)
        {
            gl.PushAttrib(OpenGL.LINE_BIT | OpenGL.ENABLE_BIT | OpenGL.COLOR_BUFFER_BIT);

            //  Turn off lighting, set up some nice anti-aliasing for lines.
            gl.Disable(OpenGL.LIGHTING);
            gl.Hint(OpenGL.LINE_SMOOTH_HINT, OpenGL.NICEST);
            gl.Enable(OpenGL.LINE_SMOOTH);
            gl.Enable(OpenGL.BLEND);
            gl.BlendFunc(OpenGL.SRC_ALPHA, OpenGL.ONE_MINUS_SRC_ALPHA);

            //	Create the grid.
            gl.LineWidth(1.5f);

            gl.Begin(OpenGL.LINES);

                for (int i = -10; i <= 10; i++)
                {
                    gl.Color(0.2f, 0.2f, 0.2f, 1f);
                    gl.Vertex(i, 0, -10);
                    gl.Vertex(i, 0, 10);
                    gl.Vertex(-10, 0, i);
                    gl.Vertex(10, 0, i);
                }

            gl.End();

            //  Turn off the depth test for the axies.
            gl.Disable(OpenGL.DEPTH_TEST);
            gl.LineWidth(2.0f);

            //	Create the axies.
            gl.Begin(OpenGL.LINES);

                gl.Color(1f, 0f, 0f, 1f);
                gl.Vertex(0f, 0f, 0f);
                gl.Vertex(3f, 0f, 0f);
                gl.Color(0f, 1f, 0f, 1f);
                gl.Vertex(0f, 0f, 0f);
                gl.Vertex(0f, 3f, 0f);
                gl.Color(0f, 0f, 1f, 1f);
                gl.Vertex(0f, 0f, 0f);
                gl.Vertex(0f, 0f, 3f);

            gl.End();

            gl.PopAttrib();

               //     gl.Flush();
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:50,代码来源:StockDrawing.cs

示例7: DrawCircle

        public virtual void DrawCircle(OpenGL gl)
        {
            //	Start drawing a line.
            gl.Begin(OpenGL.LINE_LOOP);

            //	Make a circle of points.
            for (int i = 0; i < 12; i++)
            {
                double angle = 2 * Math.PI * i / 12;

                //	Draw the point.
                gl.Vertex(Math.Cos(angle), 0, Math.Sin(angle));
            }

            //	End the line drawing.
            gl.End();
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:17,代码来源:StockDrawing.cs

示例8: Create

        /// <summary>
        /// This function creates the internal display lists.
        /// </summary>
        /// <param name="gl">OpenGL object.</param>
        public virtual void Create(OpenGL gl)
        {
            //	Create the arrow.
            arrow.Generate(gl);
            arrow.New(gl, DisplayList.DisplayListMode.Compile);

                //	Draw the 'line' of the arrow.
                gl.Begin(OpenGL.LINES);
                gl.Vertex(0, 0, 0);
                gl.Vertex(0, 0, 1);
                gl.End();

                //	Draw the arrowhead.
                gl.Begin(OpenGL.TRIANGLE_FAN);
                gl.Vertex(0, 0, 1);
                gl.Vertex(0.2f, 0.8f, 0.2f);
                gl.Vertex(0.2f, 0.8f, -0.2f);
                gl.Vertex(-0.2f, 0.8f, -0.2f);
                gl.Vertex(-0.2f, 0.8f, 0.2f);
                gl.End();

            //	End the arrow list.
            arrow.End(gl);

            //	Create the grid.
            grid.Generate(gl);
            grid.New(gl, DisplayList.DisplayListMode.Compile);

                gl.PushAttrib(OpenGL.LIGHTING_BIT);
                gl.Disable(OpenGL.LIGHTING);

                gl.Color(1, 1, 1);

                gl.Begin(OpenGL.LINES);
                for(int i = -10; i <= 10; i++)
                {
                    gl.Vertex(i, 0, -10);
                    gl.Vertex(i, 0, 10);
                    gl.Vertex(-10, 0, i);
                    gl.Vertex(10, 0, i);
                }

                gl.End();

                gl.PopAttrib();

            grid.End(gl);

            //	Create the axies.
            axies.Generate(gl);
            axies.New(gl, DisplayList.DisplayListMode.Compile);

                gl.PushAttrib(OpenGL.ALL_ATTRIB_BITS);
                gl.Disable(OpenGL.LIGHTING);
                gl.Disable(OpenGL.DEPTH_TEST);
                gl.LineWidth(2.0f);

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

                gl.PopAttrib();

            axies.End(gl);

            camera.Generate(gl);
            camera.New(gl, DisplayList.DisplayListMode.Compile);

                Polygon poly = new Polygon();
                poly.CreateCube();
                poly.Scale.Set(.2f ,0.2f, 0.2f);
                poly.Draw(gl);
            //	poly.Dispose();

            camera.End(gl);
        }
开发者ID:nromik,项目名称:sharpgl,代码行数:88,代码来源:StockDrawing.cs

示例9: DoShadowPass

		/// <summary>
		/// This is part of the shadow casting code, it does a shadowpass for the
		/// polygon using the specified light.
		/// </summary>
		/// <param name="gl">The OpenGL object.</param>
		/// <param name="light">The light casting the shadow.</param>
		/// <param name="visibleArray">An array of bools.</param>
		private void DoShadowPass(OpenGL gl, Vertex lightPos, bool[] visibleArray)
		{
            //  Helpful references.
            var faces = ParentPolygon.Faces;
            var vertices = ParentPolygon.Vertices;

			//	Go through each face.
			for(int i = 0; i < faces.Count; i++)
			{
				//	Get a reference to the face.
				Face face = faces[i];
				
				//	Is the face visible...
				if(visibleArray[i])
				{
					//	Go through each edge...
					for(int j = 0; j < face.Indices.Count; j++)
					{
						//	Get the neighbour of this edge.
                        int neighbourIndex = face.NeighbourIndices[j];

						//	If there's no neighbour, or the neighbour ain't visible, it's
						//	an edge...
						if(neighbourIndex == -1 || visibleArray[neighbourIndex] == false )
						{
							//	Get the edge vertices.
							Vertex v1 = vertices[face.Indices[j].Vertex];
							Vertex v2 = vertices[face.Indices[(j+1)%face.Indices.Count].Vertex];
						
							//	Create the two distant vertices.
							Vertex v3 = (v1 - lightPos) * 100;
							Vertex v4 = (v2 - lightPos) * 100;
							
							//	Draw the shadow volume.
                            gl.Begin(OpenGL.GL_TRIANGLE_STRIP);
							gl.Vertex(v1);
							gl.Vertex(v1 + v3);
							gl.Vertex(v2);
							gl.Vertex(v2 + v4);
							gl.End();
						}
					}
				}
			}			
		}
开发者ID:cvanherk,项目名称:3d-engine,代码行数:52,代码来源:Shadow.cs

示例10: Render

        /// <summary>
        /// Render to the provided instance of OpenGL.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        /// <param name="renderMode">The render mode.</param>
        public void Render(OpenGL gl, RenderMode renderMode)
        {
            //  Push attributes, disable lighting.
            gl.PushAttrib(OpenGL.GL_CURRENT_BIT | OpenGL.GL_ENABLE_BIT |
                OpenGL.GL_LINE_BIT | OpenGL.GL_POLYGON_BIT);
            gl.Disable(OpenGL.GL_LIGHTING);
            gl.Disable(OpenGL.GL_TEXTURE_2D);
            gl.LineWidth(1.0f);
            gl.Color(1f, 0.2f, 0.2f, 0.6f);
            gl.PolygonMode(OpenGL.GL_FRONT_AND_BACK, 
                renderMode == RenderMode.HitTest ? (uint)PolygonMode.Filled : (uint)PolygonMode.Lines);
            
            gl.Begin(OpenGL.GL_QUADS);		// Draw The Cube Using quads
            gl.Vertex(hhl);	// Top Right Of The Quad (Top)
            gl.Vertex(lhl);	// Top Left Of The Quad (Top)
            gl.Vertex(lhh);	// Bottom Left Of The Quad (Top)
            gl.Vertex(hhh);	// Bottom Right Of The Quad (Top)
            gl.Vertex(hlh);	// Top Right Of The Quad (Bottom)
            gl.Vertex(llh);	// Top Left Of The Quad (Bottom)
            gl.Vertex(lll);	// Bottom Left Of The Quad (Bottom)
            gl.Vertex(hll);	// Bottom Right Of The Quad (Bottom)
            gl.Vertex(hhh);	// Top Right Of The Quad (Front)
            gl.Vertex(lhh);	// Top Left Of The Quad (Front)
            gl.Vertex(llh);	// Bottom Left Of The Quad (Front)
            gl.Vertex(hlh);	// Bottom Right Of The Quad (Front)
            gl.Vertex(hll);	// Top Right Of The Quad (Back)
            gl.Vertex(lll);	// Top Left Of The Quad (Back)
            gl.Vertex(lhl);	// Bottom Left Of The Quad (Back)
            gl.Vertex(hhl);	// Bottom Right Of The Quad (Back)
            gl.Vertex(lhh);	// Top Right Of The Quad (Left)
            gl.Vertex(lhl);	// Top Left Of The Quad (Left)
            gl.Vertex(lll);	// Bottom Left Of The Quad (Left)
            gl.Vertex(llh);	// Bottom Right Of The Quad (Left)
            gl.Vertex(hhl);	// Top Right Of The Quad (Right)
            gl.Vertex(hhh);	// Top Left Of The Quad (Right)
            gl.Vertex(hlh);	// Bottom Left Of The Quad (Right)
            gl.Vertex(hll);	// Bottom Right Of The Quad (Right)
            gl.End();			// End Drawing The Cube

            //  Pop attributes.
            gl.PopAttrib();
        }
开发者ID:cvanherk,项目名称:3d-engine,代码行数:47,代码来源:BoundingVolume.cs

示例11: SampleRendering

        private void SampleRendering(OpenGL gl, float rX, float rY, float rZ)
        {
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
            gl.LoadIdentity();					// Reset The View
            gl.Translate(-1.5f, 0.0f, -6.0f);				// Move Left And Into The Screen

            gl.Rotate(rtri, rX, rY, rZ);				// Rotate The Pyramid On It's Y Axis

            gl.Begin(OpenGL.GL_TRIANGLES);					// Start Drawing The Pyramid

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Front)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Left Of Triangle (Front)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Right Of Triangle (Front)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Right)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Left Of Triangle (Right)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Right Of Triangle (Right)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Back)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Left Of Triangle (Back)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Right Of Triangle (Back)

            gl.Color(1.0f, 0.0f, 0.0f);			// Red
            gl.Vertex(0.0f, 1.0f, 0.0f);			// Top Of Triangle (Left)
            gl.Color(0.0f, 0.0f, 1.0f);			// Blue
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Left Of Triangle (Left)
            gl.Color(0.0f, 1.0f, 0.0f);			// Green
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Right Of Triangle (Left)
            gl.End();						// Done Drawing The Pyramid

            gl.LoadIdentity();
            gl.Translate(1.5f, 0.0f, -7.0f);				// Move Right And Into The Screen

            gl.Rotate(rquad, rX, rY, rZ);			// Rotate The Cube On X, Y & Z

            gl.Begin(OpenGL.GL_QUADS);					// Start Drawing The Cube

            gl.Color(0.0f, 1.0f, 0.0f);			// Set The Color To Green
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Top)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Top)
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Bottom Left Of The Quad (Top)
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Bottom Right Of The Quad (Top)

            gl.Color(1.0f, 0.5f, 0.0f);			// Set The Color To Orange
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Top Right Of The Quad (Bottom)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Top Left Of The Quad (Bottom)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Bottom)
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Bottom)

            gl.Color(1.0f, 0.0f, 0.0f);			// Set The Color To Red
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Front)
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Front)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Bottom Left Of The Quad (Front)
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Bottom Right Of The Quad (Front)

            gl.Color(1.0f, 1.0f, 0.0f);			// Set The Color To Yellow
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Back)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Back)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Back)
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Back)

            gl.Color(0.0f, 0.0f, 1.0f);			// Set The Color To Blue
            gl.Vertex(-1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Left)
            gl.Vertex(-1.0f, 1.0f, -1.0f);			// Top Left Of The Quad (Left)
            gl.Vertex(-1.0f, -1.0f, -1.0f);			// Bottom Left Of The Quad (Left)
            gl.Vertex(-1.0f, -1.0f, 1.0f);			// Bottom Right Of The Quad (Left)

            gl.Color(1.0f, 0.0f, 1.0f);			// Set The Color To Violet
            gl.Vertex(1.0f, 1.0f, -1.0f);			// Top Right Of The Quad (Right)
            gl.Vertex(1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Right)
            gl.Vertex(1.0f, -1.0f, 1.0f);			// Bottom Left Of The Quad (Right)
            gl.Vertex(1.0f, -1.0f, -1.0f);			// Bottom Right Of The Quad (Right)
            gl.End();						// Done Drawing The Q

            gl.Flush();

            rtri += 1.0f;// 0.2f;						// Increase The Rotation Variable For The Triangle
            rquad -= 1.0f;// 0.15f;						// Decrease The Rotation Variable For The Quad
        }
开发者ID:chantsunman,项目名称:sharpgl,代码行数:88,代码来源:FormRenderContextsSample.cs

示例12: 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

示例13: 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

示例14: Draw

        public override void Draw(OpenGL gl)
        {
            gl.Color(color.R, color.G, color.B, life);

            gl.Begin(OpenGL.TRIANGLE_STRIP);
            gl.Vertex(position.X+0.1f, position.Y+0.1f, position.Z+0.1f);
            gl.Vertex(position.X-0.1f, position.Y+0.1f, position.Z);
            gl.Vertex(position.X+0.1f, position.Y-0.1f, position.Z);
            gl.Vertex(position.X-0.1f, position.Y-0.1f, position.Z);

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

示例15: RenderImmediateMode

        /// <summary>
        /// Renders the scene in immediate mode.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        public void RenderImmediateMode(OpenGL gl)
        {
            //  Setup the modelview matrix.
            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.LoadIdentity();
            gl.MultMatrix(modelviewMatrix.to_array());

            //  Push the polygon attributes and set line mode.
            gl.PushAttrib(OpenGL.GL_POLYGON_BIT);
            gl.PolygonMode(FaceMode.FrontAndBack, PolygonMode.Lines);

            //  Render the trefoil.
            var vertices = trefoilKnot.Vertices;
            gl.Begin(BeginMode.Triangles);
            foreach (var index in trefoilKnot.Indices)
                gl.Vertex(vertices[index].x, vertices[index].y, vertices[index].z);
            gl.End();

            //  Pop the attributes, restoring all polygon state.
            gl.PopAttrib();
        }
开发者ID:chantsunman,项目名称:sharpgl,代码行数:25,代码来源:Scene.cs


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