From 095be9811eaccd92cee156b4c486fb92b77cdcd2 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 4 Apr 2011 00:01:39 +0200 Subject: Threaded VBO creation. A secondary memory-mapped VBO is filled in a separate thread, which replaces the main VBO when work is done. --- quadtree.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'quadtree.h') diff --git a/quadtree.h b/quadtree.h index 951a98e..b927dee 100644 --- a/quadtree.h +++ b/quadtree.h @@ -3,8 +3,18 @@ #include "vector.h" +#include + class Quadtree { public: + + struct UpdateThread { + Quadtree *tree; + float *buffer; + UpdateThread(Quadtree *t, float *b); + void operator()(); + }; + struct QuadNode { Quadtree *tree; QuadNode *parent; @@ -29,9 +39,15 @@ class Quadtree { }; float *heights; + float *thread_buffer; + size_t buf_size; + bool thread_done, thread_running; + boost::mutex vbo_lock; + boost::mutex node_lock; int width, height, levels; float init_time; QuadNode *root; + unsigned int temp_vbo; unsigned int vbo_object; unsigned int nodes; unsigned int vertices; @@ -43,6 +59,7 @@ class Quadtree { void create_nodes(int levels); unsigned int count_nodes(); void make_vbo(); + void update_vbo(); QuadNode *find(float x, float y, int level = -1); QuadNode *get_left(QuadNode *node); QuadNode *get_right(QuadNode *node); -- cgit v1.2.3