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


C# OpenGL.GenBuffers方法代碼示例

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


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

示例1: VBO

        public VBO(OpenGL gl, BeginMode beginMode)
        {
            Mode = beginMode;
            _gl = gl;

            var buffers = new uint[1];
            gl.GenBuffers(1, buffers);
            Handle = buffers[0];

            Count = 0;
        }
開發者ID:rho24,項目名稱:OpenCAD,代碼行數:11,代碼來源:VBO.cs

示例2: CreateBufferIds

        public static OGLBufferId[] CreateBufferIds(OpenGL gl, int amount)
        {
            uint[] ids = new uint[amount];
            OGLBufferId[] bIds = new OGLBufferId[amount];
            gl.GenBuffers(amount, ids);

            for (int i = 0; i < amount; i++)
            {
                bIds[i] = new OGLBufferId(ids[i]);
            }

            return bIds;
        }
開發者ID:jochemgeussens,項目名稱:OpenGLHelper-Using-SharpGL,代碼行數:13,代碼來源:OGLBufferId.cs

示例3: CreateVertexNormalBuffer

        public uint CreateVertexNormalBuffer(OpenGL gl)
        {
            Vertex[] verts = new Vertex[VertexCount * 2];
            int count = 0;

            float ds = 1.0f / Slices;
            float dt = 1.0f / Stacks;

            // The upper bounds in these loops are tweaked to reduce the
            // chance of precision error causing an incorrect # of iterations.

            for (float s = 0; s < 1 - ds / 2; s += ds)
            {
                for (float t = 0; t < 1 - dt / 2; t += dt)
                {
                    const float E = 0.01f;
                    Vertex p = EvaluateTrefoil(s, t);
                    Vertex u = EvaluateTrefoil(s + E, t) - p;
                    Vertex v = EvaluateTrefoil(s, t + E) - p;
                    Vertex n = u.VectorProduct(v);
                    n.Normalize();
                    verts[count++] = p;
                    verts[count++] = n;
                }
            }
            
            //  Pin the data.
            GCHandle vertsHandle = GCHandle.Alloc(verts, GCHandleType.Pinned);
            IntPtr vertsPtr = vertsHandle.AddrOfPinnedObject();
            var size = Marshal.SizeOf(typeof(Vertex)) * VertexCount;

            uint[] buffers = new uint[1];
            gl.GenBuffers(1, buffers);
            uint handle = buffers[0];
            gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, handle);
            gl.BufferData(OpenGL.GL_ARRAY_BUFFER, size, vertsPtr, OpenGL.GL_STATIC_DRAW);

            //  Free the data.
            vertsHandle.Free();

            return handle;
        }
開發者ID:mind0n,項目名稱:hive,代碼行數:42,代碼來源:TrefoilKnot.cs

示例4: CreateBufferIds

 private void CreateBufferIds(OpenGL gl)
 {
     var amount = 8;
     uint[] ids = new uint[amount];
     gl.GenBuffers(amount, ids);
     Position = ids[0];
     Normal = ids[1];
     AmbientMaterial = ids[2];
     DiffuseMaterial = ids[3];
     SpecularMaterial = ids[4];
     ShininessValue = ids[5];
     HTColorId = ids[6];
     Ibo = ids[7];
 }
開發者ID:jochemgeussens,項目名稱:sharpgl,代碼行數:14,代碼來源:NMHTBufferGroup.cs

示例5: CreateIndexBuffer

        private uint CreateIndexBuffer(OpenGL gl)
        {
            ushort[] inds = new ushort[IndexCount];
            int count = 0;

            ushort n = 0;
            for (ushort i = 0; i < Slices; i++)
            {
                for (ushort j = 0; j < Stacks; j++)
                {
                    inds[count++] = (ushort)(n + j);
                    inds[count++] = (ushort)(n + (j + 1) % Stacks);
                    inds[count++] = (ushort)((n + j + Stacks) % VertexCount);

                    inds[count++] = (ushort)((n + j + Stacks) % VertexCount);
                    inds[count++] = (ushort)((n + (j + 1) % Stacks) % VertexCount);
                    inds[count++] = (ushort)((n + (j + 1) % Stacks + Stacks) % VertexCount);
                }

                n += (ushort)Stacks;
            }
            
            //  Pin the data.
            GCHandle indsHandle = GCHandle.Alloc(inds, GCHandleType.Pinned);
            IntPtr indsPtr = indsHandle.AddrOfPinnedObject();
            var size = Marshal.SizeOf(typeof(ushort)) * VertexCount;

            uint[] buffers = new uint[1];
            gl.GenBuffers(1, buffers);
            uint handle = buffers[0];
            gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, handle);
            gl.BufferData(OpenGL.GL_ELEMENT_ARRAY_BUFFER, (int)size, indsPtr, OpenGL.GL_STATIC_DRAW);

            //  Free the data.
            indsHandle.Free();

            return handle;
        }
開發者ID:RFExplorer,項目名稱:rfexplorer-1,代碼行數:38,代碼來源:TrefoilKnot.cs

示例6: CreateBufferIds

 private void CreateBufferIds(OpenGL gl)
 {
     var amount = 3;
     uint[] ids = new uint[amount];
     gl.GenBuffers(amount, ids);
     Position = ids[0];
     ColorValue = ids[1];
     Ibo = ids[2];
 }
開發者ID:jochemgeussens,項目名稱:sharpgl,代碼行數:9,代碼來源:LinesBufferGroup.cs

示例7: VBO

 public VBO(OpenGL gl)
 {
     _gl = gl;
     _gl.GenBuffers(1, _handle);
 }
開發者ID:veggielane,項目名稱:OpenCAD,代碼行數:5,代碼來源:VBO.cs


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