]> git.tdb.fi Git - libs/gl.git/blobdiff - source/select.cpp
Add files
[libs/gl.git] / source / select.cpp
diff --git a/source/select.cpp b/source/select.cpp
new file mode 100644 (file)
index 0000000..e989de4
--- /dev/null
@@ -0,0 +1,47 @@
+#include <GL/gl.h>
+#include "select.h"
+
+using namespace std;
+
+namespace Msp {
+namespace GL {
+
+vector<SelectRecord> *select_buf=0;
+vector<uint> select_buf_int;
+
+void select_buffer(vector<SelectRecord> &buf)
+{
+       select_buf_int.resize(1024);
+       glSelectBuffer(select_buf_int.size(), &select_buf_int[0]);
+       select_buf=&buf;
+}
+
+void parse_select_records(const uint *buf, uint count, vector<SelectRecord> &tbuf)
+{
+       uint i=0;
+       while(count--)
+       {
+               SelectRecord record;
+
+               uint n_names=buf[i++];
+               record.min_depth=buf[i++];
+               record.max_depth=buf[i++];
+
+               record.names.reserve(n_names);
+               while(n_names--)
+                       record.names.push_back(buf[i++]);
+               
+               tbuf.push_back(record);
+       }
+}
+
+void _parse_internal_select_records(uint count)
+{
+       if(!select_buf)
+               //XXX throw InvalidOperation();
+               return;
+       parse_select_records(&select_buf_int[0], count, *select_buf);
+}
+
+} // namespace GL
+} // namespace Msp