protected override void OnDraw(double time, double delta) { if (CursorSprite is null) { return; } if (MeshRenderer is null) { throw new NullReferenceException("MeshRenderer is null"); } if (CursorSprite.SpriteSet.Texture is null) { throw new NullReferenceException("CursorSprite's spriteset has a null texture"); } // Disable depth testing and writing GL.Disable(EnableCap.DepthTest); GL.DepthMask(false); // Render MeshRenderer.Begin(); ShaderProgram.SetTextureSource(CursorSprite.TopLeftCoord, CursorSprite.SizeCoord); CursorSprite.SpriteSet.Texture.BindDiffuse(); var trans = Transform.Matrix; MeshRenderer.DrawMesh(Mesh, ref trans, Color.White, BlendType.AlphaPremultiplied); MeshRenderer.End(); // Enable depth settings GL.Enable(EnableCap.DepthTest); GL.DepthMask(true); }
public void Draw(Vector3 cameraUp, Vector3 cameraForward) { // Draw the gun mesh meshRenderer.DrawMesh(gunMesh); // Draw the bullet particles bulletParticleEmitter.DrawParticles(cameraUp, cameraForward); // Draw muzzle flash if (runAnimation || rumbleTimer > RUMBLE_TIME * 0.9f) { billboardRenderer.DrawParticle(muzzleFlashBillboard, cameraUp, cameraForward); } }
protected override void OnDraw(double time, double delta) { if (!(Mesh is null)) { if (TileExtensions.SpriteSet.Texture is null) { throw new NullReferenceException("SpriteSet texture is null"); } // Enable depth testing GL.Enable(EnableCap.DepthTest); // Render MeshRenderer.Begin(); TileExtensions.SpriteSet.Texture.BindDiffuse(); DiffuseSampler.BindDiffuse(); var trans = Matrix4 <float> .Identity; MeshRenderer.DrawMesh(Mesh, ref trans, Color.White, BlendType.Alpha); MeshRenderer.End(); } base.OnDraw(time, delta); }
private void DrawMain(BoundingFrustum viewFrustum) { graphicsDevice.SetRenderTarget(mainRT); graphicsDevice.Clear(clearColor); if (level.Type == LevelType.Outdoor) { terrainRenderer.Draw(level.Terrain); terrainRenderer.Draw(level.TerrainPlane); } else { surfaceRenderer.DrawSurface(level.Surface); } foreach (Mesh mesh in level.MeshList) { if (viewFrustum.Intersects(mesh.AABB)) { meshRenderer.DrawMesh(mesh, viewFrustum); } } foreach (ShootingTarget target in level.ShootingTargetList) { target.Draw(meshRenderer, viewFrustum); } foreach (Billboard billboard in level.BillboardList) { billboardRenderer.DrawLighting(billboard, camera.Up, camera.Look); } level.Sky.DrawClouds(); if (level.WaterHeight != Level.WATER_DISABLED_HEIGHT) { waterRenderer.Draw(level.Water, reflectionRT, mainRT); } // Draw post processing if (postProcessingEffectsEnabled) { graphicsDevice.RasterizerState = RasterizerState.CullNone; graphicsDevice.SetRenderTarget(occlusionRT); graphicsDevice.Clear(Color.Black); // Draw light into occlusion map lightRenderer.Draw(level.Light, camera.Up, camera.Look); // Copy Occlusion data from the Alpha channel of main render target postEffects.DrawCopyOcclusion(mainRT); graphicsDevice.SetRenderTarget(bloomRT); graphicsDevice.Clear(Color.Black); // Draw lightscattering into bloom map postEffects.DrawLightScattering(occlusionRT); // Apply bloom lighting to output the final image graphicsDevice.SetRenderTarget(null); postEffects.ApplyBloom(mainRT, bloomRT); } }
public void Draw(MeshRenderer meshRenderer, BoundingFrustum viewFrustum) { // Draw the target mesh meshRenderer.DrawMesh(targetMesh, viewFrustum); }