aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-22 21:46:24 +0800
committerchai <chaifix@163.com>2018-10-22 21:46:24 +0800
commit6dc75930fe5fe02f1af5489917752d315cf9e48f (patch)
treec634d6997d58af783e3866755fc38a96f97806ac /src
parent8c0da1990d6e7f9ad19c5270c0fdee848af829a1 (diff)
*修改graphic接口
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Graphics/Font/je_texture_font.cpp5
-rw-r--r--src/libjin/Graphics/je_canvas.cpp4
-rw-r--r--src/libjin/Graphics/je_graphic.h17
3 files changed, 12 insertions, 14 deletions
diff --git a/src/libjin/Graphics/Font/je_texture_font.cpp b/src/libjin/Graphics/Font/je_texture_font.cpp
index 2c04815..9651c1a 100644
--- a/src/libjin/Graphics/Font/je_texture_font.cpp
+++ b/src/libjin/Graphics/Font/je_texture_font.cpp
@@ -101,8 +101,9 @@ namespace JinEngine
}
glyphinfolist[glyphinfolist.size() - 1].count += 4;
// normalized
- float nx = glyph->x / (float)mSize.w, ny = glyph->y / (float)mSize.h;
- float nw = glyph->w / (float)mSize.w, nh = glyph->h / (float)mSize.h;
+ float w = getWidth(), h = getHeight();
+ float nx = glyph->x / w, ny = glyph->y / h;
+ float nw = glyph->w / w, nh = glyph->h / h;
glyphvertices_push(p.x, p.y, nx, ny);
glyphvertices_push(p.x, p.y + glyph->h, nx, ny + nh);
glyphvertices_push(p.x + glyph->w, p.y + glyph->h, nx + nw, ny + nh);
diff --git a/src/libjin/Graphics/je_canvas.cpp b/src/libjin/Graphics/je_canvas.cpp
index 3841206..7e0858b 100644
--- a/src/libjin/Graphics/je_canvas.cpp
+++ b/src/libjin/Graphics/je_canvas.cpp
@@ -65,8 +65,8 @@ namespace JinEngine
if (isBinded(canvas)) return;
current = canvas;
gl.bindFrameBuffer(canvas->fbo);
- int w = canvas->mSize.w;
- int h = canvas->mSize.h;
+ int w = canvas->getWidth();
+ int h = canvas->getHeight();
// Set view port to canvas.
glViewport(0, 0, w, h);
gl.ProjectionMatrix.setOrtho(0, w, 0, h, -1, 1);
diff --git a/src/libjin/Graphics/je_graphic.h b/src/libjin/Graphics/je_graphic.h
index d7e3254..fb6b19e 100644
--- a/src/libjin/Graphics/je_graphic.h
+++ b/src/libjin/Graphics/je_graphic.h
@@ -1,5 +1,5 @@
-#ifndef __JE_DRAWABLE
-#define __JE_DRAWABLE
+#ifndef __JE_GRAPHIC_H
+#define __JE_GRAPHIC_H
#include "../core/je_configuration.h"
#if defined(jin_graphics)
@@ -73,16 +73,13 @@ namespace JinEngine
void setFilter(GLint min, GLint max);
protected:
- static const int DRAWABLE_V_SIZE = 8;
-
GLuint mTexture;
-
- // Size of drawable thing.
- JinEngine::Math::Vector2<uint> mSize;
+ private:
+ JinEngine::Math::Vector2<uint> mSize;
// Screen coordinates and uv coordinates.
- float mVertexCoords[DRAWABLE_V_SIZE];
- float mTextureCoords[DRAWABLE_V_SIZE];
+ float mVertexCoords[8];
+ float mTextureCoords[8];
};
@@ -91,4 +88,4 @@ namespace JinEngine
#endif // defined(jin_graphics)
-#endif // __JE_DRAWABLE \ No newline at end of file
+#endif // __JE_GRAPHIC_H \ No newline at end of file