From db6480dccd9a3dbf4100a824930a36251f4e743c Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 5 Jan 2018 15:56:35 +0000 Subject: [Engine] Log levels added to engine. --- examples/resources/textureshader.frag | 2 +- examples/simplegame/main.cpp | 49 +++++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 12 deletions(-) (limited to 'examples') diff --git a/examples/resources/textureshader.frag b/examples/resources/textureshader.frag index 1292de96..ae12f4b0 100644 --- a/examples/resources/textureshader.frag +++ b/examples/resources/textureshader.frag @@ -12,5 +12,5 @@ void main() { vec4 texture_colour = texture(texture_sampler, fragment_uv); - colour = texture_colour; + colour = texture_colour * fragment_colour; } diff --git a/examples/simplegame/main.cpp b/examples/simplegame/main.cpp index bd5a05b9..ed6b78f3 100644 --- a/examples/simplegame/main.cpp +++ b/examples/simplegame/main.cpp @@ -8,6 +8,8 @@ #include +#include +#include #include using std::cout; @@ -16,6 +18,9 @@ using namespace yage; int main() { + + Logger logger; + srand(time(nullptr)); Window window; window.create("Simple Game", 1920, 1080); @@ -30,7 +35,7 @@ int main() Texture brick = ResourceManager::getTexture("examples/resources/wall.png"); - cout << "texture: " << brick.width << ", " << brick.height << '\n'; + yLogDebug << "texture: " << brick.width << ", " << brick.height; Camera camera(1920, 1080); textureProgram.use(); @@ -54,23 +59,45 @@ int main() if (window.keyPressed(yage::key::E)) { texture = breast_plate; } + if (window.keyPressed(yage::key::EQUAL)) { + camera.zoom(0.1f); + } + if (window.keyPressed(yage::key::MINUS)) { + camera.zoom(-0.1f); + } + if (window.keyPressed(yage::key::LEFT)) { + camera.move({-5.f, 0.f}); + } + if (window.keyPressed(yage::key::RIGHT)) { + camera.move({5.f, 0.f}); + } + if (window.keyPressed(yage::key::UP)) { + camera.move({0.f, 5.f}); + } + if (window.keyPressed(yage::key::DOWN)) { + camera.move({0.f, -5.f}); + } camera.update(textureProgram); - int amount = 5; - time = glfwGetTime(); - for (int i = 0; i < 1920/amount; i++) { - for(int j = 0; j < 1080/amount; j++) - sp.draw({(float)(amount*i), (float)(amount*j), (float)amount, (float)amount}, {0.f, 0.f, 1.f, 1.f}, fountain.id, - Colour(255, 255, 255, 255), 0); + int amount = 10; + time = glfwGetTime(); + for (int i = 0; i < 1920 / amount; i++) { + for (int j = 0; j < 1080 / amount; j++) + sp.draw({(float)(amount * i), (float)(amount * j), + (float)amount, (float)amount}, + {0.f, 0.f, 1.f, 1.f}, texture.id, + Colour(rand() % 256, rand() % 256, rand() % 256, 255), + 0); } - sp.draw({50, 50, 100, 100}, {0, 0, 1, 1}, brick.id, Colour(255, 255, 255, 255), 1); - yLog << "draw: " << glfwGetTime() - time; + sp.draw({50, 50, 100, 100}, {0, 0, 1, 1}, brick.id, + Colour(255, 255, 255, 255), 1); + yLogDebug << "draw: " << glfwGetTime() - time; time = glfwGetTime(); sp.render(); - yLog << "render: " << glfwGetTime() - time; + yLogDebug << "render: " << glfwGetTime() - time; window.swapBuffer(); if (i == 0) { @@ -78,7 +105,7 @@ int main() diff = final_time - prev_time; prev_time = final_time; fps = 1 / diff * 30; - yLog << "fps: " << fps; + yLogInfo << "fps: " << fps; } i = (i + 1) % 30; } -- cgit