added ObjectGlTexColor, tweaked shaders

This commit is contained in:
Antoine
2021-05-19 05:37:45 +02:00
parent 58e94314cc
commit 7f491ad597
10 changed files with 51 additions and 33 deletions

View File

@ -6,18 +6,10 @@ import engine.graphics.VertexArray;
import engine.math.Matrix4f;
public class ObjectGlColor extends ObjectGl{
public ObjectGlColor(float x, float y, float z, float h, float w, float[] color) {
super();
this.vertexArray = new VertexArray(Primitive.createRectangle(x, y, z, h, w), Primitive.rectangle_indices, color, null);
this.transform = Matrix4f.identity();
this.shader = new Shader("shaders/ObjectGlColor/vert.glsl","shaders/ObjectGlColor/frag.glsl");
}
@Override
public void render() {
this.shader.enable();
this.vertexArray.render();
this.shader.disable();
}
}

View File

@ -10,7 +10,7 @@ import java.util.List;
public class ObjectGlTex extends ObjectGl{
List<Texture> textures;
protected List<Texture> textures;
public ObjectGlTex(){
@ -22,13 +22,29 @@ public class ObjectGlTex extends ObjectGl{
this.transform = Matrix4f.identity();
this.shader = new Shader("shaders/ObjectGlTex/vert.glsl","shaders/ObjectGlTex/frag.glsl");
// TODO tex
int count = 0;
for (String path : texPath){
textures.add(new Texture(path, count));
count++;
}
}
@Override
public void render() {
this.shader.enable();
this.shader.setUniformMat4f("transform", this.transform);
for (Texture t : textures){
t.bind();
}
this.vertexArray.render();
for (Texture t : textures){
t.unbind();
}
this.shader.disable();
}
}

View File

@ -1,5 +1,6 @@
package engine.object;
import engine.graphics.Texture;
import engine.math.Primitive;
import engine.graphics.Shader;
import engine.graphics.VertexArray;
@ -15,6 +16,10 @@ public class ObjectGlTexColor extends ObjectGlTex{
this.transform = Matrix4f.identity();
this.shader = new Shader("shaders/ObjectGlTexColor/vert.glsl","shaders/ObjectGlTexColor/frag.glsl");
// TODO Create texture
int count = 0;
for (String path : texPath){
textures.add(new Texture(path, count));
count++;
}
}
}