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


C++ Texture::GetResourceWidth方法代码示例

本文整理汇总了C++中Texture::GetResourceWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Texture::GetResourceWidth方法的具体用法?C++ Texture::GetResourceWidth怎么用?C++ Texture::GetResourceWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texture的用法示例。


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

示例1: LoadSprite

void Sprite::LoadSprite(const char * filename)
{
	const std::string fullFileName(std::string(SPRITE_PATH) + std::string(filename) + std::string(".spr"));
	ConfigLua conf(fullFileName.c_str());
	

	mHeader.frameCount = conf.GetInt("gclsprite.frame_count");
	mHeader.width = conf.GetInt("gclsprite.width");
	mHeader.height = conf.GetInt("gclsprite.height");
	mHeader.textureCount = conf.GetInt("gclsprite.texture_count");
	std::stringstream fullTextureKey;
	const std::string textureKey("gclsprite.textures.texture");
	for (size_t i=0; i<mHeader.textureCount; ++i)
	{
		fullTextureKey.str("");
		fullTextureKey << textureKey;
		fullTextureKey << i;
		const std::string filename = conf.GetString(fullTextureKey.str().c_str());
		std::string fullTextureFileName(TEXTURE_PATH);
		fullTextureFileName += filename;
		Texture *texture = new Texture(fullTextureFileName.c_str());

		GCLAssertMsg(mHeader.width <= texture->GetResourceWidth(), std::string(filename) + ": You have a sprite that is bigger than your texture");
		GCLAssertMsg(mHeader.height <= texture->GetResourceHeight(), std::string(filename) + ": You have a sprite that is bigger than your texture");

		mTextureList.push_back(texture);
	}

	MeshReal halfWidth = MeshReal(mHeader.width/2.0);
	MeshReal halfHeight = MeshReal(mHeader.height/2.0);

	square[0] = VertexPT(Point3<MeshReal>(-halfWidth, halfHeight, 0.0), Point2<MeshReal>(0.0, 1.0)); // top left
	square[1] = VertexPT(Point3<MeshReal>(halfWidth, -halfHeight, 0.0), Point2<MeshReal>(1.0, 0.0)); // bot right
	square[2] = VertexPT(Point3<MeshReal>(-halfWidth, -halfHeight, 0.0),Point2<MeshReal>(0.0, 0.0)); // bot left
	square[3] = VertexPT(Point3<MeshReal>(halfWidth, halfHeight, 0.0), Point2<MeshReal>(1.0, 1.0)); // top right
	square[4] = VertexPT(Point3<MeshReal>(halfWidth, -halfHeight, 0.0), Point2<MeshReal>(1.0, 0.0)); // bot right
	square[5] = VertexPT(Point3<MeshReal>(-halfWidth, halfHeight, 0.0), Point2<MeshReal>(0.0, 1.0)); // top left


	mMaterial = new Material("DefaultSprite");
	mObj = new RenderObject( *mMaterial, square, 6);

}
开发者ID:fcoulombe,项目名称:kinevox,代码行数:43,代码来源:Sprite.cpp


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