aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/Jin.exebin549376 -> 1407488 bytes
-rw-r--r--bin/jin.exebin549376 -> 1407488 bytes
-rw-r--r--build/vc++/jin.rcbin3340 -> 3272 bytes
-rw-r--r--build/vs2015/libs/LuaJIT-2.0.5/src/lua51.libbin0 -> 59514 bytes
-rw-r--r--src/libjin/Graphics/Font.h10
-rw-r--r--src/libjin/Graphics/Shapes.cpp8
-rw-r--r--src/libjin/Graphics/Shapes.h10
-rw-r--r--src/lua/modules/graphics/graphics.cpp50
8 files changed, 38 insertions, 40 deletions
diff --git a/bin/Jin.exe b/bin/Jin.exe
index 028add4..fe5bf33 100644
--- a/bin/Jin.exe
+++ b/bin/Jin.exe
Binary files differ
diff --git a/bin/jin.exe b/bin/jin.exe
index 028add4..fe5bf33 100644
--- a/bin/jin.exe
+++ b/bin/jin.exe
Binary files differ
diff --git a/build/vc++/jin.rc b/build/vc++/jin.rc
index 5a3a57f..216f2ca 100644
--- a/build/vc++/jin.rc
+++ b/build/vc++/jin.rc
Binary files differ
diff --git a/build/vs2015/libs/LuaJIT-2.0.5/src/lua51.lib b/build/vs2015/libs/LuaJIT-2.0.5/src/lua51.lib
new file mode 100644
index 0000000..36f6e7c
--- /dev/null
+++ b/build/vs2015/libs/LuaJIT-2.0.5/src/lua51.lib
Binary files differ
diff --git a/src/libjin/Graphics/Font.h b/src/libjin/Graphics/Font.h
index 176669c..5311c96 100644
--- a/src/libjin/Graphics/Font.h
+++ b/src/libjin/Graphics/Font.h
@@ -11,11 +11,7 @@ namespace jin
{
namespace graphics
{
- /**
- * Usage of stb_truetype.h here might be a little
- * bit dummy. Implementation of Font is referring
- * to stb_truetype.h L243~284. I basicly copy it:)
- */
+
class Font: public Drawable
{
public:
@@ -34,9 +30,7 @@ namespace graphics
void box(const char* text, int fontHeight, int spacing, int lineHeight, int* w, int * h);
private:
- /**
- * ASCII 32(space)..126(~) 95 glyphs
- */
+ /* ASCII 32(space)..126(~) 95 glyphs */
static const int ASCII_CHARACTER_NUM = 96;
stbtt_bakedchar asciiData[ASCII_CHARACTER_NUM];
diff --git a/src/libjin/Graphics/Shapes.cpp b/src/libjin/Graphics/Shapes.cpp
index aef4a1c..b2ef3f8 100644
--- a/src/libjin/Graphics/Shapes.cpp
+++ b/src/libjin/Graphics/Shapes.cpp
@@ -44,7 +44,7 @@ namespace graphics
glDisableClientState(GL_VERTEX_ARRAY);
}
- void circle(RENDER_MODE mode, int x, int y, int r)
+ void circle(RenderMode mode, int x, int y, int r)
{
r = r < 0 ? 0 : r;
@@ -69,13 +69,13 @@ namespace graphics
delete[] coords;
}
- void rect(RENDER_MODE mode, int x, int y, int w, int h)
+ void rect(RenderMode mode, int x, int y, int w, int h)
{
float coords[] = { x, y, x + w, y, x + w, y + h, x, y + h };
polygon(mode, coords, 4);
}
- void triangle(RENDER_MODE mode, int x1, int y1, int x2, int y2, int x3, int y3)
+ void triangle(RenderMode mode, int x1, int y1, int x2, int y2, int x3, int y3)
{
float coords[] = { x1, y1, x2, y2, x3, y3 };
polygon(mode, coords, 3);
@@ -101,7 +101,7 @@ namespace graphics
delete[] verts;
}
- void polygon(RENDER_MODE mode, float* p, int count)
+ void polygon(RenderMode mode, float* p, int count)
{
if (mode == LINE)
{
diff --git a/src/libjin/Graphics/Shapes.h b/src/libjin/Graphics/Shapes.h
index 1ef93a1..204339f 100644
--- a/src/libjin/Graphics/Shapes.h
+++ b/src/libjin/Graphics/Shapes.h
@@ -16,19 +16,19 @@ namespace graphics
NONE = 0,
FILL ,
LINE
- }RENDER_MODE;
+ }RenderMode;
/**
* TODO:
* 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 rect(RenderMode mode, int x, int y, int w, int h);
+ extern void triangle(RenderMode mode, int x1, int y1, int x2, int y2, int x3, int y3);
+ extern void circle(RenderMode 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);
+ extern void polygon(RenderMode mode, float* p, int count);
} // graphics
} // jin
diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp
index fadc59d..62bfb26 100644
--- a/src/lua/modules/graphics/graphics.cpp
+++ b/src/lua/modules/graphics/graphics.cpp
@@ -13,8 +13,6 @@ namespace lua
using jin::filesystem::Filesystem;
using jin::filesystem::Buffer;
- typedef Texture Texture;
-
static struct
{
color curRenderColor;
@@ -27,12 +25,12 @@ namespace lua
{
Window* wnd = Window::get();
Window::Setting setting;
- setting.width = luax_getfield_integer(L, 1, "width");
- setting.height = luax_getfield_integer(L, 1, "height");
- setting.title = luax_getfield_string(L, 1, "title");
- setting.vsync = luax_getfield_bool(L, 1, "vsync");
+ setting.width = luax_getfield_integer(L, 1, "width");
+ setting.height = luax_getfield_integer(L, 1, "height");
+ setting.title = luax_getfield_string(L, 1, "title");
+ setting.vsync = luax_getfield_bool(L, 1, "vsync");
setting.fullscreen = luax_getfield_bool(L, 1, "fullscreen");
- setting.resizable= luax_getfield_bool(L, 1, "resizable");
+ setting.resizable = luax_getfield_bool(L, 1, "resizable");
if (!wnd->init(&setting))
{
luax_pushboolean(L, false);
@@ -270,12 +268,12 @@ namespace lua
return 0;
}
- static RENDER_MODE strtomode(const char* str)
+ static RenderMode strtomode(const char* str)
{
std::string s = std::string(str);
- if (s == "fill") return RENDER_MODE::FILL;
- else if (s == "line") return RENDER_MODE::LINE;
- else return RENDER_MODE::NONE;
+ if (s == "fill") return RenderMode::FILL;
+ else if (s == "line") return RenderMode::LINE;
+ else return RenderMode::NONE;
}
static int l_point(lua_State* L)
@@ -301,8 +299,8 @@ namespace lua
static int l_rect(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
- RENDER_MODE mode = strtomode(modestr);
- if (mode != RENDER_MODE::NONE)
+ RenderMode mode = strtomode(modestr);
+ if (mode != RenderMode::NONE)
{
int x = luax_checknumber(L, 2);
int y = luax_checknumber(L, 3);
@@ -322,8 +320,8 @@ namespace lua
static int l_circle(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
- RENDER_MODE mode = strtomode(modestr);
- if (mode != RENDER_MODE::NONE)
+ RenderMode mode = strtomode(modestr);
+ if (mode != RenderMode::NONE)
{
int x = luax_checknumber(L, 2);
int y = luax_checknumber(L, 3);
@@ -342,8 +340,8 @@ namespace lua
static int l_triangle(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
- RENDER_MODE mode = strtomode(modestr);
- if (mode != RENDER_MODE::NONE)
+ RenderMode mode = strtomode(modestr);
+ if (mode != RenderMode::NONE)
{
int x = luax_checknumber(L, 2);
int y = luax_checknumber(L, 3);
@@ -369,8 +367,8 @@ namespace lua
{
const char* modestr = luax_checkstring(L, 1);
int n = luax_checknumber(L, 2);
- RENDER_MODE mode = strtomode(modestr);
- if (mode != RENDER_MODE::NONE)
+ RenderMode mode = strtomode(modestr);
+ if (mode != RenderMode::NONE)
{
if (!luax_istable(L, 3))
{
@@ -429,7 +427,6 @@ namespace lua
if (context.defaultFont == 0)
{
#include "lua/resources/font.ttf.h"
- // load default font
context.defaultFont = new Font();
context.defaultFont->loadMemory(font_ttf);
}
@@ -473,35 +470,42 @@ namespace lua
}
static const luaL_Reg f[] = {
+ /* window */
{ "init", l_init },
{ "setTitle", l_setTitle },
{ "getSize", l_getSize },
{ "getWidth", l_getWidth },
{ "getHeight", l_getHeight },
+ { "destroy", l_destroy },
+ /* creators */
{ "newTexture", l_newTexture },
{ "newShader", l_newShader },
{ "newCanvas", l_newCanvas },
{ "newFont", l_newFont },
- { "box", l_box },
- { "write", l_write },
+ /* render */
{ "setClearColor", l_setClearColor },
{ "clear", l_clear },
{ "draw", l_draw },
{ "setColor", l_setColor },
{ "palette", l_palette },
{ "present", l_present },
+ /* font */
+ { "box", l_box },
+ { "write", l_write },
{ "setFont", l_setFont },
+ /* canvas */
{ "bindCanvas", l_bindCanvas },
{ "unbindCanvas", l_unbindCanvas },
+ /* shader */
{ "useShader", l_useShader },
{ "unuseShader", l_unuseShader },
+ /* shapes */
{ "point", l_point },
{ "line", l_line },
{ "rect", l_rect },
{ "circle", l_circle },
{ "triangle", l_triangle },
{ "polygon", l_polygon },
- { "destroy", l_destroy },
{ 0, 0 }
};