transform added

This commit is contained in:
Antoine 2021-05-17 14:53:16 +02:00
parent e241c7c9b1
commit 2570553b93
3 changed files with 11 additions and 2 deletions

View File

@ -7,9 +7,11 @@ out vec3 ourColor;
out vec2 TexCoord;
out vec4 position;
uniform mat4 transform;
void main()
{
gl_Position = vec4(aPos, 1.0);
gl_Position = transform * vec4(aPos, 1.0);
ourColor = aColor;
TexCoord = aTexCoord;
position = gl_Position;

View File

@ -3,6 +3,7 @@ package engine;
import engine.graphics.Shader;
import engine.graphics.Texture;
import engine.graphics.VertexArray;
import engine.math.Matrix4f;
public class Scene {
@ -14,6 +15,8 @@ public class Scene {
Texture texture_map2;
byte[] indices;
Matrix4f transform;
VertexArray vertexArray;
Shader shader;
@ -36,9 +39,13 @@ public class Scene {
this.vertexArray = new VertexArray(this.vertices, this.indices, this.color, this.texture);
shader.setUniform1i("texture1", 0);
shader.setUniform1i("texture2", 1);
this.transform = Matrix4f.rotateZ(3.14f/2.0f);
shader.setUniformMat4f("transform", this.transform);
}
public void render(){
// this.transform = this.transform.multiply(Matrix4f.rotateZ(0.001f));
shader.setUniformMat4f("transform", this.transform);
this.shader.enable();
this.texture_map.bind();
this.texture_map2.bind();

View File

@ -88,7 +88,7 @@ public class Matrix4f {
result.elements[1 + 0 * 4] = -sin;
result.elements[0 + 1 * 4] = sin;
result.elements[2 + 1 * 4] = cos;
result.elements[1 + 1 * 4] = cos;
return result;
}