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


C++ Private::hasValidOutputHandler方法代码示例

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


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

示例1: nvStaticCheck

bool Compressor::Private::compress(const InputOptions::Private & inputOptions, const CompressionOptions::Private & compressionOptions, const OutputOptions::Private & outputOptions) const
{
    // Make sure enums match.
    nvStaticCheck(FloatImage::WrapMode_Clamp == (FloatImage::WrapMode)WrapMode_Clamp);
    nvStaticCheck(FloatImage::WrapMode_Mirror == (FloatImage::WrapMode)WrapMode_Mirror);
    nvStaticCheck(FloatImage::WrapMode_Repeat == (FloatImage::WrapMode)WrapMode_Repeat);

    // Get output handler.
    if (!outputOptions.hasValidOutputHandler()) {
        outputOptions.error(Error_FileOpen);
        return false;
    }

    nvtt::Surface img;
    img.setWrapMode(inputOptions.wrapMode);
    img.setAlphaMode(inputOptions.alphaMode);
    img.setNormalMap(inputOptions.isNormalMap);

    const int faceCount = inputOptions.faceCount;
    int width = inputOptions.width;
    int height = inputOptions.height;
    int depth = inputOptions.depth;

    nv::getTargetExtent(&width, &height, &depth, inputOptions.maxExtent, inputOptions.roundMode, inputOptions.textureType);

    // If the extents have not changed, then we can use source images for all mipmaps.
    bool canUseSourceImages = (inputOptions.width == width && inputOptions.height == height && inputOptions.depth == depth);

    int mipmapCount = 1;
    if (inputOptions.generateMipmaps) {
        mipmapCount = countMipmaps(width, height, depth);
        if (inputOptions.maxLevel > 0) mipmapCount = min(mipmapCount, inputOptions.maxLevel);
    }

    if (!outputHeader(inputOptions.textureType, width, height, depth, mipmapCount, img.isNormalMap(), compressionOptions, outputOptions)) {
        return false;
    }


    // Output images.
    for (int f = 0; f < faceCount; f++)
    {
        int w = width;
        int h = height;
        int d = depth;
        bool canUseSourceImagesForThisFace = canUseSourceImages;

        img.setImage(inputOptions.inputFormat, inputOptions.width, inputOptions.height, inputOptions.depth, inputOptions.images[f]);

        // To normal map.
        if (inputOptions.convertToNormalMap) {
            img.toGreyScale(inputOptions.heightFactors.x, inputOptions.heightFactors.y, inputOptions.heightFactors.z, inputOptions.heightFactors.w);
            img.toNormalMap(inputOptions.bumpFrequencyScale.x, inputOptions.bumpFrequencyScale.y, inputOptions.bumpFrequencyScale.z, inputOptions.bumpFrequencyScale.w);
        }

        // To linear space.
        if (!img.isNormalMap()) {
            img.toLinear(inputOptions.inputGamma);
        }

        // Resize input.
        img.resize(w, h, d, ResizeFilter_Box);

        nvtt::Surface tmp = img;
        if (!img.isNormalMap()) {
            tmp.toGamma(inputOptions.outputGamma);
        }

        quantize(tmp, compressionOptions);
        compress(tmp, f, 0, compressionOptions, outputOptions);

        for (int m = 1; m < mipmapCount; m++) {
            w = max(1, w/2);
            h = max(1, h/2);
            d = max(1, d/2);

            int idx = m * faceCount + f;

            bool useSourceImages = false;
            if (canUseSourceImagesForThisFace) {
                if (inputOptions.images[idx] == NULL) { // One face is missing in this mipmap level.
                    canUseSourceImagesForThisFace = false; // If one level is missing, ignore the following source images.
                }
                else {
                    useSourceImages = true;
                }
            }

            if (useSourceImages) {
                img.setImage(inputOptions.inputFormat, w, h, d, inputOptions.images[idx]);

                // For already generated mipmaps, we need to convert to linear.
                if (!img.isNormalMap()) {
                    img.toLinear(inputOptions.inputGamma);
                }
            }
            else {
                if (inputOptions.mipmapFilter == MipmapFilter_Kaiser) {
                    float params[2] = { inputOptions.kaiserStretch, inputOptions.kaiserAlpha };
                    img.buildNextMipmap(MipmapFilter_Kaiser, inputOptions.kaiserWidth, params);
//.........这里部分代码省略.........
开发者ID:Aggroo,项目名称:nebula-trifid,代码行数:101,代码来源:Context.cpp


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