<commit_before>package com.camilne.main;

import java.io.IOException;

import org.lwjgl.glfw.GLFW;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector2f;
import org.lwjgl.util.vector.Vector3f;

import com.camilne.app.Application;
import com.camilne.app.ApplicationConfiguration;
import com.camilne.app.ApplicationListener;
import com.camilne.app.Input;
import com.camilne.rendering.Camera;
import com.camilne.rendering.DirectionalLight;
import com.camilne.rendering.Mesh;
import com.camilne.rendering.PerspectiveCamera;
import com.camilne.rendering.PhongForwardShader;
import com.camilne.rendering.Shader;
import com.camilne.rendering.Texture;
import com.camilne.rendering.Vertex;
import com.camilne.world.World;

public class Main implements ApplicationListener{
    
    private PhongForwardShader mainShader;
    private Mesh testMesh;
    private PerspectiveCamera camera;
    private float speed;
    private float sensitivity;
    private Texture testTextureDiffuse;
    private DirectionalLight directionalLight;
    private World world;
    
    private Main() {
	mainShader = null;
	testMesh = null;
	camera = null;
	speed = 1f;
	sensitivity = 0.1f;
	testTextureDiffuse = null;
	directionalLight = null;
	world = null;
	
	ApplicationConfiguration config = new ApplicationConfiguration();
	config.width = 1280;
	config.height = 720;
	config.title = "OpenWorld - Demo";
	config.vSyncEnabled = true;
	
	Application app = new Application(this, config);
	try {
	    app.run();
	} catch(Exception e) {
	    e.printStackTrace();
	    System.exit(1);
	}
    }

    public static void main(String[] args) {
	new Main();
    }

    @Override
    public void create() {
	Shader.setPath("res/shaders/");
	Shader.setVertexExtension("vs");
	Shader.setFragmentExtension("fs");
	try {
	    mainShader = new PhongForwardShader("main");
	    mainShader.setUniform("m_model", new Matrix4f());
	} catch(IOException e) {
	    e.printStackTrace();
	    System.exit(1);
	}
	
	final Vertex testMeshVertices[] = {
		new Vertex(new Vector3f(0, 0, 0), new Vector2f(0, 0)),
		new Vertex(new Vector3f(1, 0, 0), new Vector2f(1, 0)),
		new Vertex(new Vector3f(1, 1, -0.5f), new Vector2f(1, 1)),
		new Vertex(new Vector3f(0, 1, -1), new Vector2f(0, 1)),
	};
	final int testMeshIndices[] = {
		0, 1, 2,
		2, 3, 0
	};
	Mesh.calculateNormals(testMeshVertices, testMeshIndices);
	testMesh = new Mesh(testMeshVertices, testMeshIndices);
	
	camera = new PerspectiveCamera(65.0f, 1280.0f/720.0f, 0.01f, 1000f);
	
	Texture.setPath("res/textures/");
	testTextureDiffuse = new Texture("test.png");
	
	directionalLight = new DirectionalLight(new Vector3f(-0.5f, -0.3f, -0.75f));
	
	world = new World();
    }

    @Override
    public void update(float delta) {
	final float speedThisFrame = speed * delta;
	
	// Move forward
	if (Input.isKeyPressed(GLFW.GLFW_KEY_W))
	    camera.move(Camera.Direction.FORWARD, speedThisFrame);
	// Move backward
	if (Input.isKeyPressed(GLFW.GLFW_KEY_S))
	    camera.move(Camera.Direction.BACKWARD, speedThisFrame);
	// Move right
	if (Input.isKeyPressed(GLFW.GLFW_KEY_D))
	    camera.move(Camera.Direction.RIGHT, speedThisFrame);
	// Move left
	if (Input.isKeyPressed(GLFW.GLFW_KEY_A))
	    camera.move(Camera.Direction.LEFT, speedThisFrame);
	// Move up
	if (Input.isKeyPressed(GLFW.GLFW_KEY_SPACE))
	    camera.move(Camera.AXIS_Y, speedThisFrame);
	// Move down
	if (Input.isKeyPressed(GLFW.GLFW_KEY_LEFT_SHIFT))
	    camera.move(Camera.AXIS_Y, -speedThisFrame);
	
	camera.update();
    }

    @Override
    public void render() {
	mainShader.bind();
	mainShader.update(camera, directionalLight);
	
	testTextureDiffuse.bind();
	testMesh.render();
	
	world.render(mainShader);
	mainShader.setUniform("m_model", new Matrix4f());
    }

    @Override
    public void dispose() {
	testTextureDiffuse.dispose();
    }

    @Override
    public void mouseMoved(double xpos, double ypos, double dx, double dy) {
	camera.rotateYAxis((float) (-dx * sensitivity));
	camera.rotateX((float) (-dy * sensitivity));
    }

    @Override
    public void keyPressed(int keycode) {
    }

    @Override
    public void keyReleased(int keycode) {
    }
<commit_msg>Added esc hotkey to quit application<commit_after>package com.camilne.main;

import java.io.IOException;

import org.lwjgl.glfw.GLFW;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector2f;
import org.lwjgl.util.vector.Vector3f;

import com.camilne.app.Application;
import com.camilne.app.ApplicationConfiguration;
import com.camilne.app.ApplicationListener;
import com.camilne.app.Input;
import com.camilne.rendering.Camera;
import com.camilne.rendering.DirectionalLight;
import com.camilne.rendering.Mesh;
import com.camilne.rendering.PerspectiveCamera;
import com.camilne.rendering.PhongForwardShader;
import com.camilne.rendering.Shader;
import com.camilne.rendering.Texture;
import com.camilne.rendering.Vertex;
import com.camilne.world.World;

public class Main implements ApplicationListener{
    
    private PhongForwardShader mainShader;
    private Mesh testMesh;
    private PerspectiveCamera camera;
    private float speed;
    private float sensitivity;
    private Texture testTextureDiffuse;
    private DirectionalLight directionalLight;
    private World world;
    
    private Main() {
	mainShader = null;
	testMesh = null;
	camera = null;
	speed = 1f;
	sensitivity = 0.1f;
	testTextureDiffuse = null;
	directionalLight = null;
	world = null;
	
	ApplicationConfiguration config = new ApplicationConfiguration();
	config.width = 1280;
	config.height = 720;
	config.title = "OpenWorld - Demo";
	config.vSyncEnabled = true;
	
	Application app = new Application(this, config);
	try {
	    app.run();
	} catch(Exception e) {
	    e.printStackTrace();
	    System.exit(1);
	}
    }

    public static void main(String[] args) {
	new Main();
    }

    @Override
    public void create() {
	Shader.setPath("res/shaders/");
	Shader.setVertexExtension("vs");
	Shader.setFragmentExtension("fs");
	try {
	    mainShader = new PhongForwardShader("main");
	    mainShader.setUniform("m_model", new Matrix4f());
	} catch(IOException e) {
	    e.printStackTrace();
	    System.exit(1);
	}
	
	final Vertex testMeshVertices[] = {
		new Vertex(new Vector3f(0, 0, 0), new Vector2f(0, 0)),
		new Vertex(new Vector3f(1, 0, 0), new Vector2f(1, 0)),
		new Vertex(new Vector3f(1, 1, -0.5f), new Vector2f(1, 1)),
		new Vertex(new Vector3f(0, 1, -1), new Vector2f(0, 1)),
	};
	final int testMeshIndices[] = {
		0, 1, 2,
		2, 3, 0
	};
	Mesh.calculateNormals(testMeshVertices, testMeshIndices);
	testMesh = new Mesh(testMeshVertices, testMeshIndices);
	
	camera = new PerspectiveCamera(65.0f, 1280.0f/720.0f, 0.01f, 1000f);
	
	Texture.setPath("res/textures/");
	testTextureDiffuse = new Texture("test.png");
	
	directionalLight = new DirectionalLight(new Vector3f(-0.5f, -0.3f, -0.75f));
	
	world = new World();
    }

    @Override
    public void update(float delta) {
	final float speedThisFrame = speed * delta;
	
	// Move forward
	if (Input.isKeyPressed(GLFW.GLFW_KEY_W))
	    camera.move(Camera.Direction.FORWARD, speedThisFrame);
	// Move backward
	if (Input.isKeyPressed(GLFW.GLFW_KEY_S))
	    camera.move(Camera.Direction.BACKWARD, speedThisFrame);
	// Move right
	if (Input.isKeyPressed(GLFW.GLFW_KEY_D))
	    camera.move(Camera.Direction.RIGHT, speedThisFrame);
	// Move left
	if (Input.isKeyPressed(GLFW.GLFW_KEY_A))
	    camera.move(Camera.Direction.LEFT, speedThisFrame);
	// Move up
	if (Input.isKeyPressed(GLFW.GLFW_KEY_SPACE))
	    camera.move(Camera.AXIS_Y, speedThisFrame);
	// Move down
	if (Input.isKeyPressed(GLFW.GLFW_KEY_LEFT_SHIFT))
	    camera.move(Camera.AXIS_Y, -speedThisFrame);
	
	camera.update();
    }

    @Override
    public void render() {
	mainShader.bind();
	mainShader.update(camera, directionalLight);
	
	testTextureDiffuse.bind();
	testMesh.render();
	
	world.render(mainShader);
	mainShader.setUniform("m_model", new Matrix4f());
    }

    @Override
    public void dispose() {
	testTextureDiffuse.dispose();
    }

    @Override
    public void mouseMoved(double xpos, double ypos, double dx, double dy) {
	camera.rotateYAxis((float) (-dx * sensitivity));
	camera.rotateX((float) (-dy * sensitivity));
    }

    @Override
    public void keyPressed(int keycode) {
	if(keycode == GLFW.GLFW_KEY_ESCAPE)
	    System.exit(0);
    }

    @Override
    public void keyReleased(int keycode) {
    }

{'fraction_non_alphanumeric': 0.12382761486406269, 'fraction_numerical': 0.018876884720408407, 'mean_word_length': 4.1054545454545455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5262117', 'n_tokens_mistral': 3057, 'n_tokens_neox': 2879, 'n_words': 598}