-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsorted_scene.cpp
57 lines (49 loc) · 1 KB
/
sorted_scene.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "scene.hpp"
#include "utility.hpp"
void renderable::update(float)
{
}
void sorted_batch::add(renderable* b)
{
renderables_.insert(b);
}
void sorted_batch::remove(renderable* b)
{
renderables_.erase(b);
}
state_set* sorted_batch::create_state_set()
{
state_set* s = device_->create_state_set();
state_sets_.push_back(s);
return s;
}
void sorted_batch::remove_state_set(state_set* s)
{
//std::find(
}
void sorted_batch::update(float t)
{
FOR_EACH(renderable_set, it, renderables_)
{
(*it)->update(t);
}
}
void sorted_batch::present()
{
using std::swap;
state_set_list::iterator it = state_sets_.begin();
state_set_list::const_iterator end = state_sets_.end();
if(it == end)
return;
state_set_list::iterator previous = it;
device_->present(*it);
++it;
while(it != end) {
device_->present(*it);
// Partial bubble sort
//if((*it)->less(*previous))
// swap(*it, *previous);
previous = it;
++it;
}
}