Browse code

Add implementation

Robert Cranston authored on 14/10/2022 20:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,65 @@
1
+#include <exception>
2
+#include <iostream>
3
+#include <string>
4
+#include <type_traits>
5
+
6
+#include <glbase.hpp>
7
+
8
+
9
+struct GLBaseTest : protected GLBase
10
+{
11
+    explicit GLBaseTest()
12
+    :
13
+        GLBase{}
14
+    {
15
+        std::cout
16
+            << path_prefix_("path", "")       << "\n"
17
+            << path_prefix_("path", "prefix") << std::endl;
18
+
19
+        try
20
+        {
21
+            TGA_::read("nonexistent");
22
+        }
23
+        catch (std::exception const & exception)
24
+        {
25
+            std::cout << exception.what() << std::endl;
26
+        }
27
+
28
+        // NOLINTNEXTLINE
29
+        TGA_ tga({1, 1}, {0, 0, 255, 127});
30
+        std::cout
31
+            << "TGA:"                                                    << "\n"
32
+            << "  size:      " << tga.size()[0] << ", " << tga.size()[1] << "\n"
33
+            << "  data size: " << tga.data().size()                      << std::endl;
34
+
35
+        std::cout
36
+            << str_path_           ("path")             << "\n"
37
+            << str_paths_          ({"path1", "path2"}) << "\n"
38
+            << str_enum_           (0x01)               << "\n"
39
+            << str_error_          (GL_NO_ERROR)        << "\n"
40
+            << str_object_type_    (GL_TEXTURE)         << "\n"
41
+            << str_glsl_           (GL_FLOAT_VEC3)      << "\n"
42
+            << str_format_         (GL_RGBA)            << "\n"
43
+            << str_type_           (GL_FLOAT)           << "\n"
44
+            << str_internal_format_(GL_RGBA32F)         << std::endl;
45
+    }
46
+};
47
+
48
+
49
+int main()
50
+{
51
+    static_assert(std::is_empty<GLBase>::value, "GLBase must be empty");
52
+
53
+    std::cout
54
+        << "Supported 1.0: "
55
+        << GLBase::supported({1, 0})
56
+        << std::endl;
57
+    std::cout
58
+        << "GL_ACTIVE_TEXTURE: "
59
+        << GLBase::integer(GL_ACTIVE_TEXTURE)
60
+        << std::endl;
61
+    GLBase::debug(1);
62
+    GLBase::debug_message("Debug message");
63
+
64
+    GLBaseTest{};
65
+}