| 144 | } |
| 145 | |
| 146 | void InterfaceUtilities::rectangle(const sibr::Vector3f & color, const UV11 & tl, const UV11 & br, bool fill, float alpha) |
| 147 | { |
| 148 | |
| 149 | static sibr::Mesh::Ptr rectangleMesh; |
| 150 | static int lastContextId = -1; |
| 151 | |
| 152 | if (lastContextId != sibr::Window::contextId) { |
| 153 | rectangleMesh = std::make_shared<sibr::Mesh>(true); |
| 154 | }; |
| 155 | |
| 156 | |
| 157 | baseShader.begin(); |
| 158 | |
| 159 | scalingGL.set(sibr::Vector2f(1.0f,1.0f)); |
| 160 | translationGL.set(sibr::Vector2f(0, 0)); |
| 161 | colorGL.set(color); |
| 162 | |
| 163 | rectangleMesh->vertices({ |
| 164 | { tl.x(), tl.y() , 0 }, |
| 165 | { tl.x(), br.y() , 0 }, |
| 166 | { br.x(), br.y() , 0 }, |
| 167 | { br.x(), tl.y() , 0 } |
| 168 | }); |
| 169 | |
| 170 | if (fill) { |
| 171 | rectangleMesh->triangles({ |
| 172 | { 0,1,2 }, |
| 173 | { 0,2,3 } |
| 174 | }); |
| 175 | |
| 176 | alphaGL.set(alpha); |
| 177 | glEnable(GL_BLEND); |
| 178 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 179 | glBlendEquation(GL_FUNC_ADD); |
| 180 | rectangleMesh->render(false, false); |
| 181 | } |
| 182 | |
| 183 | rectangleMesh->triangles({ |
| 184 | { 0,0,1 },{ 1,1,2 },{ 2,2,3 },{ 3,3,0 } |
| 185 | }); |
| 186 | |
| 187 | alphaGL.set(1.0f); |
| 188 | rectangleMesh->render(false, false, sibr::Mesh::LineRenderMode); |
| 189 | |
| 190 | baseShader.end(); |
| 191 | } |
| 192 | |
| 193 | void InterfaceUtilities::rectanglePixels(const sibr::Vector3f & color, const sibr::Vector2f & center, const sibr::Vector2f & diagonal, bool fill, float alpha, const sibr::Vector2f & winSize) |
| 194 | { |