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