aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-22 07:05:55 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-22 07:05:55 +0200
commitc9ee5e1c1feccb073863ba17cbfdcf094f235886 (patch)
treef6b9f3fdc21cecbaca1fd58425c0f93c3372a9d4 /tests
parentfe1588ef18163c7557d3d0a62c085f42f2abfab2 (diff)
Add vertex buffer
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index 3f149a3..bca9f67 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -7,6 +7,7 @@
#include <mglpp/graphics/Font.hpp>
#include <mglpp/graphics/Text.hpp>
#include <mglpp/graphics/Rectangle.hpp>
+#include <mglpp/graphics/VertexBuffer.hpp>
struct Delegate {
Delegate() {}
@@ -22,11 +23,15 @@ struct Delegate {
mgl::Text text("hello world!\nGood bye world!", { 0.0f, 0.0f }, *font);
window->draw(text);
+
+ vertex_buffer->set_position({ window->get_cursor_position().x + 100, window->get_cursor_position().y });
+ window->draw(*vertex_buffer);
}
mgl::Window *window;
mgl::Texture *texture;
mgl::Font *font;
+ mgl::VertexBuffer *vertex_buffer;
};
int main(int argc, char **argv) {
@@ -44,10 +49,40 @@ int main(int argc, char **argv) {
if(!font.load_from_file("/usr/share/fonts/noto/NotoSans-Regular.ttf", 32))
return 1;
+ mgl::Vertex vertices[4] = {
+ {
+ {0.0f, 0.0f},
+ {255, 0, 0, 100},
+ {0.0f, 0.0f}
+ },
+ {
+ {texture.get_size().x, 0.0f},
+ {0, 255, 0, 100},
+ {1.0f, 0.0f}
+ },
+ {
+ {texture.get_size().x, texture.get_size().y},
+ {0, 0, 255, 100},
+ {1.0f, 1.0f}
+ },
+ {
+ {0.0f, texture.get_size().y},
+ {255, 0, 255, 100},
+ {0.0f, 1.0f}
+ }
+ };
+
+ mgl::VertexBuffer vertex_buffer(mgl::VertexBuffer::Quads, mgl::VertexBuffer::Static);
+ if(!vertex_buffer.update(vertices, 4))
+ return 1;
+
+ vertex_buffer.set_texture(&texture);
+
Delegate delegate;
delegate.window = &window;
delegate.texture = &texture;
delegate.font = &font;
+ delegate.vertex_buffer = &vertex_buffer;
mgl::Event event;
while(true) {