From d6b25272499352383214c738faa8ce1870df37f3 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 22 Dec 2017 19:57:23 +0000 Subject: Changing gitmodules --- examples/simplegame/main.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 examples/simplegame/main.cpp (limited to 'examples') diff --git a/examples/simplegame/main.cpp b/examples/simplegame/main.cpp new file mode 100644 index 00000000..04d63ec0 --- /dev/null +++ b/examples/simplegame/main.cpp @@ -0,0 +1,56 @@ +/** --------------------------------------------------------------------------- + * @file: simplegame.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include + +#include + +using std::cout; + +using namespace yage; + +int main() +{ + Window window; + GlslProgram program; + + window.create("Simple Game", 800, 640); + SpriteBatch sp; + + program.compileShadersFromFile("resources/textureshader.vert", "resources/textureshader.frag"); + program.linkShaders(); + + Texture fountain = + ResourceManager::getTexture("/home/yannherklotz/Github/YAGE/tests/" + "resources/dngn_blood_fountain.png"); + + cout << "texture: " << fountain.width << ", " << fountain.height << '\n'; + + Camera2D camera(800, 640); + + while (!window.shouldClose()) { + window.clearBuffer(); + + program.use(); + camera.update(program); + + glActiveTexture(GL_TEXTURE0); + + 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.render(); + + glBindTexture(GL_TEXTURE_2D, 0); + program.unuse(); + + window.swapBuffer(); + window.pollEvents(); + } +} -- cgit