14#include <lagrange/fs/filesystem.h>
15#include <lagrange/ui/types/GLContext.h>
16#include <lagrange/ui/utils/math.h>
17#include <lagrange/ui/api.h>
22#include <unordered_map>
34 Eigen::Vector2f scale;
35 Eigen::Vector2f offset;
38 Eigen::Vector2f scale_ = Eigen::Vector2f::Constant(1.0f),
39 Eigen::Vector2f offset_ = Eigen::Vector2f::Constant(0.0f),
40 float rotation_ = 0.0f);
41 Eigen::Matrix3f get_matrix()
const;
48 GLenum internal_format;
55 float border_color[4];
59 int multisample_samples;
65 , internal_format(GL_NONE)
67 , mag_filter(GL_LINEAR)
68 , min_filter(GL_LINEAR_MIPMAP_LINEAR)
72 , border_color{0, 0, 0, 0}
73 , generate_mipmap(
true)
76 , multisample_samples(4)
80 static Params multisampled_rgba16f(
int num_samples = 4)
83 p.type = GL_TEXTURE_2D_MULTISAMPLE;
84 p.internal_format = GL_RGBA16F;
85 p.generate_mipmap =
false;
86 p.min_filter = GL_LINEAR;
87 p.multisample_samples = num_samples;
92 static Params multisampled_rgba16f_depth(
int num_samples = 4)
94 Params p = multisampled_rgba16f(num_samples);
95 p.internal_format = GL_DEPTH_COMPONENT24;
102 p.type = GL_TEXTURE_2D;
104 p.internal_format = GL_RGB16F;
105 p.wrap_s = GL_CLAMP_TO_EDGE;
106 p.wrap_t = GL_CLAMP_TO_EDGE;
107 p.mag_filter = GL_LINEAR;
108 p.min_filter = GL_LINEAR;
109 p.generate_mipmap =
false;
118 p.internal_format = GL_RGBA16F;
125 p.type = GL_TEXTURE_2D;
127 p.internal_format = GL_RED;
128 p.wrap_s = GL_CLAMP_TO_EDGE;
129 p.wrap_t = GL_CLAMP_TO_EDGE;
130 p.mag_filter = GL_LINEAR;
131 p.min_filter = GL_LINEAR;
132 p.generate_mipmap =
false;
139 p.type = GL_TEXTURE_2D;
141 p.internal_format = GL_RGB;
142 p.wrap_s = GL_CLAMP_TO_EDGE;
143 p.wrap_t = GL_CLAMP_TO_EDGE;
144 p.mag_filter = GL_NEAREST;
145 p.min_filter = GL_NEAREST;
146 p.generate_mipmap =
false;
154 p.internal_format = GL_RGBA;
161 p.format = GL_DEPTH_COMPONENT;
162 p.internal_format = GL_DEPTH_COMPONENT24;
169 const void* image_data,
174 Texture(
const Params& params,
int width = 1,
int height = 1,
int depth = 0);
180 void bind_to(GLenum texture_unit)
const;
182 GLuint get_id()
const {
return m_id; }
184 const Params& get_params()
const {
return m_params; }
187 void resize(
int width,
int height = 0,
int depth = 0,
bool force =
false);
189 int get_width()
const {
return m_width; }
190 int get_height()
const {
return m_height; }
192 void upload(
float* data);
193 void upload(
unsigned char* data);
195 void set_uv_transform(
const Texture::Transform& uv_transform);
199 std::vector<unsigned char> data;
200 int w, h, components;
204 std::optional<Texture::DownloadResult> download(
205 GLenum target = GL_TEXTURE_2D,
209 const fs::path& file_path,
210 GLenum opengl_target = GL_TEXTURE_2D,
215 static bool is_internal_format_color_renderable(GLenum internal_format);
218 GLenum get_gl_element_type()
const {
return m_gl_elem_type; }
221 void set_common_params();
223 void load_data_from_image(
const fs::path& file_path);
224 void load_data_from_image(
const void* image_data,
size_t size);
232 GLenum m_gl_elem_type;
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Definition: Texture.h:198