diff options
| author | chai <chaifix@163.com> | 2018-09-02 10:08:58 +0800 | 
|---|---|---|
| committer | chai <chaifix@163.com> | 2018-09-02 10:08:58 +0800 | 
| commit | 3bb587f0d7c471a70683fa7d26939d21968dea98 (patch) | |
| tree | 6ef9e75b5159dda0a8d1dc4ef8640be4eacc6343 /src | |
| parent | 862763a88f6b4a6cb6c034287c509a91776adf8b (diff) | |
*update
Diffstat (limited to 'src')
| -rw-r--r-- | src/libjin/Graphics/Canvas.cpp | 54 | ||||
| -rw-r--r-- | src/libjin/Graphics/Canvas.h | 11 | ||||
| -rw-r--r-- | src/libjin/Graphics/Drawable.cpp | 26 | ||||
| -rw-r--r-- | src/libjin/Graphics/Drawable.h | 43 | ||||
| -rw-r--r-- | src/libjin/Graphics/Font.cpp | 90 | ||||
| -rw-r--r-- | src/libjin/Graphics/Font.h | 35 | ||||
| -rw-r--r-- | src/libjin/Graphics/JSL.cpp | 12 | ||||
| -rw-r--r-- | src/libjin/Graphics/JSL.h | 4 | ||||
| -rw-r--r-- | src/libjin/Graphics/Shapes.h | 12 | ||||
| -rw-r--r-- | src/libjin/Graphics/Texture.cpp | 46 | ||||
| -rw-r--r-- | src/libjin/Graphics/Texture.h | 2 | ||||
| -rw-r--r-- | src/libjin/Graphics/Window.cpp | 2 | ||||
| -rw-r--r-- | src/libjin/Math/Vector.cpp | 22 | ||||
| -rw-r--r-- | src/libjin/Math/Vector.h | 18 | ||||
| -rw-r--r-- | src/libjin/math/vector.cpp | 22 | ||||
| -rw-r--r-- | src/libjin/math/vector.h | 18 | ||||
| -rw-r--r-- | src/lua/modules/graphics/graphics.cpp | 5 | ||||
| -rw-r--r-- | src/lua/modules/graphics/jsl.cpp | 13 | 
18 files changed, 198 insertions, 237 deletions
diff --git a/src/libjin/Graphics/Canvas.cpp b/src/libjin/Graphics/Canvas.cpp index 99f022d..c88429f 100644 --- a/src/libjin/Graphics/Canvas.cpp +++ b/src/libjin/Graphics/Canvas.cpp @@ -10,6 +10,8 @@ namespace jin  namespace graphics  { +    /*class member*/ GLint Canvas::cur = -1; +      /*class member*/ Canvas* Canvas::createCanvas(int w, int h)      {          return new Canvas(w, h); @@ -18,31 +20,15 @@ namespace graphics      Canvas::Canvas(int w, int h)           : Drawable(w, h)      { -        init(); -    } - -    Canvas::~Canvas() -    { -    } +        vertCoord[0] = 0; vertCoord[1] = 0; +        vertCoord[2] = 0; vertCoord[3] = h; +        vertCoord[4] = w; vertCoord[5] = h; +        vertCoord[6] = w; vertCoord[7] = 0; -    /*class member*/ GLint Canvas::cur = -1;  - -    bool Canvas::init() -    { -        setVertices( -            new float [DRAWABLE_V_SIZE] { -                0, 0, -                0, (float)height, -                (float)width, (float)height, -                (float)width, 0, -            }, -            new float [DRAWABLE_V_SIZE] { -                0, 1, -                0, 0, -                1, 0, -                1, 1 -            } -        ); +        textCoord[0] = 0; textCoord[1] = 1; +        textCoord[2] = 0; textCoord[3] = 0; +        textCoord[4] = 1; textCoord[5] = 0; +        textCoord[6] = 1; textCoord[7] = 1;          GLint current_fbo;          glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); @@ -56,18 +42,18 @@ namespace graphics          glBindTexture(GL_TEXTURE_2D, texture);          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); -        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); +        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);          glBindTexture(GL_TEXTURE_2D, 0);          glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);          GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); -         +          // unbind framebuffer          glBindFramebuffer(GL_FRAMEBUFFER, current_fbo); -         -        if (status != GL_FRAMEBUFFER_COMPLETE_EXT) -            return false; -        return true;  +    } + +    Canvas::~Canvas() +    {      }      bool Canvas::hasbind(GLint fbo) @@ -90,8 +76,8 @@ namespace graphics          glPushMatrix();          glLoadIdentity(); -        glViewport(0, 0, width, height); -        glOrtho(0, width, height, 0, -1, 1); +        glViewport(0, 0, size.x, size.y); +        glOrtho(0, size.x, size.y, 0, -1, 1);          // Switch back to modelview matrix          glMatrixMode(GL_MODELVIEW); @@ -110,8 +96,8 @@ namespace graphics          glBindFramebuffer(GL_FRAMEBUFFER, 0);          Window* wnd = Window::get(); -        int ww = wnd->getW(), -            wh = wnd->getH(); +        int ww = wnd->getW(); +        int wh = wnd->getH();          glViewport(0, 0, ww, wh); diff --git a/src/libjin/Graphics/Canvas.h b/src/libjin/Graphics/Canvas.h index 0d5635e..4e86e50 100644 --- a/src/libjin/Graphics/Canvas.h +++ b/src/libjin/Graphics/Canvas.h @@ -11,27 +11,18 @@ namespace graphics      class Canvas: public Drawable      {      public:  -          static Canvas* createCanvas(int w, int h); -          ~Canvas(); -         +          void bind();  -                  static void unbind(); -          static bool hasbind(GLint fbo);       protected: -          Canvas(int w, int h);          GLuint fbo;  - -        // current binded fbo           static GLint cur;  - -        bool init();      };  } // render  } // jin diff --git a/src/libjin/Graphics/Drawable.cpp b/src/libjin/Graphics/Drawable.cpp index cab6c50..799498e 100644 --- a/src/libjin/Graphics/Drawable.cpp +++ b/src/libjin/Graphics/Drawable.cpp @@ -9,34 +9,22 @@ namespace jin  {  namespace graphics  { -    Drawable::Drawable(int w, int h):texture(0), width(w), height(h), ancx(0), ancy(0), textCoord(0), vertCoord(0) +    Drawable::Drawable(int w, int h) +        : texture(0) +        , size() +        , anchor()      {      }      Drawable::~Drawable()      {          glDeleteTextures(1, &texture); -        delete[] vertCoord;  -        delete[] textCoord; -    } - -    void Drawable::setVertices(float* v, float* t) -    { -        // render area  -        if (vertCoord) -            delete[] vertCoord; -        vertCoord = v; - -        // textrue  -        if (textCoord)  -            delete[] textCoord;  -        textCoord = t;      }      void Drawable::setAnchor(int x, int y)      { -        ancx = x;  -        ancy = y; +        anchor.x = x;  +        anchor.y = y;      }      void Drawable::draw(int x, int y, float sx, float sy, float r) @@ -45,7 +33,7 @@ namespace graphics          if (! textCoord||! vertCoord) return;          static jin::math::Matrix t; -        t.setTransformation(x, y, r, sx, sy, ancx, ancy); +        t.setTransformation(x, y, r, sx, sy, anchor.x, anchor.y);          glEnable(GL_TEXTURE_2D); diff --git a/src/libjin/Graphics/Drawable.h b/src/libjin/Graphics/Drawable.h index 4e91adb..86cc919 100644 --- a/src/libjin/Graphics/Drawable.h +++ b/src/libjin/Graphics/Drawable.h @@ -3,7 +3,9 @@  #include "../modules.h"  #if JIN_MODULES_RENDER +#include "../math/Vector.h"  #include "../3rdparty/GLee/GLee.h" +  namespace jin   {  namespace graphics @@ -16,44 +18,23 @@ namespace graphics          virtual ~Drawable();          void setAnchor(int x, int y);  -                  void draw(int x, int y, float sx, float sy, float r); - -        inline int getWidth() const -        { -            return width; -        } - -        inline int getHeight() const  -        { -            return height; -        } - -        inline GLuint getTexture() const  -        {  -            return texture;  -        }; +        inline int getWidth() const { return size.x; } +        inline int getHeight() const { return size.y; } +        inline GLuint getTexture() const { return texture; }      protected: +        static const int DRAWABLE_V_SIZE = 8; -        const int DRAWABLE_V_SIZE = 8; - -        void setVertices(float* v, float* t); -         -        GLuint texture;  +        GLuint texture;          GLuint vbo; +        jin::math::Vector2 size; +        jin::math::Vector2 anchor; +        float vertCoord[DRAWABLE_V_SIZE]; +        float textCoord[DRAWABLE_V_SIZE]; -        int width, height; -         -        /* anchor point */  -        int ancx, ancy; -         -        // render coords -        float* textCoord; -        float* vertCoord; -      }; - +      } // render  } // jin diff --git a/src/libjin/Graphics/Font.cpp b/src/libjin/Graphics/Font.cpp index a107613..6be08e7 100644 --- a/src/libjin/Graphics/Font.cpp +++ b/src/libjin/Graphics/Font.cpp @@ -28,29 +28,26 @@ namespace graphics      // bitmap for saving font data      static unsigned char temp_bitmap[BITMAP_WIDTH * BITMAP_HEIGHT]; -    void Font::loadf(const char* path) +    void Font::loadFile(const char* path)      {          fread(ttf_buffer, 1, 1 << 20, fopen(path, "rb")); -         -        loadb(ttf_buffer); +        loadMemory(ttf_buffer);      }      /**      * load from memory       */ -    void Font::loadb(const unsigned char* data) +    void Font::loadMemory(const unsigned char* data)      { -        stbtt_BakeFontBitmap(data, 0, PIXEL_HEIGHT, temp_bitmap, BITMAP_WIDTH, BITMAP_HEIGHT, 32, 96, cdata);  +        if (data == nullptr) +            return; +        stbtt_BakeFontBitmap(data, 0, PIXEL_HEIGHT, temp_bitmap, BITMAP_WIDTH, BITMAP_HEIGHT, 32, ASCII_CHARACTER_NUM, asciiData);          glGenTextures(1, &texture);          glBindTexture(GL_TEXTURE_2D, texture); -         -        glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, BITMAP_WIDTH, -            BITMAP_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap); - +        glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, BITMAP_WIDTH, BITMAP_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap);          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); -                  glBindTexture(GL_TEXTURE_2D, 0);      } @@ -69,16 +66,12 @@ namespace graphics          return q;       } -    /** -    * render function draw mutiple times  -    * in loop  -    */      void Font::render( -        const char* text, // rendered text  -        float x, float y, // render position  -        int fheight,      // font height -        int spacing,      // font spacing  -        int lheight)      // line height +        const char* text,  +        float x, float y,  +        int fontHeight,    +        int spacing,       +        int lineHeight)         {          float _x = x,                _y = y;  @@ -95,38 +88,37 @@ namespace graphics          stbtt_aligned_quad q;          // render every given character -        int xc = x; -        int yc = y;  +        float xc = x; +        float yc = y; -        float factor = fheight / (float)PIXEL_HEIGHT; -         +        float factor = fontHeight / (float)PIXEL_HEIGHT; +        float texCoord[8]; +        float verCoord[8];          for (int i = 0; i < len; ++i)          {              char c = text[i];              if (c == '\n')              {                  xc = x;  -                yc += lheight; +                yc += lineHeight;                  continue;              }              // only support ASCII  -            Quad q = getCharQuad(cdata, 512, 512, c - 32); +            Quad q = getCharQuad(asciiData, 512, 512, c - 32);              float s0 = q.x,                  s1 = q.x + q.w,                  t0 = q.y,                  t1 = q.y + q.h;              // texture quad -            float tc[] = { -               s0, t1,  -               s1, t1,  -               s1, t0,  -               s0, t0  -            }; +            texCoord[0] = s0; texCoord[1] = t1; +            texCoord[2] = s1; texCoord[3] = t1; +            texCoord[4] = s1; texCoord[5] = t0; +            texCoord[6] = s0; texCoord[7] = t0;              // character bound box  -            stbtt_bakedchar box = cdata[c - 32]; +            stbtt_bakedchar box = asciiData[c - 32];              float width    = factor * (box.x1 - box.x0);              float height   = factor * (box.y1 - box.y0); @@ -137,18 +129,16 @@ namespace graphics              float xadvance = factor * box.xadvance;              // render quad -            float vc[] = { -                xc + xoffset,         yc + height + yoffset, -                xc + width + xoffset, yc + height + yoffset, -                xc + width + xoffset, yc + yoffset, -                xc + xoffset,         yc + yoffset -            }; +            verCoord[0] = xc + xoffset;         verCoord[1] = yc + height + yoffset; +            verCoord[2] = xc + width + xoffset; verCoord[3] = yc + height + yoffset; +            verCoord[4] = xc + width + xoffset; verCoord[5] = yc + yoffset; +            verCoord[6] = xc + xoffset;         verCoord[7] = yc + yoffset;              // forward to next character               xc += xadvance + spacing; -            glTexCoordPointer(2, GL_FLOAT, 0, tc); -            glVertexPointer(2, GL_FLOAT, 0, vc); +            glTexCoordPointer(2, GL_FLOAT, 0, texCoord); +            glVertexPointer(2, GL_FLOAT, 0, verCoord);              glDrawArrays(GL_QUADS, 0, 4);          } @@ -159,26 +149,26 @@ namespace graphics          glDisable(GL_TEXTURE_2D);      } -    void Font::box(const char* str, int fheight, int spacing, int lheight, int* w, int * h) +    void Font::box(const char* text, int fontHeight, int spacing, int lineHeight, int* w, int * h)      { -        int len = strlen(str); +        int len = strlen(text);          float xc = 0; -        int yc = len ? lheight: 0; +        int yc = len ? lineHeight : 0;          int maxX = 0;  -        float factor = fheight / (float)PIXEL_HEIGHT; +        float factor = fontHeight / (float)PIXEL_HEIGHT; -         for (int i = 0; i < len; ++i) +        for (int i = 0; i < len; ++i)          { -            char c = str[i];  +            char c = text[i];              if (c == '\n')              { -                yc += lheight;  +                yc += lineHeight;                  xc = 0;                  continue;              } -            stbtt_bakedchar box = cdata[c - 32]; +            stbtt_bakedchar box = asciiData[c - 32];              xc += factor * box.xadvance + spacing;              if (xc > maxX) maxX = xc; @@ -188,7 +178,7 @@ namespace graphics          *h = yc;      } -} -} +} // graphics +} // jin  #endif // JIN_MODULES_RENDER
\ No newline at end of file diff --git a/src/libjin/Graphics/Font.h b/src/libjin/Graphics/Font.h index 7fc96e2..176669c 100644 --- a/src/libjin/Graphics/Font.h +++ b/src/libjin/Graphics/Font.h @@ -19,43 +19,32 @@ namespace graphics      class Font: public Drawable      {      public:  -          Font();  -        /** -        * load ttf font data from .ttf  -        */ -        void loadf(const char* file);  - -        /** -        * load ttf font data from memory  -        */ -        void loadb(const unsigned char* data); +        void loadFile(const char* file);  +        void loadMemory(const unsigned char* data); -        /** -        * render text to screen  -        */          void render( -            const char* str,  // rendered text  +            const char* text, // rendered text               float x, float y, // render position  -            int fheight,      // font size  +            int fondSize,     // font size               int spacing,      // font spacing  -            int lheight       // line height +            int lineHeight    // line height          ); - -        void box(const char* str, int fheight, int spacing, int lheight, int* w, int * h);  +        void box(const char* text, int fontHeight, int spacing, int lineHeight, int* w, int * h);       private:  -          /** -        * ASCII 32(space)..126(~) is 95 glyphs  +        * ASCII 32(space)..126(~) 95 glyphs          */ -        stbtt_bakedchar cdata[96]; +        static const int ASCII_CHARACTER_NUM = 96; + +        stbtt_bakedchar asciiData[ASCII_CHARACTER_NUM];      }; -} -} +} // graphics +} // jin  #endif // JIN_MODULES_RENDER  #endif // __JIN_FONT_H
\ No newline at end of file diff --git a/src/libjin/Graphics/JSL.cpp b/src/libjin/Graphics/JSL.cpp index fb6279a..e22e872 100644 --- a/src/libjin/Graphics/JSL.cpp +++ b/src/libjin/Graphics/JSL.cpp @@ -54,7 +54,6 @@ void main()          GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);          glShaderSource(fragmentShader, 1, (const GLchar**)&fs, NULL);          glCompileShader(fragmentShader); -          pid = glCreateProgram();          glAttachShader(pid, fragmentShader);          glLinkProgram(pid); @@ -84,7 +83,6 @@ void main()      void JSLProgram::sendFloat(const char* variable, float number)      {          checkJSL(); -          int loc = glGetUniformLocation(pid, variable);           glUniform1f(loc, number);      } @@ -92,7 +90,6 @@ void main()      void JSLProgram::sendTexture(const char* variable, const Texture* tex)      {          checkJSL(); -          GLint location = glGetUniformLocation(pid, variable);          if (location == -1)              return; @@ -106,7 +103,6 @@ void main()      void JSLProgram::sendCanvas(const char* variable, const Canvas* canvas)      {          checkJSL(); -          GLint location = glGetUniformLocation(pid, variable);          if (location == -1)              return;  @@ -120,7 +116,6 @@ void main()      void JSLProgram::sendVec2(const char* name, float x, float y)      {          checkJSL(); -          int loc = glGetUniformLocation(pid, name);          glUniform2f(loc, x, y);      } @@ -128,7 +123,6 @@ void main()      void JSLProgram::sendVec3(const char* name, float x, float y, float z)      {          checkJSL(); -          int loc = glGetUniformLocation(pid, name);          glUniform3f(loc, x, y, z);      } @@ -136,7 +130,6 @@ void main()      void JSLProgram::sendVec4(const char* name, float x, float y, float z, float w)      {          checkJSL(); -          int loc = glGetUniformLocation(pid, name);          glUniform4f(loc, x, y, z, w);      } @@ -144,7 +137,6 @@ void main()      void JSLProgram::sendColor(const char* name, const color* col)       {          checkJSL(); -          int loc = glGetUniformLocation(pid, name);          glUniform4f(loc,              col->rgba.r / 255.f, @@ -154,7 +146,7 @@ void main()          );      } -} -} +} // graphics +} // jin  #endif // JIN_MODULES_RENDER
\ No newline at end of file diff --git a/src/libjin/Graphics/JSL.h b/src/libjin/Graphics/JSL.h index 8d4712b..b9198fb 100644 --- a/src/libjin/Graphics/JSL.h +++ b/src/libjin/Graphics/JSL.h @@ -67,8 +67,8 @@ namespace graphics      }; -} -} +} // graphics +} // jin  #endif // JIN_MODULES_RENDER  #endif // __JIN_JSL_H
\ No newline at end of file diff --git a/src/libjin/Graphics/Shapes.h b/src/libjin/Graphics/Shapes.h index afd4f7a..1ef93a1 100644 --- a/src/libjin/Graphics/Shapes.h +++ b/src/libjin/Graphics/Shapes.h @@ -20,24 +20,18 @@ namespace graphics      /**      * TODO: -    *     drawPixels(int n, points) +    *   drawPixels(int n, points)      */      extern void line(int x1, int y1, int x2, int y2); -      extern void rect(RENDER_MODE mode, int x, int y, int w, int h); -      extern void triangle(RENDER_MODE mode, int x1, int y1, int x2, int y2, int x3, int y3); -      extern void circle(RENDER_MODE mode, int x, int y, int r); -      extern void point(int x, int y); -      extern void points(int n, GLshort* p, GLubyte* c); -      extern void polygon(RENDER_MODE mode, float* p, int count); -} -} +} // graphics +} // jin  #endif // JIN_MODULES_RENDER  #endif // __JIN_GEOMETRY_H
\ No newline at end of file diff --git a/src/libjin/Graphics/Texture.cpp b/src/libjin/Graphics/Texture.cpp index 4c6707d..f3c08fb 100644 --- a/src/libjin/Graphics/Texture.cpp +++ b/src/libjin/Graphics/Texture.cpp @@ -57,46 +57,46 @@ namespace graphics      color Texture::getPixel(int x, int y)      { -        if (without(x, 0, width) || without(y, 0, height)) +        int w = size.x;  +        int h = size.y; +        if (without(x, 0, w) || without(y, 0, h))          {              return { 0 };          } -        return pixels[x + y * width]; +        return pixels[x + y * w];      } -    bool Texture::loadb(const void* b, size_t size) +    bool Texture::loadb(const void* b, size_t s)      {          // ʹstbi_load_from_memory -        unsigned char* textureData = stbi_load_from_memory((unsigned char *)b, size, &width, &height, NULL, STBI_rgb_alpha); +        int w; +        int h; +        unsigned char* textureData = stbi_load_from_memory((unsigned char *)b, s, &w, &h, NULL, STBI_rgb_alpha);          if (textureData == 0) return false; +        size.x = w;  +        size.y = h;          pixels = (color*)textureData;          glGenTextures(1, &texture);          glBindTexture(GL_TEXTURE_2D, texture);          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); -        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, -            height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData); +        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData); -        // set render vertices  -        Drawable::setVertices( -            new float [DRAWABLE_V_SIZE] { -            0, 0, -            0, (float)height, -            (float)width, (float)height, -            (float)width, 0, -        }, -            new float [DRAWABLE_V_SIZE] { -                0, 0, -                0, 1, -                1, 1, -                1, 0 -            } -            ); +        vertCoord[0] = 0; vertCoord[1] = 1; +        vertCoord[2] = 0; vertCoord[3] = h; +        vertCoord[4] = w; vertCoord[5] = h; +        vertCoord[6] = w; vertCoord[7] = 1; + +        textCoord[0] = 0; textCoord[1] = 0; +        textCoord[2] = 0; textCoord[3] = 1; +        textCoord[4] = 1; textCoord[5] = 1; +        textCoord[6] = 1; textCoord[7] = 0;          return true;       } -} -} + +} // graphics +} // jin  #endif // JIN_MODULES_RENDER
\ No newline at end of file diff --git a/src/libjin/Graphics/Texture.h b/src/libjin/Graphics/Texture.h index 1e7a2f5..947021a 100644 --- a/src/libjin/Graphics/Texture.h +++ b/src/libjin/Graphics/Texture.h @@ -15,7 +15,6 @@ namespace graphics      {      public: -                 static Texture* createTexture(const char* file);          static Texture* createTexture(const void* mem, size_t size); @@ -24,7 +23,6 @@ namespace graphics          color getPixel(int x, int y);      private: -          Texture();          bool loadb(const void* buffer, size_t size); diff --git a/src/libjin/Graphics/Window.cpp b/src/libjin/Graphics/Window.cpp index 708a30f..f4ca9aa 100644 --- a/src/libjin/Graphics/Window.cpp +++ b/src/libjin/Graphics/Window.cpp @@ -18,7 +18,7 @@ namespace graphics      {  #if JIN_DEBUG          Loghelper::log(Loglevel::LV_INFO, "Init window system"); -#endif // JIN_DEBUG +#endif          if (SDL_Init(SDL_INIT_VIDEO) < 0)              return false;  diff --git a/src/libjin/Math/Vector.cpp b/src/libjin/Math/Vector.cpp index f26d0c4..3e44d70 100644 --- a/src/libjin/Math/Vector.cpp +++ b/src/libjin/Math/Vector.cpp @@ -1,2 +1,24 @@  #include "vector.h" +namespace jin +{ +namespace math +{ + +    Vector2::Vector2()  +        :x(0), y(0)  +    { +    } +     +    Vector2::Vector2(float _x, float _y)  +        : x(_x), y(_y)  +    { +    }; +     +    Vector2::Vector2(const Vector2& v)  +        : x(v.x), y(v.y) +    { +    } + +} +}
\ No newline at end of file diff --git a/src/libjin/Math/Vector.h b/src/libjin/Math/Vector.h index 43e249e..0fbdc87 100644 --- a/src/libjin/Math/Vector.h +++ b/src/libjin/Math/Vector.h @@ -5,10 +5,20 @@ namespace jin  {  namespace math  { -     -     -} -} +    class Vector2 +    { +    public: +        Vector2(); +        Vector2(float _x, float _y); +        Vector2(const Vector2& v); + +        float x;  +        float y; + +    }; + +} // math +} // jin  #endif
\ No newline at end of file diff --git a/src/libjin/math/vector.cpp b/src/libjin/math/vector.cpp index f26d0c4..3e44d70 100644 --- a/src/libjin/math/vector.cpp +++ b/src/libjin/math/vector.cpp @@ -1,2 +1,24 @@  #include "vector.h" +namespace jin +{ +namespace math +{ + +    Vector2::Vector2()  +        :x(0), y(0)  +    { +    } +     +    Vector2::Vector2(float _x, float _y)  +        : x(_x), y(_y)  +    { +    }; +     +    Vector2::Vector2(const Vector2& v)  +        : x(v.x), y(v.y) +    { +    } + +} +}
\ No newline at end of file diff --git a/src/libjin/math/vector.h b/src/libjin/math/vector.h index 43e249e..0fbdc87 100644 --- a/src/libjin/math/vector.h +++ b/src/libjin/math/vector.h @@ -5,10 +5,20 @@ namespace jin  {  namespace math  { -     -     -} -} +    class Vector2 +    { +    public: +        Vector2(); +        Vector2(float _x, float _y); +        Vector2(const Vector2& v); + +        float x;  +        float y; + +    }; + +} // math +} // jin  #endif
\ No newline at end of file diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp index 98a4fef..92168ad 100644 --- a/src/lua/modules/graphics/graphics.cpp +++ b/src/lua/modules/graphics/graphics.cpp @@ -8,6 +8,7 @@ namespace jin  {  namespace lua  { +  	using namespace jin::graphics;      using jin::filesystem::Filesystem;      using jin::filesystem::Buffer; @@ -404,7 +405,7 @@ namespace lua                  exit(1);              }              fs->read(path, &b); -            font->loadb((const unsigned char*)b.data); +            font->loadMemory((const unsigned char*)b.data);          }          proxy->bind(new Ref<Font>(font, JIN_GRAPHICS_FONT));          return 1; @@ -420,7 +421,7 @@ namespace lua                  #include "lua/resources/font.ttf.h"                  // load default font                  context.defaultFont = new Font(); -                context.defaultFont->loadb(font_ttf); +                context.defaultFont->loadMemory(font_ttf);              }              context.curFont = context.defaultFont;              return 0; diff --git a/src/lua/modules/graphics/jsl.cpp b/src/lua/modules/graphics/jsl.cpp index 9714695..c2808ca 100644 --- a/src/lua/modules/graphics/jsl.cpp +++ b/src/lua/modules/graphics/jsl.cpp @@ -18,19 +18,6 @@ namespace lua  		return proxy->getRef<JSLProgram>();      } -    static enum VARIABLE_TYPE -    { -        INVALID = 0, - -        NUMBER, -        IMAGE, -        CANVAS, -        VEC2, -        VEC3, -        VEC4,  -        COLOR, -    }; -      /**      * jsl:sendNumber("variable", 0.1)      */  | 
