private static void RenderEditor(FrameEventArgs e) { imgui.Update(mainWindow.KeyboardState, mainWindow.MouseState, (float)e.Time); Ogl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); Ogl.ClearColor(0.1f, 0.1f, 0.1f, 255); EntygineApp.RenderFrame(e); Ogl.Viewport(0, 0, mainWindow.Size.X, mainWindow.Size.Y); imgui.WindowResized(mainWindow.Size.X, mainWindow.Size.Y); mainEditorDrawer.Draw(); imgui.Render(); }
public static RenderCommand DrawGeometry(CameraData camera, Matrix4 cameraTransform) { return(new RenderCommand("Draw Geometry", (ref RenderContext context) => { if (!context.TryGetData(out GeometryRenderData geometryData)) { return; } if (!context.TryGetData(out LightsRenderData lightData)) { return; } //if (MainDevWindowGL.Window.KeyboardState.IsKeyDown(OpenTK.Windowing.GraphicsLibraryFramework.Keys.I)) // yaw += 0.1f; //if (MainDevWindowGL.Window.KeyboardState.IsKeyDown(OpenTK.Windowing.GraphicsLibraryFramework.Keys.O)) // yaw -= 0.1f; //if (MainDevWindowGL.Window.KeyboardState.IsKeyDown(OpenTK.Windowing.GraphicsLibraryFramework.Keys.K)) // pitch += 0.1f; //if (MainDevWindowGL.Window.KeyboardState.IsKeyDown(OpenTK.Windowing.GraphicsLibraryFramework.Keys.L)) // pitch -= 0.1f; Ogl.Viewport(0, 0, AppScreen.Resolution.x, AppScreen.Resolution.y); Ogl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Light mainLight = lightData.lights[0]; Matrix4 projection = camera.CalculateProjection(); List <MeshRenderGroup> renderGroups = geometryData.GetRenderGroups(); for (int i = 0; i < renderGroups.Count; i++) { MeshRenderGroup renderGroup = renderGroups[i]; RenderMesh pair = renderGroup.MeshRender; List <Matrix4> positions = renderGroup.Transforms; pair.mat.SetDepthMap(new DepthTexture(mainLight.Framebuffer.DepthBuffer)); GraphicsAPI.UseMeshMaterial(pair.mesh, pair.mat); //Update camera pos for material //TODO: Use 'Uniform buffer objects' to globally share this data pair.mat.SetMatrix("view", cameraTransform); pair.mat.SetMatrix("projection", projection); pair.mat.SetVector3("directionalLight", new Vector3(1, 1, 1)); pair.mat.SetVector3("ambientLight", new Vector3(0.5f, 0.5f, 0.5f)); pair.mat.SetVector3("directionalDir", LIGHT_FORWARD_NORMALIZED); pair.mat.SetMatrix("lightSpace", LIGHT_VIEW * mainLight.GetProjection()); for (int p = 0; p < positions.Count; p++) { pair.mat.SetMatrix("model", positions[p]); GraphicsAPI.DrawTriangles(pair.mesh.GetIndiceCount()); } GraphicsAPI.FreeMeshMaterial(pair.mesh, pair.mat); } }));