diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-12-24 21:04:38 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-12-24 21:04:38 +0000 |
commit | 16915d86d4b866c1fcce7523b0d34e8343ff52fc (patch) | |
tree | fdc07bff71840f7336ed5d2e751155635e8ff96a /examples | |
parent | ddd26ed83d3ac0335562f762ced273a1d62bd959 (diff) | |
download | YAGE-16915d86d4b866c1fcce7523b0d34e8343ff52fc.tar.gz YAGE-16915d86d4b866c1fcce7523b0d34e8343ff52fc.zip |
[Code] Simple game example furthered
Diffstat (limited to 'examples')
-rw-r--r-- | examples/resources/breast_black.png | bin | 0 -> 225 bytes | |||
-rw-r--r-- | examples/resources/dngn_blood_fountain.png (renamed from examples/simplegame/dngn_blood_fountain.png) | bin | 955 -> 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.cpp | 32 |
5 files changed, 21 insertions, 11 deletions
diff --git a/examples/resources/breast_black.png b/examples/resources/breast_black.png Binary files differnew file mode 100644 index 00000000..180b292f --- /dev/null +++ b/examples/resources/breast_black.png diff --git a/examples/simplegame/dngn_blood_fountain.png b/examples/resources/dngn_blood_fountain.png Binary files differindex 7214fd47..7214fd47 100644 --- a/examples/simplegame/dngn_blood_fountain.png +++ b/examples/resources/dngn_blood_fountain.png 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(); } } |