Initial Commit with small working example.

This commit is contained in:
David Vereb
2017-05-23 16:40:02 -04:00
commit b0e17c96d3
7 changed files with 124 additions and 0 deletions

35
GraphicsObject.h Normal file
View File

@@ -0,0 +1,35 @@
#ifndef GRAPHICSOBJECT_H
#define GRAPHICSOBJECT_H
class GraphicsObject
{
public:
// 2nd arg: pointer to callback function that takes a reference to an int as an argument
GraphicsObject(int set_x)
{
x = set_x;
user_data = NULL;
callback = NULL; // function pointer
}
GraphicsObject(void (*set_callback)(int&, void*), void *set_user_data)
{
x = 0;
user_data = set_user_data;
callback = set_callback; // function pointer
}
int X()
{
// If you are SUPPOSED to callback, ...
if(callback)
// ... do so to ask for the new X value
callback(x, user_data);
return x; // either this was just set by callback, or it was always set by constructor.
}
//private:
int x;
void *user_data;
private:
void (*callback)(int&, void*);
};
#endif