Skip to content

Instantly share code, notes, and snippets.

@FRex
Created September 30, 2017 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FRex/6f80ef13eb12511d4d558162729b8709 to your computer and use it in GitHub Desktop.
Save FRex/6f80ef13eb12511d4d558162729b8709 to your computer and use it in GitHub Desktop.
#include <iostream>
class Ensurer
{
public:
void bind(int ptr, bool texturing)
{
std::printf("bind(%d, %s)\n", ptr, texturing ? "true" : "false");
if(ptr != m_ptr)
{
m_ptr = ptr;
m_texturing = false;
std::printf("Ptr changed, binding color and vertices for %d\n", m_ptr);
}
if(!m_texturing && texturing)
{
std::printf("Texturing got enabled, binding texture for %d\n", m_ptr);
m_texturing = true;
}
}
private:
int m_ptr = 0;
bool m_texturing = false;
};
int main(int argc, char ** argv)
{
Ensurer ens;
ens.bind(1, false);
ens.bind(1, true);
ens.bind(1, false);
ens.bind(2, false);
ens.bind(3, true);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment