-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIGLBindable.cpp
More file actions
29 lines (24 loc) · 864 Bytes
/
Copy pathIGLBindable.cpp
File metadata and controls
29 lines (24 loc) · 864 Bytes
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
#include "IGLBindable.h"
IGLBindable::IGLBindable() {}
void IGLBindable::PreBind(GLenum bindTarget) const
{
if (m_target_To_BoundIdsStack.find(bindTarget) == m_target_To_BoundIdsStack.end())
{
m_target_To_BoundIdsStack[bindTarget] = std::stack<GLint>();
}
GLint currentBoundId = 0;
glGetIntegerv(bindTarget, ¤tBoundId);
m_target_To_BoundIdsStack[bindTarget].push(currentBoundId);
}
GLint IGLBindable::PreUnBind(GLenum bindTarget) const
{
if (m_target_To_BoundIdsStack.find(bindTarget) == m_target_To_BoundIdsStack.end() ||
m_target_To_BoundIdsStack[bindTarget].empty())
{
std::cerr << "Unbinding non-binded GL target " << bindTarget << std::endl;
return 0;
}
GLint id = m_target_To_BoundIdsStack[bindTarget].top();
m_target_To_BoundIdsStack[bindTarget].pop();
return id;
}