aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-24 21:04:38 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-24 21:04:38 +0000
commit16915d86d4b866c1fcce7523b0d34e8343ff52fc (patch)
treefdc07bff71840f7336ed5d2e751155635e8ff96a /examples
parentddd26ed83d3ac0335562f762ced273a1d62bd959 (diff)
downloadYAGE-16915d86d4b866c1fcce7523b0d34e8343ff52fc.tar.gz
YAGE-16915d86d4b866c1fcce7523b0d34e8343ff52fc.zip
[Code] Simple game example furthered
Diffstat (limited to 'examples')
-rw-r--r--examples/resources/breast_black.pngbin0 -> 225 bytes
-rw-r--r--examples/resources/dngn_blood_fountain.png (renamed from examples/simplegame/dngn_blood_fountain.png)bin955 -> 955 bytes
-rw-r--r--examples/resources/textureshader.frag (renamed from examples/simplegame/textureshader.frag)0
-rw-r--r--examples/resources/textureshader.vert (renamed from examples/simplegame/textureshader.vert)0
-rw-r--r--examples/simplegame/main.cpp32
5 files changed, 21 insertions, 11 deletions
diff --git a/examples/resources/breast_black.png b/examples/resources/breast_black.png
new file mode 100644
index 00000000..180b292f
--- /dev/null
+++ b/examples/resources/breast_black.png
Binary files differ
diff --git a/examples/simplegame/dngn_blood_fountain.png b/examples/resources/dngn_blood_fountain.png
index 7214fd47..7214fd47 100644
--- a/examples/simplegame/dngn_blood_fountain.png
+++ b/examples/resources/dngn_blood_fountain.png
Binary files differ
diff --git a/examples/simplegame/textureshader.frag b/examples/resources/textureshader.frag
index ef728b04..ef728b04 100644
--- a/examples/simplegame/textureshader.frag
+++ b/examples/resources/textureshader.frag
diff --git a/examples/simplegame/textureshader.vert b/examples/resources/textureshader.vert
index 3277d8b0..3277d8b0 100644
--- a/examples/simplegame/textureshader.vert
+++ b/examples/resources/textureshader.vert
diff --git a/examples/simplegame/main.cpp b/examples/simplegame/main.cpp
index a631e45b..06200661 100644
--- a/examples/simplegame/main.cpp
+++ b/examples/simplegame/main.cpp
@@ -17,17 +17,19 @@ using namespace yage;
int main()
{
Window window;
- GlslProgram program;
+ GlslProgram textureProgram;
window.create("Simple Game", 800, 640);
SpriteBatch sp;
- program.compileShadersFromFile("examples/simplegame/textureshader.vert",
- "examples/simplegame/textureshader.frag");
- program.linkShaders();
+ textureProgram.compileShadersFromFile("examples/resources/textureshader.vert",
+ "examples/resources/textureshader.frag");
+ textureProgram.linkShaders();
Texture fountain = ResourceManager::getTexture(
- "examples/simplegame/dngn_blood_fountain.png");
+ "examples/resources/dngn_blood_fountain.png");
+ Texture breast_plate =
+ ResourceManager::getTexture("examples/resources/breast_black.png");
cout << "texture: " << fountain.width << ", " << fountain.height << '\n';
@@ -35,23 +37,31 @@ int main()
while (!window.shouldClose()) {
window.clearBuffer();
+ Texture texture = fountain;
- program.use();
- camera.update(program);
+ window.pollEvents();
+ if (window.keyPressed(yage::key::SPACE)) {
+ cout << "Pressed A" << '\n';
+ }
+ if (window.keyPressed(yage::key::E)) {
+ texture = breast_plate;
+ }
+
+ textureProgram.use();
+ camera.update(textureProgram);
glActiveTexture(GL_TEXTURE0);
- GLint texture_location = program.getUniformLocation("texture_sampler");
+ GLint texture_location = textureProgram.getUniformLocation("texture_sampler");
glUniform1i(texture_location, 0);
- sp.draw({0.f, 0.f, 64.f, 64.f}, {0, 0, 1, 1}, fountain.id,
+ sp.draw({0.f, 0.f, 64.f, 64.f}, {0, 0, 1, 1}, texture.id,
Colour(255, 0, 255, 255), 0);
sp.render();
glBindTexture(GL_TEXTURE_2D, 0);
- program.unuse();
+ textureProgram.unuse();
window.swapBuffer();
- window.pollEvents();
}
}