Exemple #1
0
int LuaFonts::End(lua_State* L)
{
	CheckDrawingEnabled(L, __FUNCTION__);
	CglFont* font = tofont(L, 1);
	font->End();
	return 0;
}
Exemple #2
0
int LuaFonts::BindTexture(lua_State* L)
{
	CheckDrawingEnabled(L, __FUNCTION__);

	CglFont* font = tofont(L, 1);

	glBindTexture(GL_TEXTURE_2D, font->GetTexture());
	glEnable(GL_TEXTURE_2D);

	return 0;
}
Exemple #3
0
int LuaFonts::Print(lua_State* L)
{
	CheckDrawingEnabled(L, __FUNCTION__);

	const int args = lua_gettop(L); // number of arguments
	if ((args < 4) ||
	    !lua_isstring(L, 2) || !lua_isnumber(L, 3) || !lua_isnumber(L, 4)) {
		luaL_error(L,
		  "Incorrect arguments to font:Print(msg, x, y [,size [,\"options\"] ]");
	}

	CglFont* font = tofont(L, 1);

	const string text(lua_tostring(L, 2),lua_strlen(L, 2));
	const float x     = lua_tonumber(L, 3);
	const float y     = lua_tonumber(L, 4);
	const float size  = luaL_optfloat(L, 5, font->GetSize());

	int options = FONT_NEAREST;

	if ((args >= 6) && lua_isstring(L, 6)) {
		const char* c = lua_tostring(L, 6);
		while (*c != 0) {
	  		switch (*c) {
				case 'c': { options |= FONT_CENTER;        break; }
				case 'r': { options |= FONT_RIGHT;         break; }

				case 'a': { options |= FONT_ASCENDER;      break; }
				case 't': { options |= FONT_TOP;           break; }
				case 'v': { options |= FONT_VCENTER;       break; }
				case 'x': { options |= FONT_BASELINE;      break; }
				case 'b': { options |= FONT_BOTTOM;        break; }
				case 'd': { options |= FONT_DESCENDER;     break; }

				case 's': { options |= FONT_SHADOW;        break; }
				case 'o':
				case 'O': { options |= FONT_OUTLINE;       break; }

				case 'n': { options ^= FONT_NEAREST;       break; }
			}
	  		c++;
		}
	}

	font->glPrint(x, y, size, options, text);

	return 0;
}