1
0
Fork 0

Define classes as structs

for default public access and inheritance
This commit is contained in:
Meoweg 2015-11-13 10:47:30 +00:00
parent 9b03876a3e
commit cef70d5c0f
11 changed files with 20 additions and 31 deletions

View File

@ -4,10 +4,9 @@
#include "transformation.hpp" #include "transformation.hpp"
#include "scene.hpp" #include "scene.hpp"
class Camera : struct Camera :
public Transformation Transformation
{ {
public:
inline Camera(const Scene &scene) : _scene(scene) {} inline Camera(const Scene &scene) : _scene(scene) {}
inline void draw() const; inline void draw() const;

View File

@ -3,9 +3,8 @@
#include "texture.hpp" #include "texture.hpp"
class Material struct Material
{ {
public:
inline void use() const; inline void use() const;
const Texture *texture; const Texture *texture;

View File

@ -7,12 +7,11 @@
#include <string> #include <string>
#include <map> #include <map>
class Mtllib: struct Mtllib:
public Resource Resource
{ {
RESOURCE(Mtllib) RESOURCE(Mtllib)
public:
const Material *operator[](const std::string &name) const; const Material *operator[](const std::string &name) const;
private: private:

View File

@ -6,10 +6,9 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
class Object : struct Object :
public Transformation Transformation
{ {
public:
Object(const Model &model) : _model(model) {}; Object(const Model &model) : _model(model) {};
void draw(const glm::mat4 &mvp) const; void draw(const glm::mat4 &mvp) const;

View File

@ -6,12 +6,11 @@
#include <string> #include <string>
class Program: struct Program:
public Resource Resource
{ {
RESOURCE(Program) RESOURCE(Program)
public:
void use() const; void use() const;
GLuint get_uniform_location(const GLchar *name) const; GLuint get_uniform_location(const GLchar *name) const;

View File

@ -3,17 +3,17 @@
#include "store.hpp" #include "store.hpp"
class Resource struct Resource
{ {
friend class Store; private:
friend struct Store;
__attribute__((unused)) // Used by friend class Store __attribute__((unused)) // Used by friend class Store
unsigned long _ref_count = 0; unsigned long _ref_count = 0;
}; };
#define RESOURCE(T) \ #define RESOURCE(T) \
private: \ friend struct ::Store; \
friend class ::Store; \
T(Store &store, const std::string &name); \ T(Store &store, const std::string &name); \
static const std::string filename(const std::string &name); static const std::string filename(const std::string &name);

View File

@ -7,9 +7,8 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
class Scene struct Scene
{ {
public:
inline Scene &operator <<(Object *object); inline Scene &operator <<(Object *object);
inline void draw(const glm::mat4 &mvp) const; inline void draw(const glm::mat4 &mvp) const;

View File

@ -3,9 +3,8 @@
#include "gl.hpp" #include "gl.hpp"
class Shader struct Shader
{ {
public:
Shader(GLenum type, const char *filename); Shader(GLenum type, const char *filename);
inline GLuint id() const { return _id; }; inline GLuint id() const { return _id; };

View File

@ -5,11 +5,10 @@
#include <string> #include <string>
#include <map> #include <map>
class Resource; struct Resource;
class Store struct Store
{ {
public:
template <class T> template <class T>
const T *load(const std::string &name); const T *load(const std::string &name);

View File

@ -6,13 +6,11 @@
#include <string> #include <string>
class Texture: struct Texture:
public Resource Resource
{ {
RESOURCE(Texture) RESOURCE(Texture)
public:
void use() const; void use() const;
private: private:

View File

@ -3,9 +3,8 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
class Transformation struct Transformation
{ {
public:
glm::mat4 transformation() const; glm::mat4 transformation() const;
glm::mat4 base; glm::mat4 base;