]> git.tdb.fi Git - libs/gl.git/blob - source/select.cpp
Windows compatibility:
[libs/gl.git] / source / select.cpp
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include "except.h"
9 #include "gl.h"
10 #include "select.h"
11
12 using namespace std;
13
14 namespace {
15
16 vector<Msp::GL::SelectRecord> *select_buf=0;
17 vector<Msp::GL::uint> select_buf_int;
18
19 }
20
21 namespace Msp {
22 namespace GL {
23
24 void select_buffer(vector<SelectRecord> &buf)
25 {
26         select_buf_int.resize(1024);
27         glSelectBuffer(select_buf_int.size(), &select_buf_int[0]);
28         select_buf=&buf;
29 }
30
31 void parse_select_records(const uint *buf, uint count, vector<SelectRecord> &tbuf)
32 {
33         uint i=0;
34         while(count--)
35         {
36                 SelectRecord record;
37
38                 uint n_names=buf[i++];
39                 record.min_depth=buf[i++];
40                 record.max_depth=buf[i++];
41
42                 record.names.reserve(n_names);
43                 while(n_names--)
44                         record.names.push_back(buf[i++]);
45                 
46                 tbuf.push_back(record);
47         }
48 }
49
50 void _parse_internal_select_records(uint count)
51 {
52         if(!select_buf)
53                 throw InvalidState("No select buffer specified");
54         parse_select_records(&select_buf_int[0], count, *select_buf);
55 }
56
57 } // namespace GL
58 } // namespace Msp