| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,62 @@ |
| 1 |
+#include <gltexture2d.hpp> |
|
| 2 |
+ |
|
| 3 |
+#include <ostream> |
|
| 4 |
+ |
|
| 5 |
+#include <globject.hpp> |
|
| 6 |
+ |
|
| 7 |
+// NOLINTNEXTLINE |
|
| 8 |
+#define STR_EXCEPTION GLObject<>::Exception |
|
| 9 |
+#include <str.hpp> |
|
| 10 |
+ |
|
| 11 |
+ |
|
| 12 |
+/// TGA |
|
| 13 |
+ |
|
| 14 |
+ |
|
| 15 |
+GLTexture2D GLTexture2D::tga_read( |
|
| 16 |
+ Path const & path, |
|
| 17 |
+ GLenum format, |
|
| 18 |
+ GLenum internal_format, |
|
| 19 |
+ GLenum wrap, |
|
| 20 |
+ GLenum min_filter, |
|
| 21 |
+ GLenum mag_filter |
|
| 22 |
+) |
|
| 23 |
+try |
|
| 24 |
+{
|
|
| 25 |
+ auto texture = GLTexture2D( |
|
| 26 |
+ str_path_(path), |
|
| 27 |
+ TGA::read(path).size(), |
|
| 28 |
+ internal_format, |
|
| 29 |
+ wrap, |
|
| 30 |
+ min_filter, |
|
| 31 |
+ mag_filter |
|
| 32 |
+ ); |
|
| 33 |
+ texture.data( |
|
| 34 |
+ TGA::read(path_prefix_(path, prefix())).data(), |
|
| 35 |
+ GL_TEXTURE_2D, |
|
| 36 |
+ format |
|
| 37 |
+ ); |
|
| 38 |
+ return texture; |
|
| 39 |
+} |
|
| 40 |
+catch (...) |
|
| 41 |
+{
|
|
| 42 |
+ STR_THROW_NESTED( |
|
| 43 |
+ "Failed to read GLTexture2D TGA " << str_path_(path) << ":" |
|
| 44 |
+ ); |
|
| 45 |
+} |
|
| 46 |
+ |
|
| 47 |
+ |
|
| 48 |
+void GLTexture2D::tga_write( |
|
| 49 |
+ Path const & path, |
|
| 50 |
+ GLenum format |
|
| 51 |
+) const |
|
| 52 |
+try |
|
| 53 |
+{
|
|
| 54 |
+ TGA(size(), data(GL_TEXTURE_2D, format)) |
|
| 55 |
+ .write(path_prefix_(path, prefix())); |
|
| 56 |
+} |
|
| 57 |
+catch (...) |
|
| 58 |
+{
|
|
| 59 |
+ STR_THROW_NESTED( |
|
| 60 |
+ "Failed to write GLTexture2D TGA " << str_path_(path) << ":" |
|
| 61 |
+ ); |
|
| 62 |
+} |