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


C# OpenGL.DrawArrays方法代码示例

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


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

示例1: InitShader

        void IRenderable.Render(OpenGL gl, RenderMode renderMode)
        {
            if (positionBuffer != null && colorBuffer != null && radiusBuffer != null)
            {
                if (this.shaderProgram == null)
                {
                    this.shaderProgram = InitShader(gl, renderMode);
                }
                if (this.vertexArrayObject == null)
                {
                    CreateVertexArrayObject(gl, renderMode);
                }

                BeforeRendering(gl, renderMode);

                if (this.RenderGrid && this.vertexArrayObject != null)
                {
                    gl.Enable(OpenGL.GL_BLEND);
                    gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);

                    gl.BindVertexArray(this.vertexArrayObject[0]);
                    gl.DrawArrays(OpenGL.GL_POINTS, 0, count);
                    gl.BindVertexArray(0);

                    gl.Disable(OpenGL.GL_BLEND);
                }

                AfterRendering(gl, renderMode);
            }
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:30,代码来源:PointGrid.cs

示例2: RenderVertices_VertexArray

 private void RenderVertices_VertexArray(OpenGL gl)
 {
     gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY);
     gl.VertexPointer(3, 0, vertexArrayValues);
     gl.DrawArrays(OpenGL.GL_POINTS, 0, 2);//vertices.Length);
     gl.DisableClientState(OpenGL.GL_VERTEX_ARRAY);
 }
开发者ID:hhool,项目名称:sharpgl,代码行数:7,代码来源:MainWindow.xaml.cs

示例3: Draw

        /// <summary>
        /// Draws the scene.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        public void Draw(OpenGL gl)
        {
            //  Clear the scene.
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT);

            //  Bind the shader, set the matrices.
            shaderProgram.Bind(gl);
            shaderProgram.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, "modelMatrix", modelMatrix.to_array());

            //  Bind the out vertex array.
            vertexBufferArray.Bind(gl);

            //  Draw the square.
            gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, 6); 

            //  Unbind our vertex array and shader.
            vertexBufferArray.Unbind(gl);
            shaderProgram.Unbind(gl);
        }
开发者ID:hhool,项目名称:sharpgl,代码行数:25,代码来源:Scene.cs

示例4: Draw

 public override void Draw(OpenGL gl)
 {
   this.vertexBufferArray.Bind(gl);
   gl.DrawArrays(OpenGL.GL_LINES, 0, this.lineCount*2);
   this.vertexBufferArray.Unbind(gl);
 }
开发者ID:karlbloedorn,项目名称:InfoMap,代码行数:6,代码来源:ShapeData.cs

示例5: RenderRetainedMode

        /// <summary>
        /// Renders the scene in retained mode.
        /// </summary>
        /// <param name="gl">The OpenGL instance.</param>
        public void RenderRetainedMode(OpenGL gl)
        {
            //  Use the shader program.
            shaderPerPixel.Bind(gl);

            //  Set the light position.
            shaderPerPixel.SetUniform3(gl, "LightPosition", 0.25f, 0.25f, 10f);

            //  Set the matrices.
            shaderPerPixel.SetUniformMatrix4(gl, "Projection", projectionMatrix.to_array());
            shaderPerPixel.SetUniformMatrix4(gl, "Modelview", modelviewMatrix.to_array());
            shaderPerPixel.SetUniformMatrix3(gl, "NormalMatrix", normalMatrix.to_array());

            //  Go through each mesh and render the vertex buffer array.
            foreach(var mesh in meshes)
            {
                //  Set the variables for the shader program.
                shaderPerPixel.SetUniform3(gl, "DiffuseMaterial", mesh.material.Diffuse.r, mesh.material.Diffuse.g, mesh.material.Diffuse.b);
                shaderPerPixel.SetUniform3(gl, "AmbientMaterial", mesh.material.Ambient.r, mesh.material.Ambient.g, mesh.material.Ambient.b);
                shaderPerPixel.SetUniform3(gl, "SpecularMaterial", mesh.material.Specular.r, mesh.material.Specular.g, mesh.material.Specular.b);
                shaderPerPixel.SetUniform1(gl, "Shininess", mesh.material.Shininess);

                var vertexBufferArray = meshVertexBufferArrays[mesh];
                vertexBufferArray.Bind(gl);

                //  IMPORTANT: This is interesting. If you use OpenGL 2.1, you can use quads. If you move to 3.0 or onwards,
                //  you can only draw the triangle types - cause 3.0 onwards deprecates other types.
                //  see: http://stackoverflow.com/questions/8041361/simple-opengl-clarification
                //  this shows that the OpenGL mode selection works - if I choose 2.1 I can draw quads, otherwise I can't.
                //  There's a good article on tesselating quads to triangles here:
                //  http://prideout.net/blog/?p=49
                //  This should be a sample!

                uint mode = OpenGL.GL_TRIANGLES;
                if (mesh.indicesPerFace == 4)
                    mode = OpenGL.GL_QUADS;
                else if (mesh.indicesPerFace > 4)
                    mode = OpenGL.GL_POLYGON;

                gl.DrawArrays(mode, 0, mesh.vertices.Length);
            }

            //  Unbind the shader.
            shaderPerPixel.Unbind(gl);
        }
开发者ID:BloofX,项目名称:sharpgl,代码行数:49,代码来源:Scene.cs

示例6: runGlThread

        private void runGlThread(object args)
        {
            var inputs = (Tuple<CancellationToken>) args;

            var cancelToken = inputs.Item1;
            var gl = new OpenGL();

            int localRenderWidth = 1;
            int localRenderHeight = 1;
            if (!createRenderContext(gl, localRenderWidth, localRenderHeight))
            {
            //TODO better error handling here
            Console.WriteLine("*** Unable to create OpenGL Render Context");
            return;
            }

            uint activeVaoHandle;
            uint activeGlProgramHandle;
            initGLObjects(gl, out activeVaoHandle, out activeGlProgramHandle);

            ActiveProgramValues localActiveProgramValues = null;
            while (!cancelToken.IsCancellationRequested)
            {
            bool resizeRenderContext;
            lock (this)
            {
                if (!ReferenceEquals(localActiveProgramValues, activeProgramValues))
                {
                    localActiveProgramValues = activeProgramValues;
                    if (localActiveProgramValues.Valid)
                    {
                        linkProgram(gl, localActiveProgramValues, activeGlProgramHandle);
                    } else
                    {
                        // Leave the old program running. This prevents the user from seeing
                        // a black screen while they are in the process of modifying a shader.
                    }
                }

                resizeRenderContext = localRenderWidth != renderWidth || localRenderHeight != renderHeight;
                localRenderWidth = renderWidth;
                localRenderHeight = renderHeight;
            }

            if (resizeRenderContext)
            {
                localActiveProgramValues = null;
                deleteGlObjects(gl, activeVaoHandle, activeGlProgramHandle);
                if (!createRenderContext(gl, localRenderWidth, localRenderHeight))
                {
            //TODO better error handling here
                    Console.WriteLine("*** Unable to resize OpenGL Render Context");
                    return;
                }
                initGLObjects(gl, out activeVaoHandle, out activeGlProgramHandle);
            }

            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT);
            gl.BindVertexArray(activeVaoHandle);
            gl.UseProgram(activeGlProgramHandle);
            gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, 3);

            // do some other stuff while the image is rendering, to give it a chance to finish
            ShaderCompiler.ValidateShaders(gl);

            var provider = gl.RenderContextProvider as FBORenderContextProvider;
            Debug.Assert(provider != null, "Render context provider is not an FBO renderer");
            //TODO this call to blit will probably block. Find a better way to copy the image to CPU memory.
            gl.Blit(IntPtr.Zero);
            var hBitmap = provider.InternalDIBSection.HBitmap;

            if (hBitmap != IntPtr.Zero)
            {
                var bitmap = GetFormattedBitmapSource(hBitmap);
                // the bitmap needs to be frozen in order to share it between threads
                bitmap.Freeze();
                ImageRendered(bitmap);
            }
            }

            deleteGlObjects(gl, activeVaoHandle, activeGlProgramHandle);
        }
开发者ID:dboone,项目名称:shader-baker,代码行数:82,代码来源:GlContextManager.cs

示例7: CreateAndPlotData

        void CreateAndPlotData(OpenGL GL, float[] raw_data, int figureID)
        {
            if (_dataTail[figureID] + raw_data.Length >= C_SAMPLES_PER_FRAME)
            {
                _dataTail[figureID] = 0; // Clear the buffer
            }
            AddVerticesToFigure(figureID, raw_data, _dataTail[figureID]);

            //  Create the vertex array object.
            vertexBufferArray = new VertexBufferArray();
            vertexBufferArray.Create(GL);
            vertexBufferArray.Bind(GL);

            //  Create a vertex buffer for the vertex data.
            var vertexDataBuffer = new VertexBuffer();
            vertexDataBuffer.Create(GL);
            vertexDataBuffer.Bind(GL);
            vertexDataBuffer.SetData(GL, attribute_vpos, _data[figureID], false, 3);

            //  Now do the same for the colour data.
            var colourDataBuffer = new VertexBuffer();
            colourDataBuffer.Create(GL);
            colourDataBuffer.Bind(GL);
            colourDataBuffer.SetData(GL, attribute_vcol, _dataColor[figureID], false, 3);

            //  Unbind the vertex array, we've finished specifying data for it.
            vertexBufferArray.Unbind(GL);

            //  Bind the shader, set the matrices.
            shaderProgram.Bind(GL);
            //shaderProgram.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            //shaderProgram.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shaderProgram.SetUniformMatrix4(GL, "modelMatrix", mviewdata.to_array());

            //  Bind the out vertex array.
            vertexBufferArray.Bind(GL);

            //  Draw the square.
            GL.DrawArrays(OpenGL.GL_LINE_STRIP, 0, _dataTail[figureID]);

            //  Unbind our vertex array and shader.
            vertexBufferArray.Unbind(GL);
            shaderProgram.Unbind(GL);
        }
开发者ID:carriercomm,项目名称:WebSiteDownloads,代码行数:44,代码来源:MainWindow.xaml.cs

示例8: CreateAndDrawGrid

        void CreateAndDrawGrid(OpenGL GL)
        {
            // Debug.WriteLine("Painting Begins..");

            // Create vertices for 4 lines that will split the figure into 3 equal sections
            xgrid = new vec3[(C_NUM_Y_DIV + 1) * 2];
            for (int i = 0; i < (C_NUM_Y_DIV + 1) * 2; i = i + 2)
            {
                xgrid[i].x = -1f; xgrid[i + 1].x = 1f;
                xgrid[i].y = C_X_MARGIN_MIN + C_Y_STEP * i / 2; xgrid[i + 1].y = C_X_MARGIN_MIN + C_Y_STEP * i / 2;
                xgrid[i].z = 0f; xgrid[i + 1].z = 0f;
            }

            coldata = new vec3[] {
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White),
                GL.Color(DR.Color.White)
            };

            mviewdata = new mat4(1.0f);

            // --------------- Implementation WITH VERTEX ARRAY OBJECTS --------------------
            ////  Create the vertex array object.
            vertexBufferArray = new VertexBufferArray();
            vertexBufferArray.Create(GL);
            vertexBufferArray.Bind(GL);

            //  Create a vertex buffer for the vertex data.
            var vertexDataBuffer = new VertexBuffer();
            vertexDataBuffer.Create(GL);
            vertexDataBuffer.Bind(GL);
            vertexDataBuffer.SetData(GL, attribute_vpos, xgrid, false, 3);

            //  Now do the same for the colour data.
            var colourDataBuffer = new VertexBuffer();
            colourDataBuffer.Create(GL);
            colourDataBuffer.Bind(GL);
            colourDataBuffer.SetData(GL, attribute_vcol, coldata, false, 3);

            //  Unbind the vertex array, we've finished specifying data for it.
            vertexBufferArray.Unbind(GL);

            //  Bind the shader, set the matrices.
            shaderProgram.Bind(GL);
            //shaderProgram.SetUniformMatrix4(gl, "projectionMatrix", projectionMatrix.to_array());
            //shaderProgram.SetUniformMatrix4(gl, "viewMatrix", viewMatrix.to_array());
            shaderProgram.SetUniformMatrix4(GL, "modelview", mviewdata.to_array());

            //  Bind the out vertex array.
            vertexBufferArray.Bind(GL);

            GL.DrawArrays(OpenGL.GL_LINES, 0, 8);

            //  Unbind our vertex array and shader.
            vertexBufferArray.Unbind(GL);
            shaderProgram.Unbind(GL);

            // --------------- Implementation WITH VERTEX ARRAY OBJECTS END --------------------
        }
开发者ID:carriercomm,项目名称:WebSiteDownloads,代码行数:72,代码来源:MainWindow.xaml.cs

示例9: Draw

 public override void Draw(OpenGL gl)
 {
   this.vertexBufferArray.Bind(gl);
   gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.cells.Count * 6); //cells.Count * 4);
   this.vertexBufferArray.Unbind(gl);
 }
开发者ID:karlbloedorn,项目名称:InfoMap,代码行数:6,代码来源:RadarScan.cs

示例10: DoRenderMatrix

        /// <summary>
        /// 渲染基质
        /// </summary>
        /// <param name="gl"></param>
        /// <param name="renderMode"></param>
        private void DoRenderMatrix(OpenGL gl, RenderMode renderMode)
        {
            if (this.positionBuffer == null || this.colorBuffer == null) { return; }

            if (this.RenderGrid && this.matrixVertexArrayObject != null)
            {
                shaderProgram.SetUniform1(gl, "renderingWireframe", 0.0f);
                shaderProgram.SetUniform1(gl, "opacity", this.Opacity);

                gl.Enable(OpenGL.GL_POLYGON_OFFSET_FILL);
                gl.PolygonOffset(1.0f, 1.0f);

                gl.Enable(OpenGL.GL_BLEND);
                gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);

                gl.BindVertexArray(matrixVertexArrayObject[0]);

                switch (this.MatrixType)
                {
                    case MatrixFormat.Triangle:
                        gl.DrawArrays(this.matrixRenderMode, 0, this.MatrixVertexOrIndexCount);
                        break;
                    case MatrixFormat.Tetrahedron:
                        gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
                        gl.PrimitiveRestartIndex(uint.MaxValue);

                        gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.matrixIndexBuffer[0]);
                        gl.DrawElements(this.matrixRenderMode, this.MatrixVertexOrIndexCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
                        gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
                        break;
                    case MatrixFormat.TriangularPrism:
                        // 先渲染三棱柱的上下三角形
                        gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.MatrixVertexOrIndexCount);
                        // 再渲染三棱柱的三个侧面
                        gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
                        gl.PrimitiveRestartIndex(uint.MaxValue);
                        gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.matrixIndexBuffer[0]);
                        gl.DrawElements(this.matrixRenderMode, this.MatrixVertexOrIndexCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
                        gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
                        break;
                    default:
                        break;
                }
                gl.BindVertexArray(0);
                gl.Disable(OpenGL.GL_BLEND);

                gl.Disable(OpenGL.GL_POLYGON_OFFSET_FILL);
            }

            if (this.RenderGridWireframe && this.matrixVertexArrayObject != null)
            {
                shaderProgram.SetUniform1(gl, "renderingWireframe", 1.0f);
                shaderProgram.SetUniform1(gl, "opacity", this.Opacity);
                gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Lines);

                gl.Enable(OpenGL.GL_BLEND);
                gl.BlendFunc(SharpGL.Enumerations.BlendingSourceFactor.SourceAlpha, SharpGL.Enumerations.BlendingDestinationFactor.OneMinusSourceAlpha);

                gl.BindVertexArray(matrixVertexArrayObject[0]);
                switch (this.MatrixType)
                {
                    case MatrixFormat.Triangle:
                        gl.DrawArrays(this.matrixRenderMode, 0, this.MatrixVertexOrIndexCount);
                        break;
                    case MatrixFormat.Tetrahedron:
                        gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
                        gl.PrimitiveRestartIndex(uint.MaxValue);
                        gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.matrixIndexBuffer[0]);
                        gl.DrawElements(this.matrixRenderMode, this.MatrixVertexOrIndexCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
                        gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
                        break;
                    case MatrixFormat.TriangularPrism:
                        // 先渲染三棱柱的上下三角形
                        gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.MatrixVertexOrIndexCount / 9 * 6);
                        // 再渲染三棱柱的三个侧面
                        gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
                        gl.PrimitiveRestartIndex(uint.MaxValue);
                        gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, this.matrixIndexBuffer[0]);
                        gl.DrawElements(this.matrixRenderMode, this.MatrixVertexOrIndexCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
                        gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);
                        break;
                    default:
                        break;
                }
                gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Filled);
                gl.BindVertexArray(0);

                gl.Disable(OpenGL.GL_BLEND);
            }
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:95,代码来源:DynamicUnstructureGrid.cs

示例11: DoRenderFraction

        private void DoRenderFraction(OpenGL gl, RenderMode renderMode)
        {
            if (this.fractionPositionBuffer == null || this.fractionUVBuffer == null) { return; }

            if (this.RenderFraction && this.fractionVertexArrayObject != null)
            {
                shaderProgram.SetUniform1(gl, "renderingWireframe", 0.0f);

                gl.Enable(OpenGL.GL_POLYGON_OFFSET_FILL);
                gl.PolygonOffset(1.0f, 1.0f);

                gl.BindVertexArray(fractionVertexArrayObject[0]);

                switch (this.FractionType)
                {
                    case FractureFormat.Line:
                        float[] originalWidth = new float[1];
                        gl.GetFloat(SharpGL.Enumerations.GetTarget.LineWidth, originalWidth);

                        gl.LineWidth(this.FractionLineWidth);
                        gl.DrawArrays(OpenGL.GL_LINES, 0, this.FractionVertexCount);

                        gl.LineWidth(originalWidth[0]);
                        break;
                    case FractureFormat.Triange:
                        gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.FractionVertexCount);
                        break;
                    case FractureFormat.Quad:
                        gl.DrawArrays(OpenGL.GL_QUADS, 0, this.FractionVertexCount);
                        break;
                    default:
                        throw new NotImplementedException();
                    //break;
                }

                gl.BindVertexArray(0);

                gl.Disable(OpenGL.GL_POLYGON_OFFSET_FILL);
            }

            if (this.renderFractionWireframe && this.fractionVertexArrayObject != null)
            {
                shaderProgram.SetUniform1(gl, "renderingWireframe", 1.0f);

                gl.BindVertexArray(fractionVertexArrayObject[0]);
                {
                    gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Lines);

                    switch (this.FractionType)
                    {
                        case FractureFormat.Line:
                            gl.DrawArrays(OpenGL.GL_LINES, 0, this.FractionVertexCount);
                            break;
                        case FractureFormat.Triange:
                            gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, this.FractionVertexCount);
                            break;
                        case FractureFormat.Quad:
                            gl.DrawArrays(OpenGL.GL_QUADS, 0, this.FractionVertexCount);
                            break;
                        default:
                            break;
                    }

                    gl.PolygonMode(SharpGL.Enumerations.FaceMode.FrontAndBack, SharpGL.Enumerations.PolygonMode.Filled);
                }
                gl.BindVertexArray(0);
            }
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:68,代码来源:DynamicUnstructureGrid.cs

示例12: BindAll

        public void BindAll(OpenGL gl)
        {
            //return;
            UseProgram(gl, () =>
            {
                // Update uniforms.
                foreach (var action in ChangedUniforms)
                {
                    action.Invoke(gl);
                }
                ChangedUniforms.Clear();

                foreach (var group in BufferGroups)
                {
                    group.BindVAO(gl);

                    gl.LineWidth(group.LineWidth);

                    // Use draw elements if an index buffer is defined. Else use draw arrays.
                    if (group.IndicesCount > 0)
                        gl.DrawElements(OpenGL.GL_LINES, group.IndicesCount, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);
                    else
                        gl.DrawArrays(OpenGL.GL_LINES, 0, group.VerticesCount);
                }
            });
        }
开发者ID:jochemgeussens,项目名称:sharpgl,代码行数:26,代码来源:LinesProgram.cs

示例13: drawModel

 /// <summary>
 /// Function to draw the model
 /// </summary>
 private void drawModel(OpenGL gl) 
 {
     if(l_vboId != null)
     {
         gl.EnableClientState(OpenGL.GL_VERTEX_ARRAY);
         gl.EnableClientState(OpenGL.GL_COLOR_ARRAY);
         // itering over each list of points
         for(int k = 0; k < l_vboId.Count; k++)
         {
             gl.PushMatrix();
                 //transformations
                 gl.Scale(1.0f / f_scale, 1.0f / f_scale, 1.0f / f_scale);
                 gl.Translate(-v_center.X, -v_center.Y, -v_center.Z);
                 //vertexes
                 gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, l_vboId[k][0]);
                 gl.VertexPointer(3, OpenGL.GL_FLOAT, 0, BUFFER_OFFSET_ZERO);
                 //color
                 gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, l_vboId[k][1]);
                 gl.ColorPointer(3, OpenGL.GL_FLOAT, 0, BUFFER_OFFSET_ZERO);
                 //draw l_sizes[k] points
                 gl.DrawArrays(OpenGL.GL_POINTS, 0, l_sizes[k]);
             gl.PopMatrix();
         }
         gl.DisableClientState(OpenGL.GL_VERTEX_ARRAY);
         gl.DisableClientState(OpenGL.GL_COLOR_ARRAY);
         gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, 0);
     }
 }
开发者ID:esmitt,项目名称:csharpOpenGL,代码行数:31,代码来源:SharpGLForm.cs


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