private void DrawPrimitives() { // Clears the screen with the Color.CornflowerBlue GraphicsDevice.Clear(GraphicsDevice.DepthStencilBuffer, DepthStencilClearOptions.DepthBuffer | DepthStencilClearOptions.Stencil); GraphicsDevice.Clear(GraphicsDevice.BackBuffer, Color.CornflowerBlue); GraphicsDevice.SetRenderTarget(GraphicsDevice.DepthStencilBuffer, GraphicsDevice.BackBuffer); // Render each primitive for (int i = 0; i < primitives.Count; i++) { var primitive = primitives[i]; // Calculate the translation float dx = ((i + 1) % 4); float dy = ((i + 1) / 4); float x = (dx - 1.5f) * 1.7f; float y = 1.0f - 2.0f * dy; var time = timeSeconds + i; // Setup the World matrice for this primitive var world = Matrix.Scaling((float)Math.Sin(time * 1.5f) * 0.2f + 1.0f) * Matrix.RotationX(time) * Matrix.RotationY(time * 2.0f) * Matrix.RotationZ(time * .7f) * Matrix.Translation(x, y, 0); //var world = Matrix.Translation(x, y, 0); // Disable Cull only for the plane primitive, otherwise use standard culling GraphicsDevice.SetRasterizerState(i == 0 ? GraphicsDevice.RasterizerStates.CullNone : GraphicsDevice.RasterizerStates.CullBack); // Draw the primitive using BasicEffect simpleEffect.Transform = Matrix.Multiply(world, Matrix.Multiply(view, projection)); simpleEffect.Apply(); primitive.Draw(); } }
private void DrawTextureSampling() { // Clears the screen GraphicsDevice.Clear(GraphicsDevice.BackBuffer, Color.LightBlue); GraphicsDevice.Clear(GraphicsDevice.DepthStencilBuffer, DepthStencilClearOptions.DepthBuffer | DepthStencilClearOptions.Stencil); GraphicsDevice.SetRenderTarget(GraphicsDevice.DepthStencilBuffer, GraphicsDevice.BackBuffer); GraphicsDevice.SetRasterizerState(GraphicsDevice.RasterizerStates.CullNone); GraphicsDevice.SetVertexArrayObject(vao); for (var i = 0; i < myDraws.Length; ++i) { simpleEffect.Sampler = myDraws[i].Sampler; simpleEffect.Transform = myDraws[i].Transform; simpleEffect.Apply(); GraphicsDevice.DrawIndexed(PrimitiveType.TriangleList, 6); } GraphicsDevice.SetVertexArrayObject(null); }
private void DrawGeometry() { simpleEffect.Transform = worldViewProjection; simpleEffect.Apply(); geometry.Draw(); }