diff options
Diffstat (limited to 'examples/simplegame/main.cpp')
-rw-r--r-- | examples/simplegame/main.cpp | 25 |
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(); } } |