54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
/* /\ +--------------------------------------------------------------+
|
|
____/ \____ /| - zlib/MIT/Unlicenced game framework licensed to freely use, |
|
|
\ / / | copy, modify and sell without restriction |
|
|
+--\ ^__^ /--+ | |
|
|
| ~/ \~ | | - originally created at [http://nugget.fun] |
|
|
| ~~~~~~~~~~~~ | +--------------------------------------------------------------+
|
|
| SPACE ~~~~~ | /
|
|
| ~~~~~~~ BOX |/
|
|
+--------------+
|
|
|
|
[GLObject.hpp]
|
|
|
|
The abstract GLObject class is meant to be inherited by specific types of OpenGL objects,
|
|
for example Textures or Buffer objects. It stores the object's ID and declares virtual
|
|
functions for generating, binding, and destroying the object.
|
|
|
|
*/
|
|
|
|
#ifndef GLObject_h_
|
|
#define GLObject_h_
|
|
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <functional>
|
|
|
|
/* include Open GL */
|
|
#if defined(__EMSCRIPTEN__)
|
|
#include <GL/glew.h>
|
|
#else
|
|
#include "glew/glew.h"
|
|
#endif
|
|
|
|
class GLObject
|
|
{
|
|
|
|
protected:
|
|
|
|
std::shared_ptr<GLuint> object_id = nullptr;
|
|
std::function<void(GLuint*)> deleter = nullptr;
|
|
|
|
public:
|
|
|
|
GLObject(std::function<void(GLuint*)>);
|
|
virtual void generate() = 0;
|
|
virtual void bind() const = 0;
|
|
void id(GLuint);
|
|
GLuint id() const;
|
|
bool generated() const;
|
|
virtual ~GLObject() = default;
|
|
|
|
};
|
|
|
|
#endif
|