當前位置: 首頁>>代碼示例>>C#>>正文


C# OpenGL.DepthFunc方法代碼示例

本文整理匯總了C#中SharpGL.OpenGL.DepthFunc方法的典型用法代碼示例。如果您正苦於以下問題:C# OpenGL.DepthFunc方法的具體用法?C# OpenGL.DepthFunc怎麽用?C# OpenGL.DepthFunc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SharpGL.OpenGL的用法示例。


在下文中一共展示了OpenGL.DepthFunc方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateDisplayList

        private void CreateDisplayList(OpenGL gl)
        {
            displayList = new DisplayList();

            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 line width.
            gl.LineWidth(lineWidth);

            //Draw the line.
            gl.Begin(OpenGL.GL_LINES);
            gl.Color(Convert.ColorToGLColor(c1));
            gl.Vertex(v1.X, v1.Y, v1.Z);
            gl.Color(Convert.ColorToGLColor(c2));
            gl.Vertex(v2.X, v2.Y, v2.Z);
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            displayList.End(gl);
        }
開發者ID:chances,項目名稱:Animatum,代碼行數:30,代碼來源:Line.cs

示例2: CreateDisplayList

        private void CreateDisplayList(OpenGL gl)
        {
            displayList = new DisplayList();

            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 line width.
            gl.LineWidth(lineWidth);

            //Draw the line.
            gl.Begin(OpenGL.GL_LINES);
            for (float i = (size * -1); i < size; i+=0.4f)
            {
                float add = 0.2f;
                if (i > 0) add = 0.4f;
                if (i < 0 && i > -0.2f) add = 0.4f;
                gl.Color(1f, 0f, 0f, 1f);
                gl.Vertex(i, 0, 0);
                gl.Vertex(i + add, 0, 0);
                gl.Color(0f, 1f, 0f, 1f);
                gl.Vertex(0, i, 0);
                gl.Vertex(0, i + add, 0);
                gl.Color(0f, 0f, 1f, 1f);
                gl.Vertex(0, 0, i);
                gl.Vertex(0, 0, i + add);
            }
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            displayList.End(gl);
        }
開發者ID:chances,項目名稱:Animatum,代碼行數:41,代碼來源:Axies.cs

示例3: CreateDisplayList

        private void CreateDisplayList(OpenGL gl)
        {
            displayList = new DisplayList();

            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 line width.
            gl.LineWidth(lineWidth);

            //Draw the line.
            gl.Begin(OpenGL.GL_LINES);
            for (int i = (size * -1); i <= size; i++)
            {
                if (i != 0)
                {
                    if ((i % 4) == 0)
                        gl.Color(Convert.ColorToGLColor(darkColor));
                    else
                        gl.Color(Convert.ColorToGLColor(lightColor));
                    gl.Vertex(i, (size * -1), 0);
                    gl.Vertex(i, size, 0);
                    gl.Vertex((size * -1), i, 0);
                    gl.Vertex(size, i, 0);
                }
            }
            gl.End();

            //  Restore attributes.
            gl.PopAttrib();

            displayList.End(gl);
        }
開發者ID:chances,項目名稱:Animatum,代碼行數:40,代碼來源:Grid.cs

示例4: Initialize

        public void Initialize(OpenGL gl)
        {
            this.gl = gl;

            gl.Enable(OpenGL.GL_DEPTH_TEST);
            gl.DepthFunc(DepthFunction.LessThanOrEqual);
            gl.ClearDepth(1.0);

            gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);

            gl.Hint(HintTarget.PerspectiveCorrection, HintMode.Nicest);
            gl.Hint(HintTarget.LineSmooth,            HintMode.Nicest);
            gl.Hint(HintTarget.PointSmooth,           HintMode.Nicest);
            gl.Hint(HintTarget.PolygonSmooth,         HintMode.Nicest);

            gl.Enable(OpenGL.GL_SMOOTH);
            gl.Enable(OpenGL.GL_LINE_SMOOTH);
            gl.Enable(OpenGL.GL_POINT_SMOOTH);
            gl.Enable(OpenGL.GL_MULTISAMPLE);

            gl.MinSampleShading(4.0f);
        }
開發者ID:jtdubs,項目名稱:VoxelLand,代碼行數:22,代碼來源:Renderer.cs

示例5: 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.ALL_ATTRIB_BITS);
            gl.Disable(OpenGL.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++);
                    ((IInteractable)v).DrawPick(gl);
                }

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

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

                gl.LineWidth(1);
                gl.Disable(OpenGL.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.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.LESS);
            }

            gl.PopAttrib();
        }
開發者ID:nromik,項目名稱:sharpgl,代碼行數:68,代碼來源:SimpleTypes.cs

示例6: foreach

        /// <summary>
        /// This is called when a face is interactable, so highlight it.
        /// </summary>
        void IInteractable.DrawPick(OpenGL gl)
        {
            //	Save all the attributes.
            gl.PushAttrib(OpenGL.ALL_ATTRIB_BITS);

            //	Disable lighting, set colour to red etc.
            gl.Disable(OpenGL.LIGHTING);
            gl.DepthFunc(OpenGL.LEQUAL);

            //	Now draw it with a faint red.
            gl.Enable(OpenGL.BLEND);
            gl.BlendFunc(OpenGL.SRC_ALPHA, OpenGL.ONE_MINUS_SRC_ALPHA);
            gl.Color(1, 0, 0, 0.2f);

            //	Draw the face.
            gl.Begin(OpenGL.POLYGON);
            foreach(Index index in indices)
                gl.Vertex(parentpoly.Vertices[index.Vertex]);
            gl.End();

            gl.Disable(OpenGL.BLEND);

            //	Draw the face.
            gl.Begin(OpenGL.LINE_LOOP);
            for(int i = 0; i < indices.Count - 1; i++)
                gl.Vertex(parentpoly.Vertices[indices[i].Vertex]);
            gl.End();

            gl.PopAttrib();
        }
開發者ID:nromik,項目名稱:sharpgl,代碼行數:33,代碼來源:SimpleTypes.cs


注:本文中的SharpGL.OpenGL.DepthFunc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。