aboutsummaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/Image.cpp4
-rw-r--r--src/graphics/Shader.cpp6
-rw-r--r--src/graphics/Text.cpp13
3 files changed, 17 insertions, 6 deletions
diff --git a/src/graphics/Image.cpp b/src/graphics/Image.cpp
index 2d9b58d..74a9866 100644
--- a/src/graphics/Image.cpp
+++ b/src/graphics/Image.cpp
@@ -34,6 +34,10 @@ namespace mgl {
return { image.width, image.height };
}
+ int Image::get_num_channels() const {
+ return mgl_image_get_num_channels(&image);
+ }
+
mgl_image* Image::internal_image() {
return ℑ
}
diff --git a/src/graphics/Shader.cpp b/src/graphics/Shader.cpp
index c23d32b..7775b78 100644
--- a/src/graphics/Shader.cpp
+++ b/src/graphics/Shader.cpp
@@ -24,6 +24,12 @@ namespace mgl {
return mgl_shader_program_finalize(&shader_program) == 0;
}
+ bool Shader::set_uniform(const char *name, float value) {
+ if(!shader_program.id)
+ return false;
+ return mgl_shader_program_set_uniform_float(&shader_program, name, value) == 0;
+ }
+
bool Shader::set_uniform(const char *name, vec2f value) {
if(!shader_program.id)
return false;
diff --git a/src/graphics/Text.cpp b/src/graphics/Text.cpp
index b3a32da..49829e6 100644
--- a/src/graphics/Text.cpp
+++ b/src/graphics/Text.cpp
@@ -7,19 +7,19 @@ extern "C" {
namespace mgl {
Text::Text() : font(nullptr) {
- mgl_text_init(&text, nullptr, nullptr, 0, nullptr);
+ mgl_text_init(&text, nullptr, nullptr, 0);
}
Text::Text(std::string str, Font &font) : Text(std::move(str), vec2f(0.0f, 0.0f), font) {}
Text::Text(std::string str, vec2f position, Font &font) : font(&font), str(std::move(str)) {
- mgl_text_init(&text, font.internal_font(), this->str.c_str(), this->str.size(), nullptr);
+ mgl_text_init(&text, font.internal_font(), this->str.c_str(), this->str.size());
mgl_text_set_position(&text, { position.x, position.y });
}
Text::Text(const Text &other) {
font = other.font;
- mgl_text_init(&text, font ? font->internal_font() : nullptr, other.str.c_str(), other.str.size(), nullptr);
+ mgl_text_init(&text, font ? font->internal_font() : nullptr, other.str.c_str(), other.str.size());
mgl_text_set_position(&text, { other.text.position.x, other.text.position.y });
}
@@ -39,9 +39,10 @@ namespace mgl {
return { text.position.x, text.position.y };
}
- // TODO: Implement
- FloatRect Text::get_local_bounds() {
- return FloatRect();
+ FloatRect Text::get_bounds() const {
+ mgl_vec2f bounds = mgl_text_get_bounds(&text);
+ FloatRect rect(get_position(), { bounds.x, bounds.y });
+ return rect;
}
void Text::set_string(std::string str) {