aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-22 21:16:02 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-22 21:19:21 +0000
commitfb8197839c0bebc20fd68ee3f280da934c49c473 (patch)
treee4ccb024144cb5b41f9e572984e3278c2b0b51d0 /examples
parentd6b25272499352383214c738faa8ce1870df37f3 (diff)
downloadYAGE-fb8197839c0bebc20fd68ee3f280da934c49c473.tar.gz
YAGE-fb8197839c0bebc20fd68ee3f280da934c49c473.zip
Removing editor and refactoring code.
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt2
-rw-r--r--examples/simplegame/dngn_blood_fountain.pngbin0 -> 955 bytes
-rw-r--r--examples/simplegame/main.cpp13
-rw-r--r--examples/simplegame/textureshader.frag16
-rw-r--r--examples/simplegame/textureshader.vert23
5 files changed, 48 insertions, 6 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
new file mode 100644
index 00000000..16b20795
--- /dev/null
+++ b/examples/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(simplegame simplegame/main.cpp)
+target_link_libraries(simplegame yage)
diff --git a/examples/simplegame/dngn_blood_fountain.png b/examples/simplegame/dngn_blood_fountain.png
new file mode 100644
index 00000000..7214fd47
--- /dev/null
+++ b/examples/simplegame/dngn_blood_fountain.png
Binary files differ
diff --git a/examples/simplegame/main.cpp b/examples/simplegame/main.cpp
index 04d63ec0..a631e45b 100644
--- a/examples/simplegame/main.cpp
+++ b/examples/simplegame/main.cpp
@@ -22,16 +22,16 @@ int main()
window.create("Simple Game", 800, 640);
SpriteBatch sp;
- program.compileShadersFromFile("resources/textureshader.vert", "resources/textureshader.frag");
+ program.compileShadersFromFile("examples/simplegame/textureshader.vert",
+ "examples/simplegame/textureshader.frag");
program.linkShaders();
- Texture fountain =
- ResourceManager::getTexture("/home/yannherklotz/Github/YAGE/tests/"
- "resources/dngn_blood_fountain.png");
+ Texture fountain = ResourceManager::getTexture(
+ "examples/simplegame/dngn_blood_fountain.png");
cout << "texture: " << fountain.width << ", " << fountain.height << '\n';
- Camera2D camera(800, 640);
+ Camera camera(800, 640);
while (!window.shouldClose()) {
window.clearBuffer();
@@ -44,7 +44,8 @@ int main()
GLint texture_location = program.getUniformLocation("texture_sampler");
glUniform1i(texture_location, 0);
- sp.draw({0.f, 0.f, 64.f, 64.f}, {0, 0, 1, 1}, fountain.id, Colour(255, 0, 255, 255), 0);
+ sp.draw({0.f, 0.f, 64.f, 64.f}, {0, 0, 1, 1}, fountain.id,
+ Colour(255, 0, 255, 255), 0);
sp.render();
glBindTexture(GL_TEXTURE_2D, 0);
diff --git a/examples/simplegame/textureshader.frag b/examples/simplegame/textureshader.frag
new file mode 100644
index 00000000..ef728b04
--- /dev/null
+++ b/examples/simplegame/textureshader.frag
@@ -0,0 +1,16 @@
+#version 450
+
+layout(location = 0) in vec2 fragment_position;
+layout(location = 1) in vec4 fragment_colour;
+layout(location = 2) in vec2 fragment_uv;
+
+out vec4 colour;
+
+uniform sampler2D texture_sampler;
+
+void main()
+{
+ vec4 texture_color = texture(texture_sampler, fragment_uv);
+
+ colour = texture_color * fragment_colour;
+}
diff --git a/examples/simplegame/textureshader.vert b/examples/simplegame/textureshader.vert
new file mode 100644
index 00000000..3277d8b0
--- /dev/null
+++ b/examples/simplegame/textureshader.vert
@@ -0,0 +1,23 @@
+#version 450
+
+layout(location = 0) in vec2 vertex_position;
+layout(location = 1) in vec4 vertex_colour;
+layout(location = 2) in vec2 vertex_uv;
+
+layout(location = 0) out vec2 fragment_position;
+layout(location = 1) out vec4 fragment_colour;
+layout(location = 2) out vec2 fragment_uv;
+
+uniform mat4 P;
+
+void main()
+{
+ gl_Position.xy = (P*vec4(vertex_position, 0.0, 1.0)).xy;
+ gl_Position.z = 0.0;
+ gl_Position.w = 1.0;
+
+ fragment_position = vertex_position;
+ fragment_colour = vertex_colour;
+ fragment_uv = vec2(vertex_uv.x, 1-vertex_uv.y);
+
+}