当前位置: 首页>>代码示例>>C++>>正文


C++ CubeMapTexture::setSubImage方法代码示例

本文整理汇总了C++中CubeMapTexture::setSubImage方法的典型用法代码示例。如果您正苦于以下问题:C++ CubeMapTexture::setSubImage方法的具体用法?C++ CubeMapTexture::setSubImage怎么用?C++ CubeMapTexture::setSubImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CubeMapTexture的用法示例。


在下文中一共展示了CubeMapTexture::setSubImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: subImageBuffer

void CubeMapTextureGLTest::subImageBuffer() {
    CubeMapTexture texture;
    texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
        ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero));
    texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1),
        BufferImage2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data, BufferUsage::StaticDraw));

    MAGNUM_VERIFY_NO_ERROR();

    /** @todo How to test this on ES? */
    #ifndef MAGNUM_TARGET_GLES
    BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
    const auto imageData = image.buffer().data<UnsignedByte>();

    MAGNUM_VERIFY_NO_ERROR();

    CORRADE_COMPARE(image.size(), Vector2i(4));
    CORRADE_COMPARE_AS(imageData, Containers::ArrayReference<const UnsignedByte>{SubDataComplete}, TestSuite::Compare::Container);
    #endif
}
开发者ID:NextGenIntelligence,项目名称:magnum,代码行数:20,代码来源:CubeMapTextureGLTest.cpp

示例2: subImage

void CubeMapTextureGLTest::subImage() {
    CubeMapTexture texture;
    texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8,
        ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(4), Zero));
    texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1),
        ImageReference2D(ColorFormat::RGBA, ColorType::UnsignedByte, Vector2i(2), Data));

    MAGNUM_VERIFY_NO_ERROR();

    /** @todo How to test this on ES? */
    #ifndef MAGNUM_TARGET_GLES
    Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {ColorFormat::RGBA, ColorType::UnsignedByte});

    MAGNUM_VERIFY_NO_ERROR();

    CORRADE_COMPARE(image.size(), Vector2i(4));
    CORRADE_COMPARE_AS(
        Containers::ArrayReference<const UnsignedByte>(image.data<UnsignedByte>(), image.pixelSize()*image.size().product()),
        Containers::ArrayReference<const UnsignedByte>{SubDataComplete}, TestSuite::Compare::Container);
    #endif
}
开发者ID:NextGenIntelligence,项目名称:magnum,代码行数:21,代码来源:CubeMapTextureGLTest.cpp

示例3:

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);
}
开发者ID:JanDupal,项目名称:magnum-examples,代码行数:73,代码来源:CubeMap.cpp


注:本文中的CubeMapTexture::setSubImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。