aboutsummaryrefslogtreecommitdiff
path: root/src/RoundedRectangle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/RoundedRectangle.cpp')
-rw-r--r--src/RoundedRectangle.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/RoundedRectangle.cpp b/src/RoundedRectangle.cpp
index 587560c..82ade02 100644
--- a/src/RoundedRectangle.cpp
+++ b/src/RoundedRectangle.cpp
@@ -54,16 +54,18 @@ namespace QuickMedia {
void RoundedRectangle::draw(mgl::Window &target) {
const mgl::vec2f resolution = size + mgl::vec2f(shadow_radius*2.0f, shadow_radius*2.0f);
- if(abs(cached_radius - radius) > 0.01f) {
- // TODO: Remove these for optimizations. Also do the same in other places where set_uniform is called
- rounded_rectangle_shader->set_uniform("radius", radius);
- cached_radius = radius;
- }
+ if(rounded_rectangle_shader && rounded_rectangle_shader->is_valid()) {
+ if(abs(cached_radius - radius) > 0.01f) {
+ // TODO: Remove these for optimizations. Also do the same in other places where set_uniform is called
+ rounded_rectangle_shader->set_uniform("radius", radius);
+ cached_radius = radius;
+ }
- if(abs(cached_resolution_x - resolution.x) > 0.01f || abs(cached_resolution_y - resolution.y) > 0.01f) {
- rounded_rectangle_shader->set_uniform("resolution", size + mgl::vec2f(shadow_radius*2.0f, shadow_radius*2.0f));
- cached_resolution_x = resolution.x;
- cached_resolution_y = resolution.y;
+ if(abs(cached_resolution_x - resolution.x) > 0.01f || abs(cached_resolution_y - resolution.y) > 0.01f) {
+ rounded_rectangle_shader->set_uniform("resolution", size + mgl::vec2f(shadow_radius*2.0f, shadow_radius*2.0f));
+ cached_resolution_x = resolution.x;
+ cached_resolution_y = resolution.y;
+ }
}
target.draw(vertices, 4, mgl::PrimitiveType::Quads, rounded_rectangle_shader);