aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simplegame
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-31 18:00:01 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-31 18:00:01 +0000
commit34908f108ad7c2ee6cff96491a0bc40381477424 (patch)
treef58c6bdde485d07a7136f78055240bab923bd4a6 /examples/simplegame
parent943e3a5bc98ebcc2aa1b1d576700f7c4010c143c (diff)
downloadYAGE-34908f108ad7c2ee6cff96491a0bc40381477424.tar.gz
YAGE-34908f108ad7c2ee6cff96491a0bc40381477424.zip
[Test] Benchmarking the engine and trying to optimize.
Diffstat (limited to 'examples/simplegame')
-rw-r--r--examples/simplegame/main.cpp41
1 files changed, 34 insertions, 7 deletions
diff --git a/examples/simplegame/main.cpp b/examples/simplegame/main.cpp
index 895fce51..03c85123 100644
--- a/examples/simplegame/main.cpp
+++ b/examples/simplegame/main.cpp
@@ -17,10 +17,10 @@ using namespace yage;
int main()
{
Window window;
- window.create("Simple Game", 800, 640);
+ window.create("Simple Game", 1920, 1080);
- Shader textureProgram("examples/resources/learnopenglshader.vert",
- "examples/resources/learnopenglshader.frag");
+ Shader textureProgram("examples/resources/textureshader.vert",
+ "examples/resources/textureshader.frag");
SpriteBatch sp;
Texture fountain = ResourceManager::getTexture(
@@ -32,9 +32,16 @@ int main()
cout << "texture: " << brick.width << ", " << brick.height << '\n';
- Camera camera(800, 640);
+ Camera camera(1920, 1080);
textureProgram.use();
- textureProgram.setUniform("ourTexture", 0);
+ textureProgram.setUniform("texture_sampler", 0);
+
+ double prev_time = glfwGetTime();
+ double final_time = 0;
+ double diff = 0;
+ double fps = 0;
+ int i = 0;
+ double time;
while (!window.shouldClose()) {
window.clearBuffer();
@@ -48,10 +55,30 @@ int main()
texture = breast_plate;
}
- sp.draw({-0.5, -0.5, 1, 1}, {0, 0, 1, 1}, brick.id, Colour(255, 255, 255, 255), 0);
+ camera.update(textureProgram);
- sp.render();
+ time = glfwGetTime();
+ for (int i = 0; i < 1920/10; i++) {
+ for(int j = 0; j < 1080/10; j++)
+ sp.draw({(float)(10*i), (float)(10*j), 10.f, 10.f}, {0.f, 0.f, 1.f, 1.f}, fountain.id,
+ Colour(255, 255, 255, 255), 0);
+ }
+
+ sp.draw({50, 50, 100, 100}, {0, 0, 1, 1}, brick.id, Colour(255, 255, 255, 255), 1);
+ yLog << "draw: " << glfwGetTime() - time;
+ time = glfwGetTime();
+ sp.render();
+ yLog << "render: " << glfwGetTime() - time;
window.swapBuffer();
+
+ if (i == 0) {
+ final_time = glfwGetTime();
+ diff = final_time - prev_time;
+ prev_time = final_time;
+ fps = 1 / diff * 30;
+ yLog << "fps: " << fps;
+ }
+ i = (i + 1) % 30;
}
}