massive refactor
This commit is contained in:
1 parent
26c0f433ae
commit
e71a1a9b0b
14 files changed
+442
-275
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package org.xfe.engine;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.GL20.*;
|
||||
import static org.lwjgl.opengl.GL30.*;
|
||||
|
||||
public class Render {
|
||||
|
||||
private Matrix4f projection_matrix;
|
||||
public Render() {
|
||||
GL.createCapabilities();
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
// Nothing to be done here yet
|
||||
}
|
||||
|
||||
public void render(Window window, World world) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window.getWindowHandle());
|
||||
|
||||
float aspect_ratio = (float) window.getWidth() / window.getHeight();
|
||||
projection_matrix = new Matrix4f().perspective(Engine.FOV, aspect_ratio, Engine.Z_FAR, Engine.Z_NEAR);
|
||||
|
||||
for (Entity entity : world.entities) {
|
||||
entity.shader.bind();
|
||||
|
||||
entity.shader.setUniform("projection", projection_matrix);
|
||||
// entity.shader.setUniform("model", new Matrix4f().identity());
|
||||
// entity.shader.setUniform("view", new Matrix4f().identity());
|
||||
// entity.shader.setUniform("lightPos", world.lights.get(0).position);
|
||||
// entity.shader.setUniform("light_power", world.lights.get(0).power);
|
||||
// entity.shader.setUniform("lightColor", world.lights.get(0).color);
|
||||
// entity.shader.setUniform("objectColor", new Vector3f(1.0f, 1.0f, 1.0f));
|
||||
// entity.shader.setUniform("viewPos", new Vector3f(0.0f, 0.0f, 0.0f));
|
||||
|
||||
|
||||
glBindVertexArray(entity.mesh.ebo_id);
|
||||
glEnableVertexAttribArray(0);
|
||||
// glEnableVertexAttribArray(1);
|
||||
glDrawElements(GL_TRIANGLES, entity.mesh.vertice_indices.length, GL_UNSIGNED_INT, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user