本文整理汇总了C++中TileSet::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TileSet::GetSize方法的具体用法?C++ TileSet::GetSize怎么用?C++ TileSet::GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileSet
的用法示例。
在下文中一共展示了TileSet::GetSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void ComplexTileMap::Render(unsigned short minX, unsigned short minY, unsigned short maxX, unsigned short maxY)
{
glPushMatrix();
if(minX >= m_size[0])
minX = m_size[0] - 1;
if(minY >= m_size[1])
minY = m_size[1] - 1;
if(maxX >= m_size[0])
maxX = m_size[0] - 1;
if(maxY >= m_size[1])
maxY = m_size[1] - 1;
glEnable(GL_TEXTURE_2D);
Image *lastImage = 0;
glBegin(GL_QUADS);
for(unsigned int a = minX; a < maxX; a++)
for(unsigned int b = minY; b < maxY; b++)
{
for(vector<ComplexTileMap::Tile *>::iterator it = m_tiles[a][b].begin(); it != m_tiles[a][b].end(); it++)
{
Tile *tile = *it;
TileSet *tileSet = tile->m_tileSet;
if(tileSet)
{
Vector2<unsigned short> tileSetSize = tileSet->GetSize();
if(tile->m_value[0] < tileSetSize[0] && tile->m_value[1] < tileSetSize[1])
{
unsigned int x, y, X, Y, _x, _y, _X, _Y;
x = a * m_tileSize[0];
y = b * m_tileSize[1];
X = x + m_tileSize[0];
Y = y + m_tileSize[1];
_x = tile->m_value[0] * m_tileSize[0];
_y = tile->m_value[1] * m_tileSize[1];
_X = _x + m_tileSize[0];
_Y = _y + m_tileSize[1];
Image *tileSetImage = tileSet->GetImage();
Vector2<unsigned int> tileSetImageSize = tileSetImage->GetSize();
float tx, ty, tX, tY;
tx = ((float)_x + 0.5f) / ((float)tileSetImageSize[0]);
ty = ((float)_y + 0.5f) / ((float)tileSetImageSize[1]);
tX = ((float)_X - 0.5f) / ((float)tileSetImageSize[0]);
tY = ((float)_Y - 0.5f) / ((float)tileSetImageSize[1]);
if(lastImage != tileSetImage)
{
glEnd();
tileSetImage->Bind();
glBegin(GL_QUADS);
lastImage = tileSetImage;
}
glTexCoord2f(tx, tY);
glVertex2i(x, y);
glTexCoord2f(tX, tY);
glVertex2i(X, y);
glTexCoord2f(tX, ty);
glVertex2i(X, Y);
glTexCoord2f(tx, ty);
glVertex2i(x, Y);
}
}
}
}
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}