public static void Draw() { // We can fill vertex buffer only when in Draw LoadInDraw(); RasterizerState.CullClockwise.Apply(); DepthStencilState.None.Apply(); BlendState.Opaque.Apply(); if (MyRender.CurrentRenderSetup.BackgroundColor != null) { MyMinerGame.Static.GraphicsDevice.Clear(ClearFlags.Target, SharpDXHelper.ToSharpDX(MyRender.CurrentRenderSetup.BackgroundColor.Value), 1, 0); } else { MyEffectBackgroundCube effect = MyRender.GetEffect(MyEffects.BackgroundCube) as MyEffectBackgroundCube; effect.SetViewProjectionMatrix(MyCamera.ViewMatrixAtZero * m_backgroundProjectionMatrix); effect.SetBackgroundTexture(m_textureCube); effect.SetBackgroundColor(MySector.SunProperties.BackgroundColor); MyMinerGame.Static.GraphicsDevice.VertexDeclaration = MyVertexFormatPositionTexture3.VertexDeclaration; MyMinerGame.Static.GraphicsDevice.SetStreamSource(0, m_boxVertexBuffer, 0, MyVertexFormatPositionTexture3.Stride); effect.Begin(); MyMinerGame.Static.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, BOX_TRIANGLES_COUNT); effect.End(); MyPerformanceCounter.PerCameraDraw.TotalDrawCalls++; } }
public static void Draw() { // We can fill vertex buffer only when in Draw LoadInDraw(); //RasterizerState.CullClockwise.Apply(); RasterizerState.CullNone.Apply(); DepthStencilState.None.Apply(); BlendState.Opaque.Apply(); m_backgroundProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MyRenderCamera.FieldOfView, MyRenderCamera.AspectRatio, MyRenderCamera.NEAR_PLANE_DISTANCE, 100000); if (MyRender.CurrentRenderSetup.BackgroundColor != null) { MyRender.GraphicsDevice.Clear(ClearFlags.Target, new SharpDX.ColorBGRA(MyRender.CurrentRenderSetup.BackgroundColor.Value.R, MyRender.CurrentRenderSetup.BackgroundColor.Value.G, MyRender.CurrentRenderSetup.BackgroundColor.Value.B, MyRender.CurrentRenderSetup.BackgroundColor.Value.A), 1, 0); } else if (m_textureCube != null) { MyEffectBackgroundCube effect = MyRender.GetEffect(MyEffects.BackgroundCube) as MyEffectBackgroundCube; effect.SetViewProjectionMatrix(MyRenderCamera.ViewMatrixAtZero * m_backgroundProjectionMatrix); effect.SetBackgroundTexture(m_textureCube); effect.SetBackgroundColor(BackgroundColor); MyRender.GraphicsDevice.VertexDeclaration = MyVertexFormatPositionTexture3.VertexDeclaration; MyRender.GraphicsDevice.SetStreamSource(0, m_boxVertexBuffer, 0, MyVertexFormatPositionTexture3.Stride); effect.Begin(); MyRender.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, BOX_TRIANGLES_COUNT); effect.End(); MyPerformanceCounter.PerCameraDrawWrite.TotalDrawCalls++; } else { MyRender.GraphicsDevice.Clear(ClearFlags.Target, new SharpDX.ColorBGRA(BackgroundColor.X, BackgroundColor.Y, BackgroundColor.Z, 1), 1, 0); } }