Fixed rendering! Changed GL_FLAT to GL_FLOAT in ObjectLoader as it was a typo.
This commit is contained in:
parent
dcd1307a71
commit
51218fd182
3 changed files with 14 additions and 4 deletions
|
@ -35,19 +35,26 @@ public class ObjectLoader {
|
|||
|
||||
private void storeIndicesBuffer(int[] indices) {
|
||||
int vbo = GL15.glGenBuffers();
|
||||
|
||||
vbos.add(vbo);
|
||||
|
||||
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vbo);
|
||||
|
||||
IntBuffer buffer = Utils.storeDataInIntBuffer(indices);
|
||||
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
private void storeDataInAttributeList(int attributeNumber, int vertexCount, float[] data) {
|
||||
int vbo = GL15.glGenBuffers();
|
||||
|
||||
vbos.add(vbo);
|
||||
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
|
||||
|
||||
FloatBuffer buffer = Utils.storeDataInFloatBuffer(data);
|
||||
|
||||
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
|
||||
GL20.glVertexAttribPointer(attributeNumber, vertexCount, GL11.GL_FLAT, false, 0, 0);
|
||||
GL20.glVertexAttribPointer(attributeNumber, vertexCount, GL11.GL_FLOAT, false, 0, 0);
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public class RenderManager {
|
|||
GL30.glBindVertexArray(model.getId());
|
||||
GL20.glEnableVertexAttribArray(0);
|
||||
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, model.getVertexCount());
|
||||
|
||||
GL20.glDisableVertexAttribArray(0);
|
||||
GL30.glBindVertexArray(0);
|
||||
|
||||
|
|
|
@ -25,10 +25,12 @@ public class Utils {
|
|||
|
||||
public static String loadResource(String filename) throws Exception {
|
||||
String result;
|
||||
try (InputStream in = Utils.class.getResourceAsStream(filename);
|
||||
Scanner scanner = new Scanner(in, StandardCharsets.UTF_8.name())) {
|
||||
try (InputStream in = Utils.class.getResourceAsStream(filename)) {
|
||||
assert in != null;
|
||||
try (Scanner scanner = new Scanner(in, StandardCharsets.UTF_8)) {
|
||||
result = scanner.useDelimiter("\\A").next();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue