gdk-graphics 0b051eb9b5c1eaa0658babaa4463dd7a80aa9d2c
Loading...
Searching...
No Matches
webgl1es2_texture.h
1// © Joseph Cameron - All Rights Reserved
2
3#ifndef GDK_GFX_WEBGL1ES2_TEXTURE_H
4#define GDK_GFX_WEBGL1ES2_TEXTURE_H
5
6#include <gdk/opengl.h>
7#include <gdk/texture.h>
8#include <gdk/texture_data.h>
9#include <jfc/unique_handle.h>
10
11#include <array>
12#include <cstddef>
13#include <string>
14#include <vector>
15
16namespace gdk {
17 namespace texture_data { struct view; }
18
19 class webgl1es2_texture final : public texture {
20 public:
23 //
24 virtual void update_data(const texture_data::view &) override;
25 virtual void update_data(const texture_data::view &, const size_t offsetX, const size_t offsetY) override;
27
62
74
75 enum class format {
76 alpha,
77 depth,
78 luminance_alpha,
79 rgb,
80 rgba,
81 };
82
83 public:
85 [[nodiscard]] GLuint getHandle() const;
86
89 void activateAndBind(const GLint aUnit) const;
90
92 bool operator==(const webgl1es2_texture &) const;
94 bool operator!=(const webgl1es2_texture &) const;
95
100
104 const texture_data::view &aTextureView,
105 const wrap_mode aWrapModeU = wrap_mode::repeat,
106 const wrap_mode aWrapModeV = wrap_mode::repeat,
109
111 const webgl1es2_texture::format aFormat,
112 const size_t aWidthInTexels,
113 const size_t aHeightInTexels,
114 const texture_data::channel_type *aData,
115 const wrap_mode aWrapModeU = wrap_mode::repeat,
116 const wrap_mode aWrapModeV = wrap_mode::repeat,
119
122 static const std::shared_ptr<gdk::webgl1es2_texture> GetCheckerboardOfDeath();
123
125 static const GLint getMaxTextureSize();
126
127 private:
129 jfc::unique_handle<GLuint> m_Handle;
130
131 size_t m_CurrentDataWidth;
132 size_t m_CurrentDataHeight;
133 GLint m_CurrentDataFormat;
134 };
135}
136
137#endif
138
wrap_mode
behavior when sampling outside of the normalized texture range (u0-1, v0-1)
Definition texture.h:31
@ repeat
sampled values repeat. e.g: {2,2}, {3,3}, 100,100} would all sample {1,1}
Definition texture.h:33
texture()=default
interface type cannot be instantiated
GLuint getHandle() const
returns the handle to the webgl1es2_texture in the opengl context
static const std::shared_ptr< gdk::webgl1es2_texture > GetCheckerboardOfDeath()
webgl1es2_texture useful for indicating webgl1es2_texture related failure lazily instantiated.
virtual void update_data(const texture_data::view &) override
replace the texture data with new data
minification_filter
Definition webgl1es2_texture.h:30
@ linear_mipmap_linear
Definition webgl1es2_texture.h:60
@ nearest_mipmap_nearest
Definition webgl1es2_texture.h:42
@ linear_mipmap_nearest
Definition webgl1es2_texture.h:47
@ linear
Definition webgl1es2_texture.h:33
@ nearest_mipmap_linear
Definition webgl1es2_texture.h:54
@ nearest
Definition webgl1es2_texture.h:37
bool operator!=(const webgl1es2_texture &) const
equality semantics
webgl1es2_texture & operator=(webgl1es2_texture &&)=default
move semantics
magnification_filter
Definition webgl1es2_texture.h:65
@ nearest
Definition webgl1es2_texture.h:68
webgl1es2_texture(const texture_data::view &aTextureView, const wrap_mode aWrapModeU=wrap_mode::repeat, const wrap_mode aWrapModeV=wrap_mode::repeat, const minification_filter minFilter=minification_filter::linear, const magnification_filter magFilter=magnification_filter::nearest)
creates a 2d webgl1es2_texture from decoded image data.
virtual void update_data(const texture_data::view &, const size_t offsetX, const size_t offsetY) override
bool operator==(const webgl1es2_texture &) const
equality semantics
webgl1es2_texture(webgl1es2_texture &&)=default
move semantics
static const GLint getMaxTextureSize()
gets the max texture size supported by the current graphics device
void activateAndBind(const GLint aUnit) const
activates the texture in given unit and binds it to GL_TEXTURE_2D, so that it can be manipulated by o...
provides a pointer a contiguous list of channel data representing 2D texture metadata that contains i...
Definition texture_data.h:20