本文整理汇总了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;
}