aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules/graphics/graphics.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-15 19:43:01 +0800
committerchai <chaifix@163.com>2018-10-15 19:43:01 +0800
commitf3ee4be63e1c78c6f09fcb994b124533b1e5d3c1 (patch)
tree4dc9579b101de66b97ea0b5706f1d64f84b4f666 /src/lua/modules/graphics/graphics.cpp
parentbd3c1f268d959d351631b51d32d9912370144ddd (diff)
*更新图形模块
Diffstat (limited to 'src/lua/modules/graphics/graphics.cpp')
-rw-r--r--src/lua/modules/graphics/graphics.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp
index 700c8a5..c137420 100644
--- a/src/lua/modules/graphics/graphics.cpp
+++ b/src/lua/modules/graphics/graphics.cpp
@@ -3,6 +3,11 @@
#include "libjin/jin.h"
#include "lua/common/common.h"
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
namespace jin
{
namespace lua
@@ -37,9 +42,13 @@ namespace lua
luax_pushboolean(L, false);
return 1;
}
- /* load default font */
- TTFData* ttfData = TTFData::createTTFData(font_ttf, sizeof(font_ttf));
- context.defaultFont = ttfData->createTTF(15);
+ {
+ /* load default font */
+ Bitmap* bitmap = Bitmap::createBitmap(default_font_bitmap, sizeof(default_font_bitmap));
+ TextureFont* tf = TextureFont::createTextureFont(bitmap, Text(Encode::UTF8, default_charset), default_font_split, 18);
+ context.defaultFont = tf;
+ delete bitmap;
+ }
context.curFont = context.defaultFont;
luax_pushboolean(L, true);
@@ -123,6 +132,18 @@ namespace lua
goto fail;
}
bitmap = Bitmap::createBitmap(b.data, b.size);
+ //const Color* col = bitmap->getPixels();
+ //ofstream o = ofstream("img.txt", ios_base::app);
+ //for (int i = 0; i < bitmap->getWidth() * bitmap->getHeight(); ++i)
+ //{
+ // Color c = col[i];
+ // o << (int)c.r << ',';
+ // o << (int)c.g << ',';
+ // o << (int)c.b << ',';
+ // o << (int)c.a << ',';
+ // if ((i + 1) % 10 == 0)
+ // o << endl;
+ //}
if (bitmap == nullptr)
{
error(L, "Failed to decode image file %s", f);