public void Render() { UniformBuffers.DirectionLightBuffer.Update(lightBufferData); WorldCamera.Update(); for (var index = 0; index < loadedEntities.Count; index++) { loadedEntities[index].Render(); } for (var index = 0; index < loadedChunks.Count; index++) { loadedChunks[index].Render(); } Skybox.Render(); }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); string oglVersion = GL.GetString(StringName.Version); Title = $"FPS: {1 / e.Time:F0}, Version: {oglVersion}"; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); _skyboxProgram.Use(); _skyboxProgram.setMat4("view", _player.Camera.ViewMatrix.ClearTranslation()); _skyboxProgram.setMat4("projection", _player.Camera.ProjectionMatrix); GL.DepthMask(false); GL.Disable(EnableCap.DepthTest); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); _skybox.Render(); _program.Use(); _program.setMat4("view", _player.Camera.ViewMatrix); _program.setMat4("projection", _player.Camera.ProjectionMatrix); _program.setMat4("model", Matrix4.Identity); _program.setVec3("light_color", Vector3.One); _program.setVec3("light_position", new Vector3(0, 10, 50)); _program.setVec3("camera_position", _player.Position); GL.DepthMask(true); GL.Enable(EnableCap.DepthTest); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); _world.Render(); _debugProgram.Use(); _debugProgram.setMat4("view", _player.Camera.ViewMatrix); _debugProgram.setMat4("projection", _player.Camera.ProjectionMatrix); _debugProgram.setMat4("model", Matrix4.Identity); GL.Disable(EnableCap.DepthTest); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line); DebugDrawManager.Render(); SwapBuffers(); }
protected override void RenderObjects() { // Skybox renderer. Programs[ProgramID.Skybox].UseProgram(); Programs[ProgramID.Skybox].UniformMatrix4("projection", ref ProjectionMatrix); Programs[ProgramID.Skybox].UniformMatrix4("view", ref StaticViewMatrix); Programs[ProgramID.Skybox].UniformMatrix4("model", ref Skybox.ModelMatrix); Programs[ProgramID.Skybox].Uniform1("time", (float)RTime); Skybox.Render(); //// Basic renderer. Programs[ProgramID.Full].UseProgram(); Programs[ProgramID.Full].UniformMatrix4("projection", ref ProjectionMatrix); Programs[ProgramID.Full].UniformMatrix4("view", ref ViewMatrix); Board.Model.Render(); // Dice one renderer. Programs[ProgramID.Dice].UseProgram(); Programs[ProgramID.Dice].Uniform3("light_position", ref ActiveLight.Position); Programs[ProgramID.Dice].Uniform3("light_color", ref ActiveLight.Color); Programs[ProgramID.Dice].Uniform1("light_ambientIntensity", ActiveLight.DiffuseIntensity); Programs[ProgramID.Dice].Uniform1("light_diffuseIntensity", ActiveLight.AmbientIntensity); Programs[ProgramID.Dice].UniformMatrix4("projection", ref ProjectionMatrix); Programs[ProgramID.Dice].UniformMatrix4("view", ref ViewMatrix); Programs[ProgramID.Dice].UniformMatrix4("model", ref DiceOne.ModelMatrix); Programs[ProgramID.Dice].Uniform1("time", (float)RTime); DiceOne.Model.Render(); // Dice two renderer. Programs[ProgramID.Dice].UniformMatrix4("model", ref DiceTwo.ModelMatrix); Programs[ProgramID.Dice].Uniform1("time", (float)RTime); DiceTwo.Model.Render(); // Player renderer. Programs[ProgramID.Player].UseProgram(); foreach (var player in Board.GetPlayers()) { Programs[ProgramID.Player].UniformMatrix4("projection", ref ProjectionMatrix); Programs[ProgramID.Player].UniformMatrix4("view", ref ViewMatrix); Programs[ProgramID.Player].UniformMatrix4("model", ref player.ModelMatrix); Programs[ProgramID.Player].Uniform4("colour", ref player.Colour); player.Model.Render(); } }