本文整理汇总了C++中BMP::dimY方法的典型用法代码示例。如果您正苦于以下问题:C++ BMP::dimY方法的具体用法?C++ BMP::dimY怎么用?C++ BMP::dimY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMP
的用法示例。
在下文中一共展示了BMP::dimY方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadTexture
GLuint BMPTextureLoader::loadTexture(string fileName) {
BMP bitMap = BMP(fileName);
if(!bitMap.isValid()) {
cerr << "Could not load texture file: " << fileName << endl;
return 0;
}
GLuint res = 0;
// Generate a texture with the associative texture ID stored in the array
glGenTextures(1, &res);
cerr << "Texture " + fileName + ": " << res << endl;
// Bind the texture to the texture arrays index and init the texture
glBindTexture(GL_TEXTURE_2D, res);
// This sets the alignment requirements for the start of each pixel row in memory.
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
/*
// Build Mipmaps (builds different versions of the picture for distances - looks better)
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, bitMap.dimX(), bitMap.dimY(), GL_RGB, GL_UNSIGNED_BYTE, bitMap.data());
// Lastly, we need to tell OpenGL the quality of our texture map. GL_LINEAR_MIPMAP_LINEAR
// is the smoothest. GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR,
// but looks blochy and pixilated. Good for slower computers though.
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
// The default GL_TEXTURE_WRAP_S and ""_WRAP_T property is GL_REPEAT.
// We need to turn this to GL_CLAMP_TO_EDGE, otherwise it creates ugly seems
// in our sky box. GL_CLAMP_TO_EDGE does not repeat when bound to an object.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
*/
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitMap.dimX(), bitMap.dimY(), 0, GL_RGB, GL_UNSIGNED_BYTE, bitMap.data());
return res;
}