]> git.tdb.fi Git - libs/gl.git/blob - source/select.cpp
Add files
[libs/gl.git] / source / select.cpp
1 #include <GL/gl.h>
2 #include "select.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace GL {
8
9 vector<SelectRecord> *select_buf=0;
10 vector<uint> select_buf_int;
11
12 void select_buffer(vector<SelectRecord> &buf)
13 {
14         select_buf_int.resize(1024);
15         glSelectBuffer(select_buf_int.size(), &select_buf_int[0]);
16         select_buf=&buf;
17 }
18
19 void parse_select_records(const uint *buf, uint count, vector<SelectRecord> &tbuf)
20 {
21         uint i=0;
22         while(count--)
23         {
24                 SelectRecord record;
25
26                 uint n_names=buf[i++];
27                 record.min_depth=buf[i++];
28                 record.max_depth=buf[i++];
29
30                 record.names.reserve(n_names);
31                 while(n_names--)
32                         record.names.push_back(buf[i++]);
33                 
34                 tbuf.push_back(record);
35         }
36 }
37
38 void _parse_internal_select_records(uint count)
39 {
40         if(!select_buf)
41                 //XXX throw InvalidOperation();
42                 return;
43         parse_select_records(&select_buf_int[0], count, *select_buf);
44 }
45
46 } // namespace GL
47 } // namespace Msp