transform added
This commit is contained in:
parent
e241c7c9b1
commit
2570553b93
@ -7,9 +7,11 @@ out vec3 ourColor;
|
|||||||
out vec2 TexCoord;
|
out vec2 TexCoord;
|
||||||
out vec4 position;
|
out vec4 position;
|
||||||
|
|
||||||
|
uniform mat4 transform;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = vec4(aPos, 1.0);
|
gl_Position = transform * vec4(aPos, 1.0);
|
||||||
ourColor = aColor;
|
ourColor = aColor;
|
||||||
TexCoord = aTexCoord;
|
TexCoord = aTexCoord;
|
||||||
position = gl_Position;
|
position = gl_Position;
|
||||||
|
@ -3,6 +3,7 @@ package engine;
|
|||||||
import engine.graphics.Shader;
|
import engine.graphics.Shader;
|
||||||
import engine.graphics.Texture;
|
import engine.graphics.Texture;
|
||||||
import engine.graphics.VertexArray;
|
import engine.graphics.VertexArray;
|
||||||
|
import engine.math.Matrix4f;
|
||||||
|
|
||||||
public class Scene {
|
public class Scene {
|
||||||
|
|
||||||
@ -14,6 +15,8 @@ public class Scene {
|
|||||||
Texture texture_map2;
|
Texture texture_map2;
|
||||||
byte[] indices;
|
byte[] indices;
|
||||||
|
|
||||||
|
Matrix4f transform;
|
||||||
|
|
||||||
VertexArray vertexArray;
|
VertexArray vertexArray;
|
||||||
Shader shader;
|
Shader shader;
|
||||||
|
|
||||||
@ -36,9 +39,13 @@ public class Scene {
|
|||||||
this.vertexArray = new VertexArray(this.vertices, this.indices, this.color, this.texture);
|
this.vertexArray = new VertexArray(this.vertices, this.indices, this.color, this.texture);
|
||||||
shader.setUniform1i("texture1", 0);
|
shader.setUniform1i("texture1", 0);
|
||||||
shader.setUniform1i("texture2", 1);
|
shader.setUniform1i("texture2", 1);
|
||||||
|
this.transform = Matrix4f.rotateZ(3.14f/2.0f);
|
||||||
|
shader.setUniformMat4f("transform", this.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(){
|
public void render(){
|
||||||
|
// this.transform = this.transform.multiply(Matrix4f.rotateZ(0.001f));
|
||||||
|
shader.setUniformMat4f("transform", this.transform);
|
||||||
this.shader.enable();
|
this.shader.enable();
|
||||||
this.texture_map.bind();
|
this.texture_map.bind();
|
||||||
this.texture_map2.bind();
|
this.texture_map2.bind();
|
||||||
|
@ -88,7 +88,7 @@ public class Matrix4f {
|
|||||||
result.elements[1 + 0 * 4] = -sin;
|
result.elements[1 + 0 * 4] = -sin;
|
||||||
|
|
||||||
result.elements[0 + 1 * 4] = sin;
|
result.elements[0 + 1 * 4] = sin;
|
||||||
result.elements[2 + 1 * 4] = cos;
|
result.elements[1 + 1 * 4] = cos;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user