X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fgui%2FViewPanel.java;h=9c0681cd4e8320157ddcd84774d4b8c5c3a1d4b9;hb=a3ff3683bd0a025061667b26b6fcf56fe20f0afc;hp=8c57e377a8b288dc124828bdfa617cd7c222c3e3;hpb=59baa428fb2d9e7f0fe5423f4cea47f2d6245914;p=sixth-3d.git diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java index 8c57e37..9c0681c 100755 --- a/src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/gui/ViewPanel.java @@ -1,12 +1,7 @@ /* - * Sixth 3D engine. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 3 of the GNU Lesser General Public License - * or later as published by the Free Software Foundation. - * + * Sixth 3D engine. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. */ - package eu.svjatoslav.sixth.e3d.gui; import eu.svjatoslav.sixth.e3d.gui.humaninput.HIDInputTracker; @@ -26,12 +21,12 @@ import java.util.concurrent.ConcurrentHashMap; */ public class ViewPanel extends JPanel implements ComponentListener { private static final long serialVersionUID = 1683277888885045387L; - public Color backgroundColor = Color.BLACK; private final HIDInputTracker HIDInputTracker = new HIDInputTracker(this); private final KeyboardFocusStack keyboardFocusStack; private final Avatar avatar = new Avatar(); private final ShapeCollection rootShapeCollection = new ShapeCollection(); private final Set viewRenderListeners = ConcurrentHashMap.newKeySet(); + public Color backgroundColor = Color.BLACK; /** * Last time this view was updated. */ @@ -39,11 +34,13 @@ public class ViewPanel extends JPanel implements ComponentListener { private Timer canvasUpdateTimer; private ViewUpdateTimerTask canvasUpdateTimerTask; private RenderingContext renderingContext = null; + /** - * Currently target FPS for this view. It can be changed at runtime. Also when nothing - * changes in the view, then frames are not really repainted. + * Currently target frames per second rate for this view. Target FPS can be changed at runtime. + * 3D engine tries to be smart and only repaints screen when there are visible changes. */ - private int targetFPS = 30; + private int targetFPS = 60; + /** * Set to true if it is known than next frame reeds to be painted. Flag is cleared * immediately after frame got updated. @@ -209,7 +206,7 @@ public class ViewPanel extends JPanel implements ComponentListener { // abort rendering if window size is invalid if ((getWidth() > 0) && (getHeight() > 0) && renderFrame) { renderFrame(); - viewRepaintNeeded = renderingContext.handleDetectedComponentMouseEvents(); + viewRepaintNeeded = renderingContext.handlePossibleComponentMouseEvent(); } } @@ -218,7 +215,7 @@ public class ViewPanel extends JPanel implements ComponentListener { int panelWidth = getWidth(); int panelHeight = getHeight(); - if (panelWidth <= 0 || panelHeight <=0){ + if (panelWidth <= 0 || panelHeight <= 0) { renderingContext = null; return; }