Implementing Zooming
This commit is contained in:
parent
7edcda998c
commit
7acf9fd703
@ -9,9 +9,7 @@ import core.engine.renderer.MasterRenderer;
|
|||||||
import core.engine.terrain.Terrain;
|
import core.engine.terrain.Terrain;
|
||||||
import core.engine.textures.ModelTexture;
|
import core.engine.textures.ModelTexture;
|
||||||
import org.lwjgl.Version;
|
import org.lwjgl.Version;
|
||||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
import org.lwjgl.glfw.*;
|
||||||
import org.lwjgl.glfw.GLFWKeyCallback;
|
|
||||||
import org.lwjgl.glfw.GLFWVidMode;
|
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
import org.lwjgl.system.MemoryStack;
|
import org.lwjgl.system.MemoryStack;
|
||||||
import utils.vectors.Vector3f;
|
import utils.vectors.Vector3f;
|
||||||
@ -113,6 +111,19 @@ public class Engine {
|
|||||||
// Set the clear color
|
// Set the clear color
|
||||||
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
|
||||||
Camera camera = new Camera();
|
Camera camera = new Camera();
|
||||||
|
|
||||||
|
GLFWScrollCallback glfwScrollCallback = new GLFWScrollCallback() {
|
||||||
|
@Override
|
||||||
|
public void invoke(long window, double xOffset, double yOffset) {
|
||||||
|
if(yOffset > 0) {
|
||||||
|
camera.zoomIn();
|
||||||
|
} else if(yOffset < 0) {
|
||||||
|
camera.zoomOut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
glfwSetScrollCallback(window, glfwScrollCallback);
|
||||||
glfwSetKeyCallback(window, glfwKeyCallback = new GLFWKeyCallback() {
|
glfwSetKeyCallback(window, glfwKeyCallback = new GLFWKeyCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(long window, int key, int scancode, int action, int mods) {
|
public void invoke(long window, int key, int scancode, int action, int mods) {
|
||||||
|
@ -25,6 +25,14 @@ public class Camera {
|
|||||||
position.x -= .5f;
|
position.x -= .5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void zoomOut() {
|
||||||
|
position.y += 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void zoomIn() {
|
||||||
|
position.y -= 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3f getPosition() {
|
public Vector3f getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user