Skip to content

Commit

Permalink
Cleaned Git repo and edited TimeDebug class
Browse files Browse the repository at this point in the history
Added .gitignore
Added LICENSE
removed .classpath
removed .project
removed bin/
removed .settings/
  • Loading branch information
Slaynash committed Nov 19, 2017
1 parent d633509 commit 0407f8b
Show file tree
Hide file tree
Showing 79 changed files with 196 additions and 139 deletions.
21 changes: 0 additions & 21 deletions .classpath

This file was deleted.

31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# Eclipse files #
.classpath
.project
.settings/
bin/

# specials project files #
!libs/**

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
17 changes: 0 additions & 17 deletions .project

This file was deleted.

12 changes: 0 additions & 12 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Slaynash

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 0 additions & 1 deletion bin/.gitignore

This file was deleted.

Binary file removed bin/slaynash/sgengine/Configuration$1.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/Configuration.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/audio/AudioManager.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/audio/AudioSource.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/GUIElement.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/GUIFrame.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/GUIImage.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/GUIManager$1.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/GUIManager.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/GUIMiniPopup.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/GUIPopup.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/GUIText.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/button/GUIButton.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/button/GUIButtonAdapter.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/button/GUIButtonEvent.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/comboBox/GUIComboBox.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/slider/GUISlider.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/slider/GUISliderAdapter.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/slider/GUISliderEvent.class
Binary file not shown.
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/text2d/FontManager.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/gui/text2d/Text2d.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed bin/slaynash/sgengine/inputs/Controller.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/inputs/ControllerControl.class
Binary file not shown.
Binary file not shown.
Binary file removed bin/slaynash/sgengine/inputs/KeyboardControl.class
Binary file not shown.
Binary file not shown.
Binary file removed bin/slaynash/sgengine/models/Renderable2dModel.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/models/Renderable3dModel.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/models/RenderableModel.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/objloader/ObjLoader.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/objloader/VertexNM.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/shaders/ShaderManager.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/shaders/ShaderProgram.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/textureUtils/TextureDef.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed bin/slaynash/sgengine/utils/DisplayManager.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/utils/LibraryLoader.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/utils/MatrixUtils.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/utils/RaycastUtil.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/utils/ShapeHelper.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/utils/UserInputUtil.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/utils/VRUtils.class
Binary file not shown.
Binary file removed bin/slaynash/sgengine/utils/vr/VRController.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18 changes: 9 additions & 9 deletions src/slaynash/sgengine/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public class Configuration {
private static boolean vsync = true;
private static boolean collisionManager3dEnabled = false;
private static boolean collisionManager2dEnabled = false;
private static boolean deferredRender = false;
private static boolean deferredRenderShadows = false;
private static boolean deferredRender = true;
private static boolean deferredRenderShadows = true;
private static boolean cleanBetweenDeferredRendersEnabled = true;
private static boolean selfUpdateEntities = true;
private static boolean handRendered = false;
private static boolean deferredRenderBloom = true;
private static boolean deferredRenderPostProcessing = true;
private static boolean usingTimingDebug = false;
private static boolean guiEnabled = true;

Expand All @@ -57,7 +57,7 @@ public static void loadDefault3DFPSConfigurations() {
enableVSync(true);
useDeferredRender(true);
useDeferredRenderShadows(true);
useDeferredRenderBloom(true);
usePostProcessing(true);
//useDeferredReflections(true);
setCleanBetweenDeferredRendersEnabled(true);
setSelfEntitiesUpdateEnabled(true);
Expand All @@ -80,7 +80,7 @@ public static void loadDefaultVRConfigurations() {
useDeferredRender(true);
useDeferredRenderShadows(true);
//useDeferredReflections(true);
useDeferredRenderBloom(true);
usePostProcessing(true);
setCleanBetweenDeferredRendersEnabled(true);
setSelfEntitiesUpdateEnabled(true);
setHandRendered(false);
Expand All @@ -101,7 +101,7 @@ public static void loadDefault3DRPGConfigurations() {
enableVSync(true);
useDeferredRender(true);
useDeferredRenderShadows(true);
useDeferredRenderBloom(false);
usePostProcessing(false);
//useDeferredReflections(true);
setCleanBetweenDeferredRendersEnabled(true);
setSelfEntitiesUpdateEnabled(true);
Expand Down Expand Up @@ -333,11 +333,11 @@ public static void setHandRendered(boolean handrendered) {
}

public static boolean isPostProcessingEnabled() {
return deferredRenderBloom;
return deferredRenderPostProcessing;
}

public static void useDeferredRenderBloom(boolean deferredRenderBloom) {
Configuration.deferredRenderBloom = deferredRenderBloom;
public static void usePostProcessing(boolean deferredRenderBloom) {
Configuration.deferredRenderPostProcessing = deferredRenderBloom;
}

public static boolean isUsingTimingDebug() {
Expand Down
112 changes: 107 additions & 5 deletions src/slaynash/sgengine/DebugTimer.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,118 @@
package slaynash.sgengine;

import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import org.lwjgl.opengl.GL11;

public class DebugTimer {

private static long startTime = 0;
private static long baseTime = 0;

private static List<DebugTime> times = new ArrayList<DebugTime>();
private static List<DebugTime> savedTimes = new ArrayList<DebugTime>();
private static TimingDebugFrame frame;
private static float totalTime = 0;

public static void outputAndUpdateTime(String string) {
if(Configuration.isUsingTimingDebug()) {
GL11.glFinish();
//LogSystem.out_println("[TIMING] VR Render time [Left][Defe]: "+((System.nanoTime()-startTime)/1e6f)+"ms");
times.add(new DebugTime(((System.nanoTime()-startTime)/1e6f), string));
startTime = System.nanoTime();
}
}

public static void start() {
startTime = System.nanoTime();
public static void restart() {
times.clear();
baseTime = startTime = System.nanoTime();
}

public static void outputAndUpdateTime(String string) {
if(Configuration.isUsingTimingDebug()) LogSystem.out_printf(string, ((System.nanoTime()-startTime)/1e6f));
startTime = System.nanoTime();
private static class DebugTime{
float duration;
String name;

public DebugTime(float duration, String name) {
this.duration = duration;
this.name = name;
}
}

public static void finishUpdate() {
synchronized (savedTimes) {
savedTimes.clear();
savedTimes.addAll(times);

totalTime = ((System.nanoTime()-baseTime)/1e6f);
if(Configuration.isUsingTimingDebug()) {
LogSystem.out_println("");
LogSystem.out_println("[DebugTimer] Total time: "+totalTime+"ms");
for(int i=0;i<times.size();i++) {
DebugTime dt = times.get(i);
LogSystem.out_printf("[DebugTimer] %f%% - %f ms - %s\n", (dt.duration/totalTime*100), dt.duration, dt.name);
}
LogSystem.out_println("");
}

}

if(frame != null) SwingUtilities.invokeLater(new Runnable() {

@Override
public void run() {
frame.validate();
}
});
}

public static void showDebugFrame() {
if(frame == null)
frame = new TimingDebugFrame();
if(!frame.isVisible())
frame.setVisible(true);
}

private static class TimingDebugFrame extends JFrame {
private static final long serialVersionUID = -7547608523892329109L;

TimingDebugFrame(){
super("SGE timing debug frame");
setResizable(false);
setSize(440, 440);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}

@Override
public void paintComponents(Graphics g) {
synchronized (savedTimes) {
super.paintComponents(g);

Random rng= new Random(0);

float lastAng = 0;
float ang = 0;

g.setColor(Color.BLACK);
g.drawString(String.format("%.2f", totalTime)+"ms - "+(int)(1000/totalTime)+"fps", 0, 50);

for(DebugTime t:savedTimes) {
ang = t.duration/totalTime*360;
g.setColor(new Color(rng.nextInt(256), rng.nextInt(256), rng.nextInt(256)));
g.fillArc(20, 30, 400, 400, (int)lastAng, (int)ang);
lastAng+=ang;
}
g.setColor(Color.WHITE);
g.fillArc(20, 30, 400, 400, (int)lastAng, 360-(int)lastAng);

}

}
}
}
28 changes: 13 additions & 15 deletions src/slaynash/sgengine/deferredRender/DeferredRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import de.fruitfly.ovr.structs.Vector2i;
import slaynash.sgengine.Configuration;
import slaynash.sgengine.DebugTimer;
import slaynash.sgengine.LogSystem;
import slaynash.sgengine.shaders.ShaderManager;
import slaynash.sgengine.shaders.ShaderProgram;
Expand All @@ -29,7 +30,6 @@ public class DeferredRenderer {
protected static FrameBufferedObject[] fbos_color = new FrameBufferedObject[3];

private static PostProcessingPipeline postProcessingPipeline;
private static long startTime;

public static void init() {
if(postProcessingPipeline == null) postProcessingPipeline = new PostProcessingPipelineDefault();
Expand All @@ -55,10 +55,9 @@ public static void render(int eye) {
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glCullFace(GL11.GL_BACK);

if(Configuration.isUsingTimingDebug()) startTime = System.nanoTime();
if(Configuration.isUsingDeferredRenderShadows()) {
ShadowsRenderer.renderShadows(eye, shaderLists);
timingdebug("Shadows render time");
DebugTimer.outputAndUpdateTime("Shadows render time");
}
if(Configuration.isPostProcessingEnabled()) {

Expand All @@ -69,17 +68,17 @@ public static void render(int eye) {
fbos_colorSSAA[eye].resolveToFbo(fbos_color[eye]);


timingdebug("Deferred render time");
DebugTimer.outputAndUpdateTime("Deferred render time");
renderPostProcessing(eye);
timingdebug("PostProcessing render time");
DebugTimer.outputAndUpdateTime("PostProcessing render time");
}
else {
VRUtils.setCurrentRenderEye(eye);
renderColor(eye);
timingdebug("Deferred render time");
DebugTimer.outputAndUpdateTime("Deferred render time");
}
if(Configuration.isCleanBetweenDeferredRendersEnabled()) cleanup();
timingdebug("Deferred cleanup time");
DebugTimer.outputAndUpdateTime("Deferred cleanup time");

GL11.glDisable(GL11.GL_CULL_FACE);
}
Expand All @@ -90,23 +89,20 @@ private static void renderPostProcessing(int eye) {
if(eye != VRUtils.EYE_CENTER) postProcessingPipeline.renderVR(fbos_color[eye], eye);
else postProcessingPipeline.render(fbos_color[VRUtils.EYE_CENTER]);
}

public static void timingdebug(String text) {
if(Configuration.isUsingTimingDebug()) {
GL11.glFinish();
LogSystem.out_println("[TIMING] > "+text+": "+((System.nanoTime()-startTime)/1e6f)+"ms");
startTime = System.nanoTime();
}
}



protected static void renderColor(int eye){
if(Configuration.isUsingTimingDebug()) LogSystem.out_println("[DR] rendering "+shaderLists.size()+" shader loops:");
int l1=0;
for(ShaderRenderlist map:shaderLists){//for each shader phase
if(Configuration.isUsingTimingDebug()) LogSystem.out_println("[DR] \tShader "+l1+": rendering "+map.getObjectList().size()+" models");
ShaderProgram shader = map.getShader();
shader.useDirect();
if(shader.getShaderType() == ShaderProgram.SHADER_3D_MODERN || shader.getShaderType() == ShaderProgram.SHADER_VR_MODERN) ShaderManager.shader_loadLights(LightsManager.getPointlights());
int l2=0;
for(Entry<Integer, ArrayList<DeferredModelRenderer>> entry:map.getObjectList().entrySet()){//for each models of this type
if(Configuration.isUsingTimingDebug()) LogSystem.out_println("[DR] \t\tModel "+l2+": rendering "+entry.getValue().size()+" instances");
shader.bindModel(entry.getKey());
for(DeferredModelRenderer dmr:entry.getValue()){//for each render of this model
shader.bindDatasDirect(dmr.getShaderDatas());
Expand All @@ -116,8 +112,10 @@ protected static void renderColor(int eye){
}
if(eye == VRUtils.EYE_CENTER) dmr.render(); else dmr.renderVR(eye);
}
l2++;
}
shader.stop();
l1++;
}
}

Expand Down
Loading

0 comments on commit 0407f8b

Please sign in to comment.