still trying to debug why it isn't rendering
This commit is contained in:
1 parent
e71a1a9b0b
commit
8da13e805b
5 files changed
+18
-4
No files matched your search
@@ -1,11 +1,15 @@
|
||||
package org.xfe.engine;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Entity
|
||||
{
|
||||
Mesh mesh;
|
||||
|
||||
public Matrix4f model;
|
||||
|
||||
public ShaderProgram shader;
|
||||
|
||||
public Entity(String object_file_path, String fragment_shader_path, String vertex_shader_path)
|
||||
@@ -47,6 +51,7 @@ public class Entity
|
||||
|
||||
try {
|
||||
shader.createUniform("projection");
|
||||
shader.createUniform("model");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.InputStream;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
@@ -95,6 +96,8 @@ public class Mesh {
|
||||
|
||||
// OBJ File has been read, setup openGL buffers
|
||||
init();
|
||||
|
||||
System.out.println(Arrays.toString(this.vertices));
|
||||
}
|
||||
|
||||
private void init() {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Render {
|
||||
public void render(Window window, World world) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glfwSwapBuffers(window.getWindowHandle());
|
||||
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
float aspect_ratio = (float) window.getWidth() / window.getHeight();
|
||||
projection_matrix = new Matrix4f().perspective(Engine.FOV, aspect_ratio, Engine.Z_FAR, Engine.Z_NEAR);
|
||||
@@ -32,6 +32,7 @@ public class Render {
|
||||
entity.shader.bind();
|
||||
|
||||
entity.shader.setUniform("projection", projection_matrix);
|
||||
entity.shader.setUniform("model", entity.model);
|
||||
// entity.shader.setUniform("model", new Matrix4f().identity());
|
||||
// entity.shader.setUniform("view", new Matrix4f().identity());
|
||||
// entity.shader.setUniform("lightPos", world.lights.get(0).position);
|
||||
@@ -41,10 +42,12 @@ public class Render {
|
||||
// entity.shader.setUniform("viewPos", new Vector3f(0.0f, 0.0f, 0.0f));
|
||||
|
||||
|
||||
glBindVertexArray(entity.mesh.ebo_id);
|
||||
glBindVertexArray(entity.mesh.vao_id);
|
||||
glEnableVertexAttribArray(0);
|
||||
// glEnableVertexAttribArray(1);
|
||||
glDrawElements(GL_TRIANGLES, entity.mesh.vertice_indices.length, GL_UNSIGNED_INT, 0);
|
||||
}
|
||||
|
||||
// glfwSwapBuffers(window.getWindowHandle());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.xfe.game;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.xfe.engine.*;
|
||||
|
||||
public class Main implements GameLogic {
|
||||
@@ -18,6 +19,8 @@ public class Main implements GameLogic {
|
||||
@Override
|
||||
public void init(Window window, World world, Render render) {
|
||||
Entity cube = new Entity("/objs/cube.obj", "/shaders/shader.frag", "/shaders/shader.vert");
|
||||
cube.model = new Matrix4f().identity().translate(0, 0, -10);
|
||||
System.out.println(cube.model.toString());
|
||||
world.addEntity(cube);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user