本文整理汇总了C++中CubeMapTexture::generateMipmap方法的典型用法代码示例。如果您正苦于以下问题:C++ CubeMapTexture::generateMipmap方法的具体用法?C++ CubeMapTexture::generateMipmap怎么用?C++ CubeMapTexture::generateMipmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CubeMapTexture
的用法示例。
在下文中一共展示了CubeMapTexture::generateMipmap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateMipmap
void CubeMapTextureGLTest::generateMipmap() {
CubeMapTexture texture;
texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::PositiveY, 0, TextureFormat::RGBA8,
ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::PositiveZ, 0, TextureFormat::RGBA8,
ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::NegativeX, 0, TextureFormat::RGBA8,
ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::NegativeY, 0, TextureFormat::RGBA8,
ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
texture.setImage(CubeMapTexture::Coordinate::NegativeZ, 0, TextureFormat::RGBA8,
ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(32)));
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(texture.imageSize(0), Vector2i(32));
CORRADE_COMPARE(texture.imageSize(1), Vector2i( 0));
#endif
texture.generateMipmap();
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(texture.imageSize(0), Vector2i(32));
CORRADE_COMPARE(texture.imageSize(1), Vector2i(16));
CORRADE_COMPARE(texture.imageSize(2), Vector2i( 8));
CORRADE_COMPARE(texture.imageSize(3), Vector2i( 4));
CORRADE_COMPARE(texture.imageSize(4), Vector2i( 2));
CORRADE_COMPARE(texture.imageSize(5), Vector2i( 1));
MAGNUM_VERIFY_NO_ERROR();
#endif
}
示例2:
CubeMap::CubeMap(const std::string& prefix, Object3D* parent, SceneGraph::DrawableGroup3D<>* group): Object3D(parent), SceneGraph::Drawable3D<>(this, group) {
CubeMapResourceManager* resourceManager = CubeMapResourceManager::instance();
/* Cube mesh */
if(!(cube = resourceManager->get<Mesh>("cube"))) {
Mesh* mesh = new Mesh;
Buffer* buffer = new Buffer;
Buffer* indexBuffer = new Buffer;
Trade::MeshData3D cubeData = Primitives::Cube::solid();
MeshTools::flipFaceWinding(*cubeData.indices());
MeshTools::compressIndices(mesh, indexBuffer, Buffer::Usage::StaticDraw, *cubeData.indices());
MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw, *cubeData.positions(0));
mesh->setPrimitive(cubeData.primitive())
->addVertexBuffer(buffer, 0, CubeMapShader::Position());
resourceManager->set("cube-buffer", buffer, ResourceDataState::Final, ResourcePolicy::Resident);
resourceManager->set("cube-index-buffer", indexBuffer, ResourceDataState::Final, ResourcePolicy::Resident);
resourceManager->set(cube.key(), mesh, ResourceDataState::Final, ResourcePolicy::Resident);
}
/* Cube map texture */
if(!(texture = resourceManager->get<CubeMapTexture>("texture"))) {
CubeMapTexture* cubeMap = new CubeMapTexture;
cubeMap->setWrapping(CubeMapTexture::Wrapping::ClampToEdge)
->setMagnificationFilter(CubeMapTexture::Filter::Linear)
->setMinificationFilter(CubeMapTexture::Filter::Linear, CubeMapTexture::Mipmap::Linear);
Resource<Trade::AbstractImporter> importer = resourceManager->get<Trade::AbstractImporter>("tga-importer");
/* Configure texture storage using size of first image */
importer->openFile(prefix + "+x.tga");
Trade::ImageData2D* image = importer->image2D(0);
Vector2i size = image->size();
cubeMap->setStorage(Math::log2(size.min())+1, CubeMapTexture::InternalFormat::RGB8, size);
cubeMap->setSubImage(CubeMapTexture::PositiveX, 0, {}, image);
delete image;
importer->openFile(prefix + "-x.tga");
image = importer->image2D(0);
cubeMap->setSubImage(CubeMapTexture::NegativeX, 0, {}, image);
delete image;
importer->openFile(prefix + "+y.tga");
image = importer->image2D(0);
cubeMap->setSubImage(CubeMapTexture::PositiveY, 0, {}, image);
delete image;
importer->openFile(prefix + "-y.tga");
image = importer->image2D(0);
cubeMap->setSubImage(CubeMapTexture::NegativeY, 0, {}, image);
delete image;
importer->openFile(prefix + "+z.tga");
image = importer->image2D(0);
cubeMap->setSubImage(CubeMapTexture::PositiveZ, 0, {}, image);
delete image;
importer->openFile(prefix + "-z.tga");
image = importer->image2D(0);
cubeMap->setSubImage(CubeMapTexture::NegativeZ, 0, {}, image);
delete image;
cubeMap->generateMipmap();
resourceManager->set(texture.key(), cubeMap, ResourceDataState::Final, ResourcePolicy::Manual);
}
/* Shader */
if(!(shader = resourceManager->get<AbstractShaderProgram, CubeMapShader>("shader")))
resourceManager->set<AbstractShaderProgram>(shader.key(), new CubeMapShader, ResourceDataState::Final, ResourcePolicy::Manual);
}