| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,45 @@ |
| 1 |
+#ifndef GLBACKEND_TESTS_COMMON_RUN_HPP_ |
|
| 2 |
+#define GLBACKEND_TESTS_COMMON_RUN_HPP_ |
|
| 3 |
+ |
|
| 4 |
+ |
|
| 5 |
+#include <iostream> |
|
| 6 |
+#include <string> |
|
| 7 |
+ |
|
| 8 |
+#include <glbase.hpp> |
|
| 9 |
+#include <glbackend.hpp> |
|
| 10 |
+ |
|
| 11 |
+// NOLINTNEXTLINE |
|
| 12 |
+#define STR_EXCEPTION GLBase::Exception |
|
| 13 |
+#include <str.hpp> |
|
| 14 |
+ |
|
| 15 |
+ |
|
| 16 |
+ |
|
| 17 |
+#define GLBACKEND_TESTS_COMMON_RUN(GLBACKEND) \ |
|
| 18 |
+ run<GLBACKEND>(#GLBACKEND); |
|
| 19 |
+ |
|
| 20 |
+ |
|
| 21 |
+constexpr auto size = std::array<int, 2>{640, 480};
|
|
| 22 |
+ |
|
| 23 |
+ |
|
| 24 |
+template<typename GLBackend> |
|
| 25 |
+inline void run(std::string const & name) |
|
| 26 |
+{
|
|
| 27 |
+ GLBackend::prefix("assets/tests");
|
|
| 28 |
+ |
|
| 29 |
+ auto backend = GLBackend(name, size); |
|
| 30 |
+ |
|
| 31 |
+ std::cout << backend.debug_info() << std::endl; |
|
| 32 |
+ |
|
| 33 |
+ backend.callback_render([&]() |
|
| 34 |
+ {
|
|
| 35 |
+ glClearColor(1.0F, 0.0F, 0.0F, 0.5F); |
|
| 36 |
+ glClear(GL_COLOR_BUFFER_BIT); |
|
| 37 |
+ if (!backend.tga_compare(name + ".tga", true)) |
|
| 38 |
+ STR_THROW("Frame did not match expected frame.");
|
|
| 39 |
+ backend.running(false); |
|
| 40 |
+ }); |
|
| 41 |
+ backend.run(); |
|
| 42 |
+} |
|
| 43 |
+ |
|
| 44 |
+ |
|
| 45 |
+#endif |