added ObjectGlTexColor, tweaked shaders
This commit is contained in:
@ -2,6 +2,7 @@ package engine;
|
||||
|
||||
import engine.math.Vector3f;
|
||||
import engine.object.ObjectGl;
|
||||
import engine.object.ObjectGlColor;
|
||||
import org.lwjgl.glfw.GLFWFramebufferSizeCallback;
|
||||
import org.lwjgl.glfw.GLFWVidMode;
|
||||
import org.lwjgl.opengl.GL;
|
||||
@ -131,7 +132,7 @@ public class Engine {
|
||||
engine.init();
|
||||
|
||||
// Add objects to render
|
||||
ObjectGl cube = new ObjectGl(-0.5f,0.5f,0.0f,1.0f,1.0f);
|
||||
ObjectGl cube = new ObjectGlColor(-0.5f,0.5f,0.0f,1.0f,1.0f, new float[] {0.2f, 0.2f, 0.8f});
|
||||
engine.add_objectGl(cube);
|
||||
|
||||
while(engine.isRunning()){
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user