aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index 68e3778..163aece 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -8,7 +8,9 @@
#include <mglpp/graphics/Text.hpp>
#include <mglpp/graphics/Rectangle.hpp>
#include <mglpp/graphics/VertexBuffer.hpp>
+#include <mglpp/graphics/Vertex.hpp>
#include <mglpp/graphics/Shader.hpp>
+#include <mglpp/system/Clock.hpp>
struct Delegate {
Delegate() {}
@@ -20,11 +22,11 @@ struct Delegate {
shader_program->set_uniform("resolution", mgl::vec2f(window->get_size().x, window->get_size().y));
- mgl::Sprite sprite(*texture, { 100.0f - 10.0f, 0.0f });
+ mgl::Sprite sprite(texture, { 100.0f - 10.0f, 0.0f });
sprite.set_color({255, 255, 255, 128});
window->draw(sprite, shader_program);
- mgl::Text text("hello world!\nGood bye world!", { 0.0f, 0.0f }, *font);
+ mgl::Text text("hello world!\nelapsed time: " + std::to_string(clock.get_elapsed_time_seconds()), { 0.0f, 0.0f }, *font);
window->draw(text);
vertex_buffer->set_position({ window->get_cursor_position().x + 100, window->get_cursor_position().y });
@@ -36,6 +38,7 @@ struct Delegate {
mgl::Font *font;
mgl::VertexBuffer *vertex_buffer;
mgl::Shader *shader_program;
+ mgl::Clock clock;
};
int main(int argc, char **argv) {
@@ -57,34 +60,35 @@ int main(int argc, char **argv) {
if(!shader.load_from_file("depends/mgl/tests/circle_mask.glsl", mgl::Shader::Fragment))
return 1;
+ mgl::Texture font_texture = font.get_texture();
mgl::Vertex vertices[4] = {
{
{0.0f, 0.0f},
- {255, 0, 0, 100},
- {0.0f, 0.0f}
+ {0.0f, 0.0f},
+ {255, 0, 0, 100}
},
{
- {texture.get_size().x, 0.0f},
- {0, 255, 0, 100},
- {1.0f, 0.0f}
+ {font_texture.get_size().x, 0.0f},
+ {1.0f, 0.0f},
+ {0, 255, 0, 100}
},
{
- {texture.get_size().x, texture.get_size().y},
- {0, 0, 255, 100},
- {1.0f, 1.0f}
+ {font_texture.get_size().x, font_texture.get_size().y},
+ {1.0f, 1.0f},
+ {0, 0, 255, 100}
},
{
- {0.0f, texture.get_size().y},
+ {0.0f, font_texture.get_size().y},
+ {0.0f, 1.0f},
{255, 0, 255, 100},
- {0.0f, 1.0f}
}
};
- mgl::VertexBuffer vertex_buffer(mgl::VertexBuffer::Quads, mgl::VertexBuffer::Static);
- if(!vertex_buffer.update(vertices, 4))
+ mgl::VertexBuffer vertex_buffer;
+ if(!vertex_buffer.update(vertices, 4, mgl::PrimitiveType::Quads, mgl::VertexBuffer::Static))
return 1;
- vertex_buffer.set_texture(&texture);
+ vertex_buffer.set_texture(&font_texture);
Delegate delegate;
delegate.window = &window;