From 3e9c8aec1ef9a531afd79d0fc4d5a56d59076195 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 27 Jan 2024 10:52:18 +0000 Subject: Add text to framebuffer rendering test --- test/test-text.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test-text.cpp b/test/test-text.cpp index 166a6fa..b540b5a 100644 --- a/test/test-text.cpp +++ b/test/test-text.cpp @@ -6,10 +6,12 @@ #include #include "testMainWindow.h" +#include "testRenderOutput.h" #include "ui/applicationBase.h" +#include "ui/text.h" #include +#include #include -#include #include #include #include @@ -86,7 +88,7 @@ BOOST_DATA_TEST_CASE(initialize_chardata_A, static_assert(glm::vec2 {862, 0} / glm::vec2 {2048, 64} == glm::vec2 {0.4208984375, 0}); static_assert(glm::vec2 {866, 35} / glm::vec2 {2048, 64} == glm::vec2 {0.4228515625, 0.546875}); -BOOST_AUTO_TEST_CASE(render_text) +BOOST_AUTO_TEST_CASE(render_font) { constexpr std::string_view text {"I Like Trains"}; const auto spaces = static_cast(std::count_if(text.begin(), text.end(), isspace)); @@ -112,6 +114,19 @@ BOOST_AUTO_TEST_CASE(render_text) } } +BOOST_AUTO_TEST_CASE(render_text) +{ + TestRenderOutput output; + glBindFramebuffer(GL_FRAMEBUFFER, output.output); + glViewport(0, 0, 640, 480); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + Text t {"I Like Trains", *this, {{0, 0}, {200, 40}}, {1, 1, 1}}; + UIShader s {640, 480}; + t.render(s, {{200, 200}, {200, 100}}); + Texture::save(output.outImage, "/tmp/text.tga"); +} + BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_CASE(stream_vec) -- cgit v1.2.3 From d82541fcea40efadaef63fef5f4a76c3fea5defe Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 27 Jan 2024 11:32:16 +0000 Subject: Support constructing a glContainer from a collection of the same type --- test/test-glContainer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/test-glContainer.cpp b/test/test-glContainer.cpp index 0597470..ccf3b90 100644 --- a/test/test-glContainer.cpp +++ b/test/test-glContainer.cpp @@ -305,6 +305,15 @@ BOOST_AUTO_TEST_CASE(iter_compare) BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_CASE(create_copy_source, *boost::unit_test::timeout(1)) +{ + const std::vector src {4, 6, 2, 4, 6, 0}; + glContainer dst {src}; + static_assert(std::is_same_v); + dst.unmap(); + BOOST_CHECK_EQUAL_COLLECTIONS(src.begin(), src.end(), dst.begin(), dst.end()); +} + struct C { int x; float y; -- cgit v1.2.3 From 264640420882ceeafd9b1149eba9472cf8835e7b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 27 Jan 2024 21:47:04 +0000 Subject: Render text in N draw calls Creates a single buffer per required texture and draws the whole buffer in one go. It does introduce the use of deprecated GL_QUADS primitive, but it's the easiest way to go without needing indices, repeated vertices etc --- test/Jamfile.jam | 2 +- test/test-text.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/Jamfile.jam b/test/Jamfile.jam index c109051..733ef05 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -49,7 +49,7 @@ run test-lib.cpp ; run test-geoData.cpp : -- : fixtures/height/SD19.asc : test ; run test-network.cpp : : : test ; run test-persistence.cpp : -- : [ sequence.insertion-sort [ glob-tree $(fixtures)/json : *.json ] ] : test ; -run test-text.cpp : : : test ; +run test-text.cpp : -- : test-glContainer : test ; run test-enumDetails.cpp ; run test-render.cpp : -- : test-assetFactory : test ; run test-glContextBhvr.cpp ; diff --git a/test/test-text.cpp b/test/test-text.cpp index b540b5a..f652670 100644 --- a/test/test-text.cpp +++ b/test/test-text.cpp @@ -121,9 +121,9 @@ BOOST_AUTO_TEST_CASE(render_text) glViewport(0, 0, 640, 480); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - Text t {"I Like Trains", *this, {{0, 0}, {200, 40}}, {1, 1, 1}}; + Text t {"I Like Trains", *this, {{10, 10}, {200, 40}}, {1, 1, 1}}; UIShader s {640, 480}; - t.render(s, {{200, 200}, {200, 100}}); + t.render(s, {}); Texture::save(output.outImage, "/tmp/text.tga"); } -- cgit v1.2.3