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


C++ ITexture::GetDimensions方法代码示例

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


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

示例1: AddFrame

/**	Add an animation frame
 *
 *	@param tr A Rect object containing the texture coordinates for another animation frame
 *
 *	Operation:
 *		-#	Retrieve a pointer to the texture for this overlay
 *		-#	Find it's dimensions
 *		-#	Precalculate a scale value to convert 0->max to 0->1 so you can specify the rectangle in pixels, but convert them into texture coordinates
 *		-#	Convert the rectangle passed into the method into texture coordinates
 *		-#	Invert the y coordinates of the texture coordinates (rectangles are specified where 
 *				the origin is the top left, but texture coordinates specify the origin as the bottom left (hence why the y must be inverted)
 *		-#	Stores the texture coordinates generated, sets the default animation frame to be the first frame
 */
void Overlay::AddFrame(Rect *tr)
{
	int		x,y;
	float	tw,th;

	ITexture *t = m_vertexbuffer[0]->GetTexture();

	if(t != NULL){
		t->GetDimensions(x,y);
		
		tw = (float)x;
		th = (float)y;

		tw = 1/tw;
		th = 1/th;

		if(tr == NULL) tr = new Rect(0,0,x,y);
		
		//	Assign default texture coords
		Vertex2f *texcoords = new Vertex2f[4];

		texcoords[0].x	=	tw*tr->left;
		texcoords[0].y	=	th*tr->top;

		texcoords[1].x	=	tw*tr->left;
		texcoords[1].y	=	th*tr->bottom;

		texcoords[2].x	=	tw*tr->right;
		texcoords[2].y	=	th*tr->bottom;

		texcoords[3].x	=	tw*tr->right;
		texcoords[3].y	=	th*tr->top;

		//	Store the texture coords and set the default frame to zero
		m_texcoords.push_back(texcoords);
		SetFrame(0);
	}

	delete tr;
}
开发者ID:christhomas,项目名称:fusionengine,代码行数:53,代码来源:Overlay.cpp


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