This commit is contained in:
parent
7a8f40a1b7
commit
62e727cdea
@ -14,7 +14,12 @@ Size=775,335
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Frametime Graph]
|
[Window][Frametime Graph]
|
||||||
Pos=1345,20
|
Pos=1308,4
|
||||||
Size=566,324
|
Size=566,324
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Debug]
|
||||||
|
Pos=10,9
|
||||||
|
Size=178,77
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
|||||||
@ -96,6 +96,9 @@ public class Globals {
|
|||||||
//Core Engine signals
|
//Core Engine signals
|
||||||
//
|
//
|
||||||
public static boolean ENGINE_SHUTDOWN_FLAG = false;
|
public static boolean ENGINE_SHUTDOWN_FLAG = false;
|
||||||
|
//main debug flag
|
||||||
|
//current enables imgui debug menu or not
|
||||||
|
public static boolean ENGINE_DEBUG = true;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -181,7 +181,7 @@ public class Main {
|
|||||||
|
|
||||||
//init imgui debug windows
|
//init imgui debug windows
|
||||||
if(Globals.RUN_CLIENT && !Globals.HEADLESS){
|
if(Globals.RUN_CLIENT && !Globals.HEADLESS){
|
||||||
ImGuiWindowMacros.createFramerateGraph();
|
ImGuiWindowMacros.initImGuiWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
//fire off a loading thread for the title menus/screen
|
//fire off a loading thread for the title menus/screen
|
||||||
@ -244,7 +244,7 @@ public class Main {
|
|||||||
// track total frametiime in debug graph
|
// track total frametiime in debug graph
|
||||||
//
|
//
|
||||||
if(captureFramerate){
|
if(captureFramerate){
|
||||||
ImGuiWindowMacros.addFramerateDatapoint("totalframerate",deltaTime);
|
ImGuiWindowMacros.addFramerateDatapoint("totalframerate",deltaTime * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ public class Main {
|
|||||||
ClientFunctions.runClientFunctions();
|
ClientFunctions.runClientFunctions();
|
||||||
}
|
}
|
||||||
if(!Globals.HEADLESS && captureFramerate){
|
if(!Globals.HEADLESS && captureFramerate){
|
||||||
ImGuiWindowMacros.addFramerateDatapoint("clientsim",glfwGetTime()-functionTrackTimeStart);
|
ImGuiWindowMacros.addFramerateDatapoint("clientsim",(glfwGetTime()-functionTrackTimeStart)*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ public class Main {
|
|||||||
Globals.macroSimulation.simulate();
|
Globals.macroSimulation.simulate();
|
||||||
}
|
}
|
||||||
if(!Globals.HEADLESS && captureFramerate){
|
if(!Globals.HEADLESS && captureFramerate){
|
||||||
ImGuiWindowMacros.addFramerateDatapoint("serversim",glfwGetTime()-functionTrackTimeStart);
|
ImGuiWindowMacros.addFramerateDatapoint("serversim",(glfwGetTime()-functionTrackTimeStart)*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -349,7 +349,7 @@ public class Main {
|
|||||||
Globals.renderingEngine.drawScreen();
|
Globals.renderingEngine.drawScreen();
|
||||||
}
|
}
|
||||||
if(!Globals.HEADLESS && captureFramerate){
|
if(!Globals.HEADLESS && captureFramerate){
|
||||||
ImGuiWindowMacros.addFramerateDatapoint("render",glfwGetTime()-functionTrackTimeStart);
|
ImGuiWindowMacros.addFramerateDatapoint("render",(glfwGetTime()-functionTrackTimeStart)*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,7 @@ import static org.lwjgl.system.MemoryUtil.NULL;
|
|||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import org.joml.Matrix4d;
|
import org.joml.Matrix4d;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
@ -143,7 +144,7 @@ public class RenderingEngine {
|
|||||||
//if set to true, will render imgui windows
|
//if set to true, will render imgui windows
|
||||||
private static boolean imGuiShouldRender = true;
|
private static boolean imGuiShouldRender = true;
|
||||||
//All imgui windows that should be displayed
|
//All imgui windows that should be displayed
|
||||||
private static List<ImGuiWindow> imGuiWindows = new LinkedList<ImGuiWindow>();
|
private static List<ImGuiWindow> imGuiWindows = new CopyOnWriteArrayList<ImGuiWindow>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,9 @@ public class ImGuiWindow {
|
|||||||
|
|
||||||
//The elements housed within this window
|
//The elements housed within this window
|
||||||
List<ImGuiElement> elements = new LinkedList<ImGuiElement>();
|
List<ImGuiElement> elements = new LinkedList<ImGuiElement>();
|
||||||
|
|
||||||
|
//Optional callback for the window
|
||||||
|
ImGuiWindowCallback callback = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the window
|
* Creates the window
|
||||||
@ -38,6 +41,14 @@ public class ImGuiWindow {
|
|||||||
this.elements.remove(element);
|
this.elements.remove(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the callback for the window
|
||||||
|
* @param callback The callback
|
||||||
|
*/
|
||||||
|
public void setCallback(ImGuiWindowCallback callback){
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws this window
|
* Draws this window
|
||||||
*/
|
*/
|
||||||
@ -48,7 +59,22 @@ public class ImGuiWindow {
|
|||||||
element.draw();
|
element.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(callback != null){
|
||||||
|
callback.exec();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.end();
|
ImGui.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional callback for the window that lets you directly call imgui functions
|
||||||
|
*/
|
||||||
|
public static interface ImGuiWindowCallback {
|
||||||
|
/**
|
||||||
|
* The actual callback function
|
||||||
|
*/
|
||||||
|
public void exec();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
import electrosphere.renderer.ui.imgui.ImGuiLinePlot.ImGuiLinePlotDataset;
|
import electrosphere.renderer.ui.imgui.ImGuiLinePlot.ImGuiLinePlotDataset;
|
||||||
|
import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback;
|
||||||
|
import imgui.ImGui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various methods for creating specific imgui windows in engine
|
* Various methods for creating specific imgui windows in engine
|
||||||
@ -12,23 +14,41 @@ import electrosphere.renderer.ui.imgui.ImGuiLinePlot.ImGuiLinePlotDataset;
|
|||||||
public class ImGuiWindowMacros {
|
public class ImGuiWindowMacros {
|
||||||
|
|
||||||
//Framerate graph
|
//Framerate graph
|
||||||
private static ImGuiWindow imGuiWindow;
|
private static ImGuiWindow framerateWindow;
|
||||||
private static ImGuiLinePlot plot;
|
private static ImGuiLinePlot plot;
|
||||||
private static Map<String,ImGuiLinePlotDataset> dataSetMap;
|
private static Map<String,ImGuiLinePlotDataset> dataSetMap;
|
||||||
|
|
||||||
|
//main debug menu
|
||||||
|
private static ImGuiWindow mainDebugWindow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes imgui windows
|
||||||
|
*/
|
||||||
|
public static void initImGuiWindows(){
|
||||||
|
createMainDebugMenu();
|
||||||
|
createFramerateGraph();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a framerate graph
|
* Creates a framerate graph
|
||||||
*/
|
*/
|
||||||
public static void createFramerateGraph(){
|
private static void createFramerateGraph(){
|
||||||
imGuiWindow = new ImGuiWindow("Frametime Graph");
|
framerateWindow = new ImGuiWindow("Frametime Graph");
|
||||||
plot = new ImGuiLinePlot("Frametime plot");
|
plot = new ImGuiLinePlot("Frametime plot");
|
||||||
dataSetMap = new HashMap<String,ImGuiLinePlotDataset>();
|
dataSetMap = new HashMap<String,ImGuiLinePlotDataset>();
|
||||||
initFramerateGraphSeries("totalframerate");
|
initFramerateGraphSeries("totalframerate");
|
||||||
initFramerateGraphSeries("serversim");
|
initFramerateGraphSeries("serversim");
|
||||||
initFramerateGraphSeries("clientsim");
|
initFramerateGraphSeries("clientsim");
|
||||||
initFramerateGraphSeries("render");
|
initFramerateGraphSeries("render");
|
||||||
imGuiWindow.addElement(plot);
|
framerateWindow.addElement(plot);
|
||||||
RenderingEngine.addImGuiWindow(imGuiWindow);
|
framerateWindow.setCallback(new ImGuiWindowCallback() {
|
||||||
|
@Override
|
||||||
|
public void exec() {
|
||||||
|
if(ImGui.button("Close")){
|
||||||
|
RenderingEngine.removeImGuiWindow(framerateWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,4 +75,26 @@ public class ImGuiWindowMacros {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the main debug menu
|
||||||
|
*/
|
||||||
|
private static void createMainDebugMenu(){
|
||||||
|
mainDebugWindow = new ImGuiWindow("Debug");
|
||||||
|
mainDebugWindow.callback = new ImGuiWindowCallback() {
|
||||||
|
@Override
|
||||||
|
public void exec() {
|
||||||
|
//show framerate graph
|
||||||
|
if(ImGui.button("Show Overall Frametime")){
|
||||||
|
RenderingEngine.addImGuiWindow(framerateWindow);
|
||||||
|
}
|
||||||
|
//close button
|
||||||
|
if(ImGui.button("Close")){
|
||||||
|
RenderingEngine.removeImGuiWindow(mainDebugWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RenderingEngine.addImGuiWindow(mainDebugWindow);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user