Made PerspectiveCamera react to Display events.
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.terasology.config.RenderingConfig;
+import org.terasology.engine.subsystem.DisplayDevice;
import org.terasology.math.MatrixUtils;
import org.terasology.math.TeraMath;
import org.terasology.math.geom.Matrix4f;
import org.terasology.math.geom.Vector3f;
+import org.terasology.registry.CoreRegistry;
import org.terasology.rendering.nui.layers.mainMenu.videoSettings.CameraSetting;
import org.terasology.world.WorldProvider;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.Deque;
import java.util.LinkedList;
/**
* Simple default camera.
*/
-public class PerspectiveCamera extends SubmersibleCamera {
+public class PerspectiveCamera extends SubmersibleCamera implements PropertyChangeListener {
// Values used for smoothing
private Deque<Vector3f> previousPositions = new LinkedList<>();
private Deque<Vector3f> previousViewingDirections = new LinkedList<>();
public PerspectiveCamera(WorldProvider worldProvider, RenderingConfig renderingConfig) {
super(worldProvider, renderingConfig);
this.cameraSettings = renderingConfig.getCameraSettings();
+ DisplayDevice display = CoreRegistry.get(DisplayDevice.class);
+ display.subscribe(this);
}
@Override
@@ -189,4 +195,10 @@ private static Matrix4f createPerspectiveProjectionMatrix(float fov, float zNear
return MatrixUtils.createPerspectiveProjectionMatrix(fovY, aspectRatio, zNear, zFar);
}
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (evt.getPropertyName().equals("displayResolution")) {
+ createPerspectiveProjectionMatrix(cachedFov, zNear, zFar);
+ }
+ }
}
