PeriDyno 1.0.0
Loading...
Searching...
No Matches
GraphicsObject.h
Go to the documentation of this file.
1
16
17#pragma once
18
19#include <typeinfo>
20#include <iostream>
21
22#include "Object.h"
23
24namespace dyno
25{
26 /*
27 * Base OpenGL object with ID and create/release interface
28 */
29 class GraphicsObject : public Object
30 {
31 protected:
32 virtual void create() = 0;
33 virtual void release() = 0;
34
35 virtual bool isValid() const { return id != 0xFFFFFFFF; }
36
37 protected:
38 GraphicsObject() = default;
39 virtual ~GraphicsObject() = default;
40
41 // should be non-copyable
44
45 public:
46 unsigned int id = 0xFFFFFFFF; // GL_INVALID_INDEX
47 };
48
49 // helper functions
50 unsigned int glCheckError_(const char* file, int line);
51 #define glCheckError() glCheckError_(__FILE__, __LINE__)
52
53#define GL_OBJECT(T) \
54 public: ~T() { if(isValid()) printf("Unreleased resource: %s(%d)\n", #T, id);}
55}
virtual void create()=0
GraphicsObject(const GraphicsObject &)=delete
GraphicsObject & operator=(const GraphicsObject &)=delete
virtual bool isValid() const
GraphicsObject()=default
virtual ~GraphicsObject()=default
virtual void release()=0
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
GLenum glCheckError_(const char *file, int line)