aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-08 01:23:27 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-08 01:23:27 +0000
commite6215e764bc149497ab5772d9ea136809d898993 (patch)
treebe10db001a2d4eedd611c7db2c5cf7907f55250c /tests
parent4738752fd7633f68911f97aeda9954ee87b5ce6e (diff)
downloadYAGE-e6215e764bc149497ab5772d9ea136809d898993.tar.gz
YAGE-e6215e764bc149497ab5772d9ea136809d898993.zip
Improving api
Diffstat (limited to 'tests')
-rw-r--r--tests/simplegame.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/tests/simplegame.cpp b/tests/simplegame.cpp
index 54ead815..2968f4ba 100644
--- a/tests/simplegame.cpp
+++ b/tests/simplegame.cpp
@@ -8,32 +8,54 @@
#include <yage.cpp>
+#include <iostream>
+
+using std::cout;
+
using namespace yage;
int main()
{
Window window;
- SpriteBatch sp;
GlslProgram program;
window.create("Simple Game", 800, 640);
- sp.init();
+ SpriteBatch sp;
- program.compileShaders("/home/yannherklotz/Github/YAGE/resources/defaultshader.vert", "/home/yannherklotz/Github/YAGE/tests/resources/defaultshader.frag");
+ program.compileShaders(
+ "/home/yannherklotz/Github/YAGE/resources/defaultshader.vert",
+ "/home/yannherklotz/Github/YAGE/resources/defaultshader.frag");
program.addAttribute("vertex_position");
program.addAttribute("vertex_colour");
program.addAttribute("vertex_uv");
program.linkShaders();
- Texture fountain = ResourceManager::getTexture("/home/yannherklotz/Github/YAGE/tests/resources/dngn_blood_fountain.png");
+ Texture fountain =
+ ResourceManager::getTexture("/home/yannherklotz/Github/YAGE/tests/"
+ "resources/dngn_blood_fountain.png");
+
+ cout << "texture: " << fountain.width << ", " << fountain.height << '\n';
- while(!window.shouldClose()) {
+ Camera2D camera(800, 640);
+
+ while (!window.shouldClose()) {
window.clearBuffer();
- sp.begin();
- sp.draw(std::vector<float>({0, 0, 50, 50}), std::vector<float>({0, 0, 1, 1}), fountain.id, Colour(), 0);
+ program.use();
+ camera.update(program);
+
+ glActiveTexture(GL_TEXTURE0);
+
+ GLint texture_location = program.getUniformLocation("texture_sampler");
+ glUniform1i(texture_location, 0);
+
+ sp.draw(std::vector<float>({0, 0, 64, 64}),
+ std::vector<float>({0, 0, 1, 1}), fountain.id, Colour(), 0);
sp.render();
+ glBindTexture(GL_TEXTURE_2D, 0);
+ program.unuse();
+
window.pollEvents();
window.swapBuffer();
}