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


C# OpenGL.LoadName方法代碼示例

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


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

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

示例2: RenderForHitTest

        public override void RenderForHitTest(OpenGL gl, Dictionary<uint, Node> hitMap, ref uint currentName)
        {
            if (!Visible)
                return;

            polygon.PushObjectSpace(gl);
            if (bone != null)
            {
                parentTranslation(gl, bone);
                rotate(gl, bone);
            }

            gl.LoadName(currentName);
            hitMap[currentName] = this;

            polygon.Render(gl, SharpGL.SceneGraph.Core.RenderMode.HitTest);

            currentName++;

            // Render children
            // (there's never going to be any, but this is just for consistency)
            foreach (Node node in children) node.RenderForHitTest(gl, hitMap, ref currentName);

            polygon.PopObjectSpace(gl);
        }
開發者ID:chances,項目名稱:Animatum,代碼行數:25,代碼來源:Mesh.cs

示例3: RenderForHitTest

        public override void RenderForHitTest(OpenGL gl, Dictionary<uint, Node> hitMap, ref uint currentName)
        {
            if (!Visible)
                return;

            gl.PushMatrix();
            gl.Translate(TransformedPosition.X, TransformedPosition.Y,
                TransformedPosition.Z);

            gl.LoadName(currentName);
            hitMap[currentName] = this;

            sphere.Render(gl);

            currentName++;

            sphere.PopObjectSpace(gl);

            // Render children
            foreach (Bone bone in children)
            {
                bone.RenderForHitTest(gl, hitMap, ref currentName);
            }
        }
開發者ID:chances,項目名稱:Animatum,代碼行數:24,代碼來源:Bone.cs


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