当前位置: 首页>>代码示例>>C++>>正文


C++ CglFont类代码示例

本文整理汇总了C++中CglFont的典型用法代码示例。如果您正苦于以下问题:C++ CglFont类的具体用法?C++ CglFont怎么用?C++ CglFont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CglFont类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tofont

int LuaFonts::SetOutlineColor(lua_State* L)
{
	CglFont* font = tofont(L, 1);

	const int args = lua_gettop(L); // number of arguments
	if (args < 2) {
		luaL_error(L, "Incorrect arguments to font:SetOutlineColor([\"outlineColor\"])");
	}

	float4* color = NULL;

	if (lua_istable(L, 2)) {
		color = new float4;
		const int count = ParseFloatArray(L, 2, *color, 4);
		if (count < 3) {
			luaL_error(L, "Incorrect arguments to font:SetOutlineColor([\"outlineColor\"])");
		}
		if (count == 3) {
			color->w = 1.0f;
		}
	} else if (args >= 4) {
		color = new float4;
		color->x = lua_tonumber(L, 2);
		color->y = lua_tonumber(L, 3);
		color->z = lua_tonumber(L, 4);
		color->w = luaL_optfloat(L, 5, 1.0f);
	} else if (!lua_isnil(L, 2)) {
		luaL_error(L, "Incorrect arguments to font:SetOutlineColor([\"outlineColor\"])");
	}

	font->SetOutlineColor(color);
	delete color;
	return 0;
}
开发者ID:javaphoon,项目名称:spring,代码行数:34,代码来源:LuaFonts.cpp

示例2: CheckDrawingEnabled

int LuaFonts::End(lua_State* L)
{
	CheckDrawingEnabled(L, __FUNCTION__);
	CglFont* font = tofont(L, 1);
	font->End();
	return 0;
}
开发者ID:javaphoon,项目名称:spring,代码行数:7,代码来源:LuaFonts.cpp

示例3: tofont

int LuaFonts::GetTextWidth(lua_State* L)
{
	CglFont* font = tofont(L, 1);
	const string text(luaL_checkstring(L, 2),lua_strlen(L, 2));
	const float width = font->GetTextWidth(text);
	lua_pushnumber(L, width);
	return 1;
}
开发者ID:DarksidedStudios,项目名称:spring,代码行数:8,代码来源:LuaFonts.cpp

示例4: CheckDrawingEnabled

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;
}
开发者ID:BrainDamage,项目名称:spring,代码行数:48,代码来源:LuaFonts.cpp

示例5: luaL_getmetatable

int LuaFonts::meta_index(lua_State* L)
{
	//! first check if there is a function
	luaL_getmetatable(L, "Font");
	lua_pushvalue(L, 2);
	lua_rawget(L, -2);
	if (!lua_isnil(L, -1)) {
		return 1;
	}
	lua_pop(L, 1);

	//! couldn't find a function, so check properties
	CglFont* font = tofont(L, 1);

	if (lua_israwstring(L, 2)) {
		const string key = lua_tostring(L, 2);

		if (key == "size") {
			lua_pushnumber(L, font->GetSize());
			return 1;
		//} else if (key == "outlinecolor") {
		//} else if (key == "textcolor") {
		} else if (key == "path") {
			const std::string& filepath = font->GetFilePath();
			lua_pushlstring(L, filepath.c_str(), filepath.length());
			return 1;
		} else if (key == "height" || key == "lineheight") {
			lua_pushnumber(L, font->GetLineHeight());
			return 1;
		} else if (key == "descender") {
			lua_pushnumber(L, font->GetDescender());
			return 1;
		} else if (key == "outlinewidth") {
			lua_pushnumber(L, font->GetOutlineWidth());
			return 1;
		} else if (key == "outlineweight") {
			lua_pushnumber(L, font->GetOutlineWeight());
			return 1;
		} else if (key == "family") {
			const std::string& family = font->GetFamily();
			lua_pushlstring(L, family.c_str(), family.length());
			return 1;
		} else if (key == "style") {
			const std::string& style = font->GetStyle();
			lua_pushlstring(L, style.c_str(), style.length());
			return 1;
		} else if (key == "texturewidth") {
			lua_pushnumber(L, font->GetTexWidth());
			return 1;
		} else if (key == "textureheight") {
			lua_pushnumber(L, font->GetTexHeight());
			return 1;
		}
	}

	return 0;
}
开发者ID:javaphoon,项目名称:spring,代码行数:57,代码来源:LuaFonts.cpp


注:本文中的CglFont类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。