+void View::Render(int width, int height)
+{
+ if (width != m_cached_display.GetWidth() || height != m_cached_display.GetHeight())
+ {
+ m_cached_display.Create(width, height);
+ m_bounds_dirty = true;
+ }
+
+ if (!m_bounds_dirty)
+ {
+ m_cached_display.UnBind();
+ m_cached_display.Blit();
+ return;
+ }
+ m_cached_display.Bind();
+ m_cached_display.Clear();
+
+ if (m_buffer_dirty)
+ ReRender();
+
+ if (m_bounds_dirty)
+ {
+ if (m_use_gpu_transform)
+ {
+ GLfloat glbounds[] = {Float(m_bounds.x), Float(m_bounds.y), Float(m_bounds.w), Float(m_bounds.h)};
+ m_bounds_ubo.Upload(sizeof(float)*4, glbounds);
+ }
+ else
+ {
+ GLfloat glbounds[] = {0.0f, 0.0f, 1.0f, 1.0f};
+ m_bounds_ubo.Upload(sizeof(float)*4, glbounds);
+ }
+ }
+ m_bounds_dirty = false;
+
+ if (m_colour.a < 1.0f)
+ {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ m_vertex_buffer.Bind();
+ m_index_buffer.Bind();
+ m_bounds_ubo.Bind();
+ m_rect_shader.Use();
+ glEnable(GL_PRIMITIVE_RESTART);
+ glPrimitiveRestartIndex(0xFFFFFFFF);
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
+ glDrawElements(GL_TRIANGLE_STRIP, m_rendered_filled * 5, GL_UNSIGNED_INT, 0);
+ glDrawElements(GL_LINE_LOOP, m_rendered_outline*5, GL_UNSIGNED_INT,(void*)(sizeof(uint32_t)*m_rendered_filled*5));
+ glDisableVertexAttribArray(0);
+ glDisable(GL_PRIMITIVE_RESTART);
+ if (m_colour.a < 1.0f)
+ {
+ glDisable(GL_BLEND);
+ }
+ m_cached_display.UnBind();
+ m_cached_display.Blit();
+
+}
+
+void View::ReRender()