本文整理汇总了C++中TextureManager::getTextureId方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureManager::getTextureId方法的具体用法?C++ TextureManager::getTextureId怎么用?C++ TextureManager::getTextureId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureManager
的用法示例。
在下文中一共展示了TextureManager::getTextureId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
void GLGameModel::create()
{
GLuint currentTex = 65535;
TextureManager *tm = GAME->getTextureManager();
glNewList(displayListID, GL_COMPILE);
if(getIsLightingEnabled()) glEnable(GL_LIGHTING);
for(int i = 0; i < glModelFaces.size(); ++i)
{
GLModelFace face = glModelFaces.at(i);
// set or unset texture if neccessary
if(!face.materialName.isEmpty() &&
materials.contains(face.materialName))
{
QString textureFileName = materials.value(face.materialName);
GLuint texId = tm->getTextureId(textureFileName);
if(currentTex != texId)
{
glDisable(GL_COLOR_MATERIAL);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texId);
GAME->getGLWidget()->qglColor(Qt::white);
currentTex = texId;
}
}
else
{
if(currentTex != 0)
{
glEnable(GL_COLOR_MATERIAL);
currentTex = 0;
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
}
}
// draw the model
glBegin(GL_POLYGON);
for(int n = 0; n < face.vertexIds.size(); ++n)
{
int x = face.vertexIds.at(n);
if(x < 0 || x >= vertices.size()) continue;
QVector3D v = vertices.at(x);
if(n < face.textureCoordIds.size() && currentTex > 0)
{
x = face.textureCoordIds.at(n);
QVector2D vt = textureCoords.at(x);
glTexCoord2f(vt.x(), vt.y());
}
if(n < face.vertexNormalIds.size())
{
x = face.vertexNormalIds.at(n);
QVector3D vn = vertexNormals.at(x);
glNormal3f(vn.x(), vn.y(), vn.z());
}
glVertex3f(v.x(), v.y(), v.z());
}
glEnd();
}
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glEndList();
createFrame();
created = true;
}