+ Rect obj_bounds;
+ if (m_use_gpu_transform)
+ {
+ obj_bounds = m_document.m_objects.bounds[id];
+ }
+ else
+ {
+ obj_bounds = TransformToViewCoords(m_document.m_objects.bounds[id]);
+ }
+ GPUObjBounds gpu_bounds = {
+ (float)Float(obj_bounds.x),
+ (float)Float(obj_bounds.y),
+ (float)Float(obj_bounds.x + obj_bounds.w),
+ (float)Float(obj_bounds.y + obj_bounds.h)
+ };
+ obj_bounds_builder.Add(gpu_bounds);
+
+ }
+ m_objbounds_vbo.UnMap();
+ m_buffer_dirty = false;
+}
+
+void View::PrepareRender()
+{
+ // TODO: Error check here.
+ m_rect_outline_shader.AttachGeometryProgram(RECT_OUTLINE_GEOM);
+ m_rect_outline_shader.AttachVertexProgram(RECT_VERT);
+ m_rect_outline_shader.AttachFragmentProgram(RECT_FRAG);
+ m_rect_outline_shader.Link();
+ m_rect_outline_shader.Use();
+ glUniform4f(m_rect_outline_shader.GetUniformLocation("colour"), m_colour.r, m_colour.g, m_colour.b, m_colour.a);
+
+ m_rect_filled_shader.AttachGeometryProgram(RECT_FILLED_GEOM);
+ m_rect_filled_shader.AttachVertexProgram(RECT_VERT);
+ m_rect_filled_shader.AttachFragmentProgram(RECT_FRAG);
+ m_rect_filled_shader.Link();
+ m_rect_filled_shader.Use();
+ glUniform4f(m_rect_filled_shader.GetUniformLocation("colour"), m_colour.r, m_colour.g, m_colour.b, m_colour.a);
+
+ m_circle_filled_shader.AttachGeometryProgram(CIRCLE_FILLED_GEOM);
+ m_circle_filled_shader.AttachVertexProgram(RECT_VERT);
+ m_circle_filled_shader.AttachFragmentProgram(CIRCLE_FRAG);
+ m_circle_filled_shader.Link();
+ m_circle_filled_shader.Use();
+ glUniform4f(m_circle_filled_shader.GetUniformLocation("colour"), m_colour.r, m_colour.g, m_colour.b, m_colour.a);
+
+ m_bounds_ubo.SetType(GraphicsBuffer::BufferTypeUniform);
+ m_bounds_ubo.SetUsage(GraphicsBuffer::BufferUsageStreamDraw);
+
+ m_outline_ibo.SetUsage(GraphicsBuffer::BufferUsageStaticDraw);
+ m_outline_ibo.SetType(GraphicsBuffer::BufferTypeIndex);
+ m_outline_ibo.Resize(m_document.ObjectCount() * 2 * sizeof(uint32_t));
+ BufferBuilder<uint32_t> outline_builder(m_outline_ibo.Map(false, true, true), m_outline_ibo.GetSize());
+
+ m_filled_ibo.SetUsage(GraphicsBuffer::BufferUsageStaticDraw);
+ m_filled_ibo.SetType(GraphicsBuffer::BufferTypeIndex);
+ m_filled_ibo.Resize(m_document.ObjectCount() * 2 * sizeof(uint32_t));
+ BufferBuilder<uint32_t> filled_builder(m_filled_ibo.Map(false, true, true), m_filled_ibo.GetSize());
+
+ m_circle_ibo.SetUsage(GraphicsBuffer::BufferUsageStaticDraw);
+ m_circle_ibo.SetType(GraphicsBuffer::BufferTypeIndex);
+ m_circle_ibo.Resize(m_document.ObjectCount() * 2 * sizeof(uint32_t));
+ BufferBuilder<uint32_t> circle_builder(m_circle_ibo.Map(false, true, true), m_circle_ibo.GetSize());
+
+ m_rendered_filled = m_rendered_outline = m_rendered_circle = 0;
+ uint32_t currentIndex = 0;
+ for (unsigned id = 0; id < m_document.ObjectCount(); ++id)
+ {
+ if (m_document.m_objects.types[id] == RECT_OUTLINE)
+ {
+ outline_builder.Add(currentIndex++);
+ outline_builder.Add(currentIndex++);
+ m_rendered_outline++;
+ }
+ else if (m_document.m_objects.types[id] == RECT_FILLED)
+ {
+ filled_builder.Add(currentIndex++);
+ filled_builder.Add(currentIndex++);
+ m_rendered_filled++;
+ }
+ else
+ {
+ circle_builder.Add(currentIndex++);
+ circle_builder.Add(currentIndex++);
+ m_rendered_circle++;
+ }
+