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


C# GraphicsContext.SetVertexBuffer方法代码示例

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


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

示例1: render

        public override void render(GraphicsContext context)
        {
            shaderColored.SetUniformValue(0, ref sceneTransform);
            shaderColored.SetUniformValue(1, ref screenMatrix);
            shaderColored.SetUniformValue(2, 1f);

            context.SetShaderProgram(shaderColored);
            context.SetVertexBuffer(0, vertexBuffer);
            context.DrawArrays(DrawMode.TriangleFan, 0, vertexBuffer.VertexCount);
        }
开发者ID:JimmyDeemo,项目名称:openfl-psm,代码行数:10,代码来源:RendererPerformanceBar.cs

示例2: Initialize

 public static void Initialize()
 {
     // Set up the graphics system
     graphics = new GraphicsContext ();
     shader = new ShaderProgram("/Application/shaders/Simple.cgx");
     shader.SetUniformBinding(0, "u_viewMatrix");
     shader.SetUniformBinding(1, "u_projMatrix");
     shader.SetUniformBinding(2, "u_worldMatrix");
     SetUpCamera();
     SetUpVertices();
     graphics.SetVertexBuffer(0, vBuffer);
 }
开发者ID:neoemonk,项目名称:psm,代码行数:12,代码来源:AppMain.cs

示例3: render

        public override void render(GraphicsContext context)
        {
            if (vertexBuffer == null) return;

            program.SetUniformValue(0, ref sceneTransform);
            program.SetUniformValue(1, ref screenMatrix);
            program.SetUniformValue(2, 1f);

            context.SetShaderProgram(program);
            context.SetVertexBuffer(0, vertexBuffer);
            context.SetTexture(0, texture);
            context.DrawArrays(DrawMode.TriangleFan, 0, vertexBuffer.VertexCount);
            context.SetTexture(0, null);
        }
开发者ID:JimmyDeemo,项目名称:openfl-psm,代码行数:14,代码来源:RendererStartup.cs

示例4: Draw

        /// BasicProgram を指定した描画(一番オリジナルに近い形)
        public void Draw( 
                     GraphicsContext graphics, 
                     BasicProgram program
                      )
        {
            List< LocalPart > localPartList = updateLocalPart();

            // パーツを DrawOrder 順にソート
            localPartList.Sort();

            // パーツの描画
            foreach( LocalPart localPart in localPartList ){
            if( localPart.material != null ){
                setPolygonMode( graphics, localPart.material );
                program.SetMaterial( ref localPart.material );
                setLayers( graphics, program, localPart.material );
            }

            program.SetMatrixPalette( localPart.worldCount, ref localPart.matrixPalette );
            program.Update();

            graphics.SetVertexBuffer( 0, localPart.vertexBuffer ) ;
            graphics.DrawArrays( localPart.primitives ) ;
            }
        }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:26,代码来源:BasicModel+(2).cs

示例5: Initialize

        public static void Initialize()
        {
            //  define screen  //
            graphics = new GraphicsContext();
            ImageRect rectScreen = graphics.Screen.Rectangle;
            screenWidth = rectScreen.Width;
            screenHeight = rectScreen.Height;

            //  read image for texture  //
            //texture = new Texture2D("/Application/resources/Player.png", false);
            texture = new Texture2D("/Application/resources/cat.png", false);
            //  compile shader  //
            shaderProgram = new ShaderProgram("/Application/shaders/Sprite.cgx");
            shaderProgram.SetUniformBinding(0, "u_WorldMatrix");

            //  get texture image size  //
            Width = texture.Width;
            Height = texture.Height;

            //  calc vertex coordinates  //
            for(int i = 0; i<sliceNumTotal * 4; i++) {
                colors[i] = 1.0f;
            }
            calcVertices();

            //  texture mapping order  //
            indices = new ushort[sliceNumV-1][];
            for(int iy=0; iy<sliceNumV-1; iy++) {
                int cur_idx = 0;
                int ref_idx = iy * sliceNumH;
                indices[iy] = new ushort[sliceNumDraw];
                for(int ix=0; ix<sliceNumH; ix++) {
                    indices[iy][cur_idx++] = (ushort)ref_idx;
                    ref_idx += sliceNumH;
                    indices[iy][cur_idx++] = (ushort)ref_idx;
                    ref_idx += 1 - sliceNumH;
                }
            }

            //  construct vertex shader  //
            //  vertex_num(total), vertex_num(used with index), vertex_format, texture_format, color_format  //
            vertexBuffer = new VertexBuffer(sliceNumTotal, indexSize, VertexFormat.Float3, VertexFormat.Float2, VertexFormat.Float4);

            //  set {vertex, texture, color}  //
            vertexBuffer.SetVertices(0, vertices);
            vertexBuffer.SetVertices(1, texcoords);
            vertexBuffer.SetVertices(2, colors);

            //  set shader  //
            graphics.SetVertexBuffer(0, vertexBuffer);

            objRelativeWidth  = Width*objRatio/screenWidth;
            objRelativeHeight = Height*objRatio/screenHeight;
            unitScreenMatrix = new Matrix4(
                 objRelativeWidth,	0.0f,  0.0f, 0.0f,
                 0.0f,   -objRelativeHeight,	0.0f, 0.0f,
                 0.0f,   0.0f, 1.0f, 0.0f,
                 -objRelativeWidth/2.0f,  objRelativeHeight/2.0f, 0.0f, 1.0f
            );
        }
开发者ID:glass5er,项目名称:PSS_fisheye,代码行数:60,代码来源:AppMain.cs

示例6: render

        public override void render(GraphicsContext context)
        {
            base.render(context);

            program.SetUniformValue(1, ref screenMatrix);
            program.SetUniformValue(0, ref sceneTransform);

            context.SetShaderProgram(program);
            context.SetVertexBuffer(0, vertexBuffer);

            foreach ( CellData cell in cells ){
                program.SetUniformValue(3, (float) cell.val);
                program.SetUniformValue(2, (float) cell.time);
                pos.X = cell.x * (CELL_SIZE + 5) - CELL_SIZE * .5f;
                pos.Y = cell.y * (CELL_SIZE + 5) - CELL_SIZE * .5f;
                program.SetUniformValue(4, ref pos);
                context.DrawArrays(DrawMode.Triangles, 0, vertexBuffer.VertexCount);
            }
        }
开发者ID:JimmyDeemo,项目名称:openfl-psm,代码行数:19,代码来源:RendererResourceFields.cs

示例7: render

        public override void render(GraphicsContext context)
        {
            if (dirtyBuffer) {
                validateBuffer();
            }
            if (vertexBuffer == null) return;

            program.SetUniformValue(0, ref sceneTransform);
            program.SetUniformValue(1, ref screenMatrix);
            program.SetUniformValue(2, (float) sceneAlpha);

            context.SetShaderProgram(program);
            context.SetVertexBuffer(0, vertexBuffer);
            if (program == shaderUniversal) context.SetTexture(0, texture);

            context.DrawArrays(DrawMode.Triangles, 0, vertexBuffer.VertexCount);

            if (program == shaderUniversal) context.SetTexture(0, null);
        }
开发者ID:JimmyDeemo,项目名称:openfl-psm,代码行数:19,代码来源:RendererUniversal.cs

示例8: DrawCapsule

        /// カプセル描画
        public void DrawCapsule( GraphicsContext graphics, GeometryCapsule trgCap, Camera cam, Rgba color )
        {
            if( debShader == null || trgCap.R <= 0.00001f ){
            return ;
            }

            /// 球体部分
            ///---------------------------------------------
            DrawSphere( graphics, new GeometrySphere( trgCap.StartPos, trgCap.R ), cam, color );
            DrawSphere( graphics, new GeometrySphere( trgCap.EndPos, trgCap.R ), cam, color );

            /// パイプ部分
            ///---------------------------------------------
            setCapsulePipeVertex( trgCap );

            debVb2.SetVertices( 0, debMesh2.Positions );
            debVb2.SetIndices( debMesh2.Indices );

            Matrix4 localMtx;
            if( trgCap.StartPos.X == trgCap.EndPos.X && trgCap.StartPos.Z == trgCap.EndPos.Z ){
            localMtx = Matrix4.LookAt( trgCap.EndPos, trgCap.StartPos, new Vector3(0.0f, 0.0f, 1.0f));
            }
            else{
            localMtx = Matrix4.LookAt( trgCap.EndPos, trgCap.StartPos, new Vector3(0.0f, 1.0f, 0.0f));
            }
            Matrix4 world = localMtx.Inverse() * Matrix4.Scale( new Vector3( trgCap.R, trgCap.R, trgCap.R ) );
            world.M41 = trgCap.StartPos.X;
            world.M42 = trgCap.StartPos.Y;
            world.M43 = trgCap.StartPos.Z;

            Matrix4 worldViewProj = cam.Projection * cam.View * world;

            // uniform value
            debShader.SetUniformValue( debUIdWVP, ref worldViewProj );

            Vector4 a_Color = new Vector4( (color.R / 255.0f), (color.G / 255.0f), (color.B / 255.0f), (color.A / 255.0f) );
            debShader.SetUniformValue( debShader.FindUniform( "IAmbient" ), ref a_Color );

            graphics.SetShaderProgram( debShader );

            graphics.SetVertexBuffer( 0, debVb2 );
            graphics.DrawArrays( debMesh2.Prim, 0, debMesh2.IndexCount );
        }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:44,代码来源:RenderGeometry.cs

示例9: drawMesh

        /// private メソッド
        ///---------------------------------------------------------------------------
        /// 描画
        private void drawMesh( GraphicsContext graphics, Camera cam, Rgba color )
        {
            Matrix4 world = Matrix4.Translation( new Vector3( 0, 0, 0 ) );
            Matrix4 worldViewProj = cam.Projection * cam.View * world;

            // uniform value
            debShader.SetUniformValue( debUIdWVP, ref worldViewProj );

            Vector4 a_Color = new Vector4( (color.R / 255.0f), (color.G / 255.0f), (color.B / 255.0f), (color.A / 255.0f) );
            debShader.SetUniformValue( debShader.FindUniform( "IAmbient" ), ref a_Color );

            graphics.SetShaderProgram( debShader );

            graphics.SetVertexBuffer( 0, debVb );
            graphics.DrawArrays( debMesh.Prim, 0, debMesh.IndexCount );
        }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:19,代码来源:RenderGeometry.cs

示例10: DrawSphere

        /// 球描画
        public void DrawSphere( GraphicsContext graphics, GeometrySphere trgSph, Camera cam, Rgba color )
        {
            if( debShader == null ){
            return ;
            }

            debVb.SetVertices( 0, debMesh.Positions );
            debVb.SetIndices( debMesh.Indices );

             		Matrix4 world = Matrix4.Translation( new Vector3( trgSph.X, trgSph.Y, trgSph.Z ) ) * Matrix4.Scale( new Vector3( trgSph.R, trgSph.R, trgSph.R ) );
            Matrix4 worldViewProj = cam.Projection * cam.View * world;

            // uniform value
            debShader.SetUniformValue( debUIdWVP, ref worldViewProj );

            Vector4 a_Color = new Vector4( (color.R / 255.0f), (color.G / 255.0f), (color.B / 255.0f), (color.A / 255.0f) );
            debShader.SetUniformValue( debShader.FindUniform( "IAmbient" ), ref a_Color );

            graphics.SetShaderProgram( debShader );

            graphics.SetVertexBuffer( 0, debVb );
            graphics.DrawArrays( debMesh.Prim, 0, debMesh.IndexCount );
        }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:24,代码来源:RenderGeometry.cs


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