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


C# GraphicsContext.SetShaderProgram方法代码示例

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


在下文中一共展示了GraphicsContext.SetShaderProgram方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: Draw

        /// BasicMaterial に設定された ShaderName から、ShaderProgram を探して描画する
        public void Draw(
                     GraphicsContext graphics,
                     ShaderContainer shaderContainer,
                     Matrix4 viewProj,
                     Vector4 eye
                     )
        {
            foreach ( var bone in Bones ) {
            int worldCount = 0;
            int[] blendBones = bone.BlendBones ;
            if ( blendBones == null ) {
                worldCount = 1;
                matrixBuffer = new Matrix4[ 1 ] ;
                matrixBuffer[ 0 ] = bone.WorldMatrix;
            }else{
                int blendCount = blendBones.Length ;
                if ( blendCount > matrixBuffer.Length ) matrixBuffer = new Matrix4[ blendCount ] ;
                for ( int i = 0 ; i < blendCount ; i ++ ) {
                    matrixBuffer[ i ] = Bones[ blendBones[ i ] ].WorldMatrix * bone.BlendOffsets[ i ] ;
                }
            }
            int[] blendSubset = defaultBlendSubset ;
            foreach ( var index in bone.DrawParts ) {
                BasicPart part = Parts[ index ] ;
                foreach ( var mesh in part.Meshes ) {
                    if ( blendBones != null && blendSubset != mesh.BlendSubset ) {
                        blendSubset = ( mesh.BlendSubset != null ) ? mesh.BlendSubset : defaultBlendSubset ;
                        worldCount = blendSubset.Length ;
                        if ( worldCount > blendBones.Length ) worldCount = blendBones.Length ;
                    }
                    BasicMaterial material = Materials[ mesh.Material ];

                    if( material != null ){
                        setPolygonMode( graphics, material );

                        BasicProgram program = findBasicProgram( shaderContainer, material, worldCount, this.lightCount );
                        graphics.SetShaderProgram( program );

                        program.SetViewProj( viewProj );

                        program.SetMaterial( ref material );
                        if( material.LightEnable != 0 ){
                            program.SetLightCount( lightCount );
                            //                            program.SetLights( ref this.WorldMatrix, ref eye, ref lights );
                            program.SetLights( ref matrixBuffer[ 0 ], ref eye, ref lights );
                        }else{
                            program.SetLightCount( 0 );
                        }

                        setLayers( graphics, program, material );

                        program.SetWorldCount( worldCount );
                        for( int i = 0; i < worldCount; i++ ){
                            program.SetMatrixPalette( i, ref matrixBuffer[ blendSubset[ i ] ] );
                        }

                        program.Update();
                    }

                    graphics.SetVertexBuffer( 0, mesh.VertexBuffer ) ;
                    graphics.DrawArrays( mesh.Primitives ) ;
                }
            }
            }
        }
开发者ID:hatano0x06,项目名称:Coroppoxus,代码行数:66,代码来源:BasicModel+(2).cs

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

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

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

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

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