| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,107 @@ |
| 1 |
+#ifndef GLTEXTURE1D_HPP_ |
|
| 2 |
+#define GLTEXTURE1D_HPP_ |
|
| 3 |
+ |
|
| 4 |
+ |
|
| 5 |
+#include <string> |
|
| 6 |
+#include <utility> |
|
| 7 |
+ |
|
| 8 |
+#include <gltexturend.hpp> |
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+/// Class |
|
| 12 |
+ |
|
| 13 |
+class GLTexture1D : public GLTextureND<1> |
|
| 14 |
+{
|
|
| 15 |
+public: |
|
| 16 |
+ |
|
| 17 |
+ /// Special member functions |
|
| 18 |
+ |
|
| 19 |
+ explicit GLTexture1D( |
|
| 20 |
+ std::string object_label, |
|
| 21 |
+ Size size, |
|
| 22 |
+ GLenum internal_format = GL_RGBA8, |
|
| 23 |
+ GLenum wrap = GL_CLAMP_TO_EDGE, |
|
| 24 |
+ GLenum min_filter = GL_LINEAR, |
|
| 25 |
+ GLenum mag_filter = GL_LINEAR |
|
| 26 |
+ ); |
|
| 27 |
+ |
|
| 28 |
+ /// Core |
|
| 29 |
+ |
|
| 30 |
+ GLTexture1D static const & empty(); |
|
| 31 |
+ |
|
| 32 |
+private: |
|
| 33 |
+ |
|
| 34 |
+ /// Core |
|
| 35 |
+ |
|
| 36 |
+ void virtual data_( |
|
| 37 |
+ void const * data, |
|
| 38 |
+ GLenum target, |
|
| 39 |
+ GLenum format, |
|
| 40 |
+ GLenum type |
|
| 41 |
+ ) override; |
|
| 42 |
+}; |
|
| 43 |
+ |
|
| 44 |
+ |
|
| 45 |
+/// Special member functions |
|
| 46 |
+ |
|
| 47 |
+inline GLTexture1D::GLTexture1D( |
|
| 48 |
+ std::string object_label, |
|
| 49 |
+ Size size, |
|
| 50 |
+ GLenum internal_format, |
|
| 51 |
+ GLenum wrap, |
|
| 52 |
+ GLenum min_filter, |
|
| 53 |
+ GLenum mag_filter |
|
| 54 |
+) |
|
| 55 |
+: |
|
| 56 |
+ GLTextureND( |
|
| 57 |
+ std::move(object_label), |
|
| 58 |
+ GL_TEXTURE_1D, |
|
| 59 |
+ GL_TEXTURE_BINDING_1D, |
|
| 60 |
+ GL_MAX_TEXTURE_SIZE, |
|
| 61 |
+ size, |
|
| 62 |
+ internal_format, |
|
| 63 |
+ wrap, |
|
| 64 |
+ min_filter, |
|
| 65 |
+ mag_filter |
|
| 66 |
+ ) |
|
| 67 |
+{
|
|
| 68 |
+ try |
|
| 69 |
+ {
|
|
| 70 |
+ glTexImage1D( |
|
| 71 |
+ target_, 0, |
|
| 72 |
+ (GLint)internal_format, |
|
| 73 |
+ size[0], 0, |
|
| 74 |
+ GL_RED, GL_UNSIGNED_BYTE, nullptr |
|
| 75 |
+ ); |
|
| 76 |
+ check_error_(glGetError()); |
|
| 77 |
+ } |
|
| 78 |
+ catch (...) |
|
| 79 |
+ {
|
|
| 80 |
+ fail_action_("create");
|
|
| 81 |
+ } |
|
| 82 |
+} |
|
| 83 |
+ |
|
| 84 |
+/// Core |
|
| 85 |
+ |
|
| 86 |
+inline GLTexture1D const & GLTexture1D::empty() |
|
| 87 |
+{
|
|
| 88 |
+ return empty_<GLTexture1D>(); |
|
| 89 |
+} |
|
| 90 |
+ |
|
| 91 |
+inline void GLTexture1D::data_( |
|
| 92 |
+ void const * data, |
|
| 93 |
+ GLenum target, |
|
| 94 |
+ GLenum format, |
|
| 95 |
+ GLenum type |
|
| 96 |
+) |
|
| 97 |
+{
|
|
| 98 |
+ glTexSubImage1D( |
|
| 99 |
+ target, 0, |
|
| 100 |
+ 0, |
|
| 101 |
+ size()[0], |
|
| 102 |
+ format, type, data |
|
| 103 |
+ ); |
|
| 104 |
+} |
|
| 105 |
+ |
|
| 106 |
+ |
|
| 107 |
+#endif // GLTEXTURE1D_HPP_ |