aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simplegame/main.cpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-12-27 19:21:12 +0000
committerYann Herklotz <ymherklotz@gmail.com>2017-12-27 19:21:12 +0000
commit354d7df4d2779ed7391701d1ef4344e959b64582 (patch)
tree81ecdc8d323cae78a86fb9c99524f57c705eeabc /examples/simplegame/main.cpp
parentf949692714e72a0e2d45ebb6a5d698424ab71dee (diff)
downloadYAGE-354d7df4d2779ed7391701d1ef4344e959b64582.tar.gz
YAGE-354d7df4d2779ed7391701d1ef4344e959b64582.zip
[Broken] Texture is black.
Diffstat (limited to 'examples/simplegame/main.cpp')
-rw-r--r--examples/simplegame/main.cpp25
1 files changed, 7 insertions, 18 deletions
diff --git a/examples/simplegame/main.cpp b/examples/simplegame/main.cpp
index 9fba20eb..f5547e53 100644
--- a/examples/simplegame/main.cpp
+++ b/examples/simplegame/main.cpp
@@ -17,15 +17,11 @@ using namespace yage;
int main()
{
Window window;
- GlslProgram textureProgram;
-
window.create("Simple Game", 800, 640);
- SpriteBatch sp;
- textureProgram.compileShadersFromFile(
- "examples/resources/textureshader.vert",
- "examples/resources/textureshader.frag");
- textureProgram.linkShaders();
+ Shader textureProgram("examples/resources/textureshader.vert",
+ "examples/resources/textureshader.frag");
+ SpriteBatch sp;
Texture fountain = ResourceManager::getTexture(
"examples/resources/dngn_blood_fountain.png");
@@ -36,6 +32,9 @@ int main()
Camera camera(800, 640);
+ textureProgram.use();
+ textureProgram.setUniform("texture_sampler", 0);
+
while (!window.shouldClose()) {
window.clearBuffer();
Texture texture = fountain;
@@ -48,22 +47,12 @@ int main()
texture = breast_plate;
}
- textureProgram.use();
camera.update(textureProgram);
- glActiveTexture(GL_TEXTURE0);
-
- 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}, texture.id,
+ 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);
- textureProgram.unuse();
-
window.swapBuffer();
}
}