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


C# RenderContext11.SetupBasicEffect方法代码示例

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


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

示例1: SetupGroundOverlays

        // Set up render context state required for drawing ground overlays when shaders
        // are enabled.
        public void SetupGroundOverlays(RenderContext11 renderContext)
        {
            // A shader should be set up already
            if (renderContext.Shader == null)
            {
                renderContext.SetupBasicEffect(BasicEffect.TextureOnly, 1.0f, Color.White);
            }

            // Count the number of overlays so that we can choose the appropriate shader
            var overlayCount = 0;
            foreach (var overlay in GroundOverlays)
            {
                if (overlay.Icon.Texture != null)
                {
                    ++overlayCount;
                }
            }

            overlayCount = Math.Min(PlanetShader11.MaxOverlayTextures, overlayCount);
            if (overlayCount == 0)
            {
                // No work to do
                return;
            }

            // Get a shader identical to the one currently in use, but which supports
            // the required number of overlays.
            var key = renderContext.Shader.Key;
            key.overlayTextureCount = overlayCount;
            var overlayShader = PlanetShader11.GetPlanetShader(renderContext.Device, key);
            renderContext.Shader = overlayShader;
            renderContext.Shader.DiffuseColor = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            var devContext = renderContext.Device.ImmediateContext;
            var overlayIndex = 0;
            foreach (var overlay in GroundOverlays)
            {
                var texture = overlay.Icon.Texture;
                if ( texture != null)
                {
                    if (overlayIndex < PlanetShader11.MaxOverlayTextures)
                    {
                        renderContext.Shader.SetOverlayTextureMatrix(overlayIndex, overlay.GetMatrix().Matrix11);
                        renderContext.Shader.SetOverlayTextureColor(overlayIndex, overlay.color);
                        renderContext.Shader.SetOverlayTexture(overlayIndex, texture.ResourceView);
                    }
                    ++overlayIndex;
                }
            }
        }
开发者ID:bluephoton,项目名称:wwt-windows-client,代码行数:51,代码来源:Label.cs

示例2: Draw

        public void Draw(RenderContext11 renderContext, float Opacity, Color drawColor)
        {
            if (glyphCache == null || glyphCache.Version > glyphVersion)
            {
                PrepareBatch();
            }

            //todo11 Use Shader

            renderContext.SetupBasicEffect(BasicEffect.TextureColorOpacity, Opacity, drawColor);
            renderContext.MainTexture = glyphCache.Texture;
            renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;

            renderContext.PreDraw();

            if (layout == null)
            {
                layout = new SharpDX.Direct3D11.InputLayout(renderContext.Device, renderContext.Shader.InputSignature, new[]
                           {
                               new SharpDX.Direct3D11.InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float,     0, 0),
                               new SharpDX.Direct3D11.InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float,       12, 0),
                           });
            }
            renderContext.Device.ImmediateContext.InputAssembler.InputLayout = layout;

            renderContext.SetVertexBuffer(vertexBuffer);

            renderContext.devContext.Draw(vertexBuffer.Count, 0);
        }
开发者ID:china-vo,项目名称:wwt-windows-client,代码行数:29,代码来源:SkyText.cs

示例3: Draw

        public void Draw(RenderContext11 renderContext)
        {
            renderContext.devContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            renderContext.devContext.InputAssembler.SetVertexBuffers(0, vertexBufferBinding);
            renderContext.devContext.InputAssembler.SetIndexBuffer(indexBuffer, SharpDX.DXGI.Format.R32_UInt, 0);



            renderContext.SunPosition = new Vector3d(500, 500, 0.0);
            renderContext.SunlightColor = System.Drawing.Color.White;
            renderContext.AmbientLightColor = System.Drawing.Color.DarkGray;

            renderContext.SetupBasicEffect(BasicEffect.TextureOnly, 1.0f, System.Drawing.Color.White);
            renderContext.MainTexture = texture;

            renderContext.PreDraw();


            if (layout == null)
            {
                layout = new SharpDX.Direct3D11.InputLayout(renderContext.Device, renderContext.Shader.InputSignature, new[]
                           {
                               new SharpDX.Direct3D11.InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float,     0, 0),
                               new SharpDX.Direct3D11.InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float,       16, 0),
                           });
                renderContext.Device.ImmediateContext.InputAssembler.InputLayout = layout;
            }


            // Draw the cube
            renderContext.devContext.DrawIndexed(triangleCount * 3, 0, 0);
        }
开发者ID:keenedge,项目名称:wwt-windows-client,代码行数:32,代码来源:3dWIndow.cs


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