+ for (unsigned i = 0; i < m_object_renderers.size(); ++i)
+ {
+ m_object_renderers[i]->RenderUsingGPU();
+ }
+
+ glDisableVertexAttribArray(0);
+ if (m_colour.a < 1.0f)
+ {
+ glDisable(GL_BLEND);
+ }
+ }
+ else // Rasterise on CPU then blit texture to GPU
+ {
+ // Dynamically resize CPU rendering target pixels if needed
+ if (m_cpu_rendering_pixels == NULL || width*height > prev_width*prev_height)
+ {
+ delete [] m_cpu_rendering_pixels;
+ m_cpu_rendering_pixels = new uint8_t[width*height*4];
+ if (m_cpu_rendering_pixels == NULL)
+ Fatal("Could not allocate %d*%d*4 = %d bytes for cpu rendered pixels", width, height, width*height*4);
+ }
+ // Clear CPU rendering pixels
+ for (int i = 0; i < width*height*4; ++i)
+ m_cpu_rendering_pixels[i] = 255;
+
+ for (unsigned i = 0; i < m_object_renderers.size(); ++i)
+ {
+ m_object_renderers[i]->RenderUsingCPU(m_document.m_objects, *this, {m_cpu_rendering_pixels, width, height});
+ }
+ m_screen.RenderPixels(0,0,width, height, m_cpu_rendering_pixels); //TODO: Make this work :(
+ // Debug for great victory (do something similar for GPU and compare?)
+ ObjectRenderer::SaveBMP({m_cpu_rendering_pixels, width, height}, "cpu_rendering_last_frame.bmp");
+ }
+ m_cached_display.UnBind(); // resets render target to the screen
+ m_cached_display.Blit(); // blit FrameBuffer to screen
+}
+
+void View::UpdateObjBoundsVBO()
+{
+ m_objbounds_vbo.Invalidate();
+ m_objbounds_vbo.SetType(GraphicsBuffer::BufferTypeVertex);
+ if (m_use_gpu_transform)
+ {
+ m_objbounds_vbo.SetUsage(GraphicsBuffer::BufferUsageStaticDraw);
+ }
+ else
+ {
+ m_objbounds_vbo.SetUsage(GraphicsBuffer::BufferUsageDynamicDraw);
+ }
+ m_objbounds_vbo.Resize(m_document.ObjectCount()*sizeof(GPUObjBounds));
+
+ BufferBuilder<GPUObjBounds> obj_bounds_builder(m_objbounds_vbo.Map(false, true, true), m_objbounds_vbo.GetSize());
+