Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
More rendering progress. Added a (temporary?) basic smooth floor texture
- Loading branch information
Showing
9 changed files
with
170 additions
and
12 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) out vec4 color; | ||
|
||
in DATA | ||
{ | ||
vec2 tc; | ||
vec3 position; | ||
} fs_in; | ||
|
||
uniform vec2 player; | ||
uniform sampler2D tex; | ||
|
||
void main() | ||
{ | ||
color = texture(tex, fs_in.tc); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) in vec4 position; | ||
layout (location = 1) in vec2 tc; | ||
|
||
uniform mat4 pr_matrix; | ||
uniform mat4 vw_matrix; | ||
|
||
out DATA | ||
{ | ||
vec2 tc; | ||
vec3 position; | ||
} | ||
|
||
void main() | ||
{ | ||
gl_Position = pr_matrix * vw_matrix * position; | ||
vs_out.tc = tc; | ||
vs_out.position = vec3(vw_matrix * position); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,58 @@ | ||
package game.level; | ||
|
||
public class Level { | ||
import game.graphics.Shader; | ||
import game.graphics.Texture; | ||
import game.graphics.VertexArray; | ||
|
||
public class Level { | ||
|
||
private int width, height; | ||
// private VertexArray[][] tiles; | ||
// private Texture[][] tileTextures; | ||
|
||
private VertexArray tile; | ||
private Texture tileTexture; | ||
|
||
public Level() { | ||
float[] vertices = new float[] { | ||
-10.0f, -10.0f * 9.0f / 16.0f, 0.0f, | ||
-10.0f, 10.0f * 9.0f / 16.0f, 0.0f, | ||
0.0f, 10.0f * 9.0f / 16.0f, 0.0f, | ||
0.0f, -10.0f * 9.0f / 16.0f, 0.0f, | ||
}; | ||
|
||
byte[] indices = new byte[] { | ||
0, 1, 2, | ||
2, 3, 0 | ||
}; | ||
|
||
float[] tcs = new float[] { | ||
0, 1, | ||
0, 0, | ||
1, 0, | ||
1, 1 | ||
}; | ||
|
||
// width = 20; | ||
// height = 20; | ||
// tiles = new VertexArray[width][height]; | ||
// tileTextures = new Texture[width][height]; | ||
|
||
tile = new VertexArray(vertices, indices, tcs); | ||
tileTexture = new Texture("res/SmoothFloor.png"); | ||
} | ||
|
||
public void update() { | ||
|
||
// player update | ||
// tile update | ||
} | ||
|
||
public void render() { | ||
|
||
tileTexture.bind(); | ||
Shader.SMOOTH_FLOOR.enable(); | ||
Shader.SMOOTH_FLOOR.setUniform2f("player", 0, 0); | ||
tile.bind(); | ||
Shader.SMOOTH_FLOOR.disable(); | ||
tileTexture.unbind(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package game.level.tiles; | ||
|
||
import game.graphics.Texture; | ||
import game.graphics.VertexArray; | ||
|
||
public class SmoothFloor extends Tile{ | ||
|
||
public SmoothFloor() { | ||
super(); | ||
texture = new Texture("/res/SmoothFloor.png"); | ||
} | ||
|
||
@Override | ||
public void render() { | ||
// TODO Auto-generated method stub | ||
texture.bind(); | ||
|
||
} | ||
|
||
@Override | ||
public void update() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package game.level.tiles; | ||
|
||
import game.graphics.Texture; | ||
import game.graphics.VertexArray; | ||
|
||
public abstract class Tile { | ||
|
||
protected final float SIZE = 1.0f; | ||
protected Texture texture; | ||
protected VertexArray vertexArray; | ||
protected float[] vertices; | ||
protected byte[] indices; | ||
protected float[] textureCoords; | ||
|
||
|
||
protected Tile() { | ||
vertices = new float[] { | ||
-SIZE / 2.0f, -SIZE / 2.0f, 0.0f, | ||
-SIZE / 2.0f, SIZE / 2.0f, 0.0f, | ||
SIZE / 2.0f, SIZE / 2.0f, 0.0f, | ||
SIZE / 2.0f, -SIZE / 2.0f, 0.0f, | ||
}; | ||
|
||
indices = new byte[] { | ||
0, 1, 2, | ||
2, 3, 0 | ||
}; | ||
|
||
textureCoords = new float[] { | ||
0, 1, | ||
0, 0, | ||
1, 0, | ||
1, 1 | ||
}; | ||
|
||
} | ||
|
||
public abstract void update(); | ||
|
||
public abstract void render(); | ||
|
||
} |