diff options
Diffstat (limited to 'examples/simplegame/main.cpp')
-rw-r--r-- | examples/simplegame/main.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/examples/simplegame/main.cpp b/examples/simplegame/main.cpp index 06200661..895fce51 100644 --- a/examples/simplegame/main.cpp +++ b/examples/simplegame/main.cpp @@ -17,23 +17,24 @@ 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/learnopenglshader.vert", + "examples/resources/learnopenglshader.frag"); + SpriteBatch sp; Texture fountain = ResourceManager::getTexture( "examples/resources/dngn_blood_fountain.png"); Texture breast_plate = ResourceManager::getTexture("examples/resources/breast_black.png"); - cout << "texture: " << fountain.width << ", " << fountain.height << '\n'; + Texture brick = ResourceManager::getTexture("examples/resources/wall.png"); + + cout << "texture: " << brick.width << ", " << brick.height << '\n'; Camera camera(800, 640); + textureProgram.use(); + textureProgram.setUniform("ourTexture", 0); while (!window.shouldClose()) { window.clearBuffer(); @@ -47,21 +48,10 @@ int main() texture = breast_plate; } - textureProgram.use(); - camera.update(textureProgram); + sp.draw({-0.5, -0.5, 1, 1}, {0, 0, 1, 1}, brick.id, Colour(255, 255, 255, 255), 0); - 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, - Colour(255, 0, 255, 255), 0); sp.render(); - glBindTexture(GL_TEXTURE_2D, 0); - textureProgram.unuse(); - window.swapBuffer(); } } |