aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Drawable.h
blob: 29f1946494a3619691d5ceaeeb989010c312a2c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef __LIBJIN_DRAWABLE
#define __LIBJIN_DRAWABLE
#include "../jin_configuration.h"
#if LIBJIN_MODULES_RENDER

#include "../math/Quad.h"
#include "../math/Vector2.hpp"
#include "OpenGL.h"
#include "Bitmap.h"

namespace jin 
{
    namespace graphics
    {

        class Drawable
        {
        public:
            Drawable(int w = 0, int h = 0);
            Drawable(const Bitmap* bitmap);
            virtual ~Drawable();

            void setAnchor(int x, int y); 
            void draw(int x, int y, float sx = 1, float sy = 1, float r = 0);
            void draw(const math::Quad& slice, int x, int y, float sx = 1, float sy = 1, float r = 0, float ax = 0, float ay = 0);
            inline int getWidth() const { return size.w; }
            inline int getHeight() const { return size.h; }
            inline GLuint getTexture() const { return texture; }

        protected:
            static const int DRAWABLE_V_SIZE = 8;

            GLuint texture;
            GLuint vbo;
            /* TODO: vertex buffer object */
            /* GLuint vbo; */
            jin::math::Vector2<unsigned int> size;
            jin::math::Vector2<int> anchor;
            float vertex_coords[DRAWABLE_V_SIZE];
            float texture_coords[DRAWABLE_V_SIZE];
        
        };
    
    } // namespace render
} // namespace jin

#endif // LIBJIN_MODULES_RENDER
#endif // __LIBJIN_DRAWABLE