當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。