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


C++ CORRADE_INTERNAL_ASSERT函数代码示例

本文整理汇总了C++中CORRADE_INTERNAL_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ CORRADE_INTERNAL_ASSERT函数的具体用法?C++ CORRADE_INTERNAL_ASSERT怎么用?C++ CORRADE_INTERNAL_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: FT_Get_Char_Index

void FreeTypeFont::doFillGlyphCache(GlyphCache& cache, const std::vector<char32_t>& characters)
#endif
{
    /** @bug Crash when atlas is too small */

    /* Get glyph codes from characters */
    std::vector<FT_UInt> charIndices;
    charIndices.resize(characters.size()+1);
    charIndices[0] = 0;
    std::transform(characters.begin(), characters.end(), charIndices.begin()+1,
        [this](const char32_t c) { return FT_Get_Char_Index(ftFont, c); });

    /* Remove duplicates (e.g. uppercase and lowercase mapped to same glyph) */
    std::sort(charIndices.begin(), charIndices.end());
    charIndices.erase(std::unique(charIndices.begin(), charIndices.end()), charIndices.end());

    /* Sizes of all characters */
    std::vector<Vector2i> charSizes;
    charSizes.reserve(charIndices.size());
    for(FT_UInt c: charIndices) {
        CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Load_Glyph(ftFont, c, FT_LOAD_DEFAULT) == 0);
        charSizes.push_back(Vector2i(ftFont->glyph->metrics.width, ftFont->glyph->metrics.height)/64);
    }

    /* Create texture atlas */
    const std::vector<Rectanglei> charPositions = cache.reserve(charSizes);

    /* Render all characters to the atlas and create character map */
    unsigned char* pixmap = new unsigned char[cache.textureSize().product()]();
    /** @todo Some better way for this */
    #ifndef MAGNUM_TARGET_GLES2
    Image2D image(ImageFormat::Red, ImageType::UnsignedByte, cache.textureSize(), pixmap);
    #else
    Image2D image(Context::current() && Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>() ?
        ImageFormat::Red : ImageFormat::Luminance, ImageType::UnsignedByte, cache.textureSize(), pixmap);
    #endif
    for(std::size_t i = 0; i != charPositions.size(); ++i) {
        /* Load and render glyph */
        /** @todo B&W only if radius != 0 */
        FT_GlyphSlot glyph = ftFont->glyph;
        CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Load_Glyph(ftFont, charIndices[i], FT_LOAD_DEFAULT) == 0);
        CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Render_Glyph(glyph, FT_RENDER_MODE_NORMAL) == 0);

        /* Copy rendered bitmap to texture image */
        const FT_Bitmap& bitmap = glyph->bitmap;
        CORRADE_INTERNAL_ASSERT(std::abs(bitmap.width-charPositions[i].width()) <= 2);
        CORRADE_INTERNAL_ASSERT(std::abs(bitmap.rows-charPositions[i].height()) <= 2);
        for(Int yin = 0, yout = charPositions[i].bottom(), ymax = bitmap.rows; yin != ymax; ++yin, ++yout)
            for(Int xin = 0, xout = charPositions[i].left(), xmax = bitmap.width; xin != xmax; ++xin, ++xout)
                pixmap[yout*cache.textureSize().x() + xout] = bitmap.buffer[(bitmap.rows-yin-1)*bitmap.width + xin];

        /* Insert glyph parameters into cache */
        cache.insert(charIndices[i],
            Vector2i(glyph->bitmap_left, glyph->bitmap_top-charPositions[i].height()),
            charPositions[i]);
    }

    /* Set cache image */
    cache.setImage({}, image);
}
开发者ID:severin-lemaignan,项目名称:magnum-plugins,代码行数:60,代码来源:FreeTypeFont.cpp

示例2: CORRADE_INTERNAL_ASSERT

bool Dumpster::next() {
    /* No more things available */
    if(_current == _conf.groupCount("item")) return false;

    /* Find empty dumpster */
    Int empty = -1;
    for(Int i = 0; i != 3; ++i) if(!_dumpsterItems[i]) {
        empty = i;
        break;
    }

    /* All dumpsters full */
    if(empty == -1) return false;

    /* Load info about current item from config file */
    auto itemData = _conf.group("item", _current);
    CORRADE_INTERNAL_ASSERT(itemData);
    auto imageData = _conf.group("images")->group(itemData->value("image"));
    CORRADE_INTERNAL_ASSERT(imageData);

    /* Populate the item */
    auto item = new Item(this);
    item->reset(imageData->value<Vector2i>("size"), imageData->value("file"));
    item->_contents = itemData->value("contents");
    item->_size = itemData->value<Int>("size");
    item->_value = itemData->value<Int>("value");

    /* Move to next item in the dumpster (nothing fancy now, just sequential) */
    ++_current;

    put(empty, item);
    return true;
}
开发者ID:nuclearwhales,项目名称:rottennoodlessmuggler,代码行数:33,代码来源:Dumpster.cpp

示例3: importerManager

int DistanceFieldConverter::exec() {
    /* Load plugins */
    PluginManager::Manager<Trade::AbstractImporter> importerManager(MAGNUM_IMPORTER_PLUGIN_DIR);
    if(!(importerManager.load(args.value("importer")) & PluginManager::LoadState::Loaded)) {
        Error() << "Cannot load importer plugin" << args.value("importer") << "from" << MAGNUM_IMPORTER_PLUGIN_DIR;
        return 1;
    }
    PluginManager::Manager<Trade::AbstractImageConverter> converterManager(MAGNUM_IMAGECONVERTER_PLUGIN_DIR);
    if(!(converterManager.load(args.value("converter")) & PluginManager::LoadState::Loaded)) {
        Error() << "Cannot load converter plugin" << args.value("converter") << "from" << MAGNUM_IMAGECONVERTER_PLUGIN_DIR;
        return 1;
    }

    /* Instance plugins */
    std::unique_ptr<Trade::AbstractImporter> importer = importerManager.instance(args.value("importer"));
    CORRADE_INTERNAL_ASSERT(importer);
    std::unique_ptr<Trade::AbstractImageConverter> converter = converterManager.instance(args.value("converter"));
    CORRADE_INTERNAL_ASSERT(converter);

    /* Open input file */
    std::optional<Trade::ImageData2D> image;
    if(!importer->openFile(args.value("input")) || !(image = importer->image2D(0))) {
        Error() << "Cannot open file" << args.value("input");
        return 1;
    }

    if(image->format() != ColorFormat::Red) {
        Error() << "Unsupported image format" << image->format();
        return 1;
    }

    /* Input texture */
    Texture2D input;
    input.setMinificationFilter(Sampler::Filter::Linear)
        .setMagnificationFilter(Sampler::Filter::Linear)
        .setWrapping(Sampler::Wrapping::ClampToEdge)
        .setImage(0, TextureFormat::R8, *image);

    /* Output texture */
    Texture2D output;
    output.setStorage(1, TextureFormat::R8, args.value<Vector2i>("output-size"));

    CORRADE_INTERNAL_ASSERT(Renderer::error() == Renderer::Error::NoError);

    /* Do it */
    Debug() << "Converting image of size" << image->size() << "to distance field...";
    TextureTools::distanceField(input, output, {{}, args.value<Vector2i>("output-size")}, args.value<Int>("radius"), image->size());

    /* Save image */
    Image2D result(ColorFormat::Red, ColorType::UnsignedByte);
    output.image(0, result);
    if(!converter->exportToFile(result, args.value("output"))) {
        Error() << "Cannot save file" << args.value("output");
        return 1;
    }

    return 0;
}
开发者ID:ArEnSc,项目名称:magnum,代码行数:58,代码来源:distancefieldconverter.cpp

示例4: CORRADE_INTERNAL_ASSERT

void Buffer::unbind(const Target target, const UnsignedInt index) {
    #ifdef MAGNUM_BUILD_DEPRECATED
    #ifndef MAGNUM_TARGET_WEBGL
    CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform);
    #else
    CORRADE_INTERNAL_ASSERT(target == Target::Uniform);
    #endif
    #endif
    glBindBufferBase(GLenum(target), index, 0);
}
开发者ID:nolancash,项目名称:magnum,代码行数:10,代码来源:Buffer.cpp

示例5: CORRADE_INTERNAL_ASSERT

void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std::size_t count) {
    #ifdef MAGNUM_BUILD_DEPRECATED
    #ifndef MAGNUM_TARGET_WEBGL
    CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform);
    #else
    CORRADE_INTERNAL_ASSERT(target == Target::Uniform);
    #endif
    #endif
    Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {nullptr, count});
}
开发者ID:BrainlessLabsInc,项目名称:magnum,代码行数:10,代码来源:Buffer.cpp

示例6: CORRADE_INTERNAL_ASSERT

void AbstractFramebuffer::setViewportInternal() {
    Implementation::FramebufferState& state = *Context::current()->state().framebuffer;

    CORRADE_INTERNAL_ASSERT(_viewport != Implementation::FramebufferState::DisengagedViewport);
    CORRADE_INTERNAL_ASSERT(state.drawBinding == _id);

    /* Already up-to-date, nothing to do */
    if(state.viewport == _viewport)
        return;

    /* Update the state and viewport */
    state.viewport = _viewport;
    glViewport(_viewport.left(), _viewport.bottom(), _viewport.sizeX(), _viewport.sizeY());
}
开发者ID:RobertoMalatesta,项目名称:magnum,代码行数:14,代码来源:AbstractFramebuffer.cpp

示例7: CORRADE_INTERNAL_ASSERT

void Sprite::reset(const Vector2i& size, const ResourceKey& texture) {
    /* Don't allow sprites with odd sizes */
    CORRADE_INTERNAL_ASSERT((size%2).isZero());

    _size = size/2; /* Square texture is 2x2, thus halving the size */
    _texture = Manager::instance().get<Texture2D>(texture);
}
开发者ID:nuclearwhales,项目名称:rottennoodlessmuggler,代码行数:7,代码来源:Sprite.cpp

示例8: CORRADE_INTERNAL_ASSERT

void WireframeSpheroid::bottomHemisphere(const Float endY, const UnsignedInt rings) {
    CORRADE_INTERNAL_ASSERT(_positions.empty());

    /* Initial vertex */
    _positions.push_back(Vector3::yAxis(endY - 1.0f));

    /* Connect initial vertex to first ring */
    for(UnsignedInt i = 0; i != 4; ++i)
        _indices.insert(_indices.end(), {0, i+1});

    /* Hemisphere vertices and indices */
    const Rad ringAngleIncrement(Constants::piHalf()/rings);
    for(UnsignedInt j = 0; j != rings-1; ++j) {
        const Rad angle = Float(j+1)*ringAngleIncrement;

        _positions.emplace_back(0.0f, endY - Math::cos(angle), Math::sin(angle));
        _positions.emplace_back(Math::sin(angle), endY - Math::cos(angle), 0.0f);
        _positions.emplace_back(0.0f, endY - Math::cos(angle), -Math::sin(angle));
        _positions.emplace_back(-Math::sin(angle), endY - Math::cos(angle), 0.0f);

        /* Connect vertices to next ring */
        for(UnsignedInt i = 0; i != 4; ++i)
            _indices.insert(_indices.end(), {UnsignedInt(_positions.size())-4+i, UnsignedInt(_positions.size())+i});
    }
}
开发者ID:NextGenIntelligence,项目名称:magnum,代码行数:25,代码来源:WireframeSpheroid.cpp

示例9: extTypeFromKhrIdentifier

std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, const GLuint name) {
    const GLenum type = extTypeFromKhrIdentifier(identifier);

    /* Get label size (w/o null terminator) */
    GLsizei size;
    /** @todo Re-enable when extension loader is available for ES */
    #ifndef MAGNUM_TARGET_GLES
    glGetObjectLabelEXT(type, name, 0, &size, nullptr);
    #else
    static_cast<void>(type);
    static_cast<void>(name);
    CORRADE_INTERNAL_ASSERT(false);
    #endif

    /* Make place also for the null terminator */
    std::string label;
    label.resize(size+1);
    /** @todo Re-enable when extension loader is available for ES */
    #ifndef MAGNUM_TARGET_GLES
    glGetObjectLabelEXT(identifier, name, size+1, nullptr, &label[0]);
    #endif

    /* Pop null terminator and return the string */
    label.resize(size);
    return label;
}
开发者ID:Driky,项目名称:magnum,代码行数:26,代码来源:AbstractObject.cpp

示例10: CORRADE_INTERNAL_ASSERT

void AnyImporter::doOpenFile(const std::string& filename) {
    CORRADE_INTERNAL_ASSERT(manager());

    /* Detect type from extension */
    std::string plugin;
    if(Utility::String::endsWith(filename, ".ogg"))
        plugin = "VorbisAudioImporter";
    else if(Utility::String::endsWith(filename, ".wav"))
        plugin = "WavAudioImporter";
    else {
        Error() << "Audio::AnyImporter::openFile(): cannot determine type of file" << filename;
        return;
    }

    /* Try to load the plugin */
    if(!(manager()->load(plugin) & PluginManager::LoadState::Loaded)) {
        Error() << "Audio::AnyImporter::openFile(): cannot load" << plugin << "plugin";
        return;
    }

    /* Try to open the file (error output should be printed by the plugin
       itself) */
    std::unique_ptr<AbstractImporter> importer = static_cast<PluginManager::Manager<AbstractImporter>*>(manager())->instance(plugin);
    if(!importer->openFile(filename)) return;

    /* Success, save the instance */
    _in = std::move(importer);
}
开发者ID:caomw,项目名称:magnum-plugins,代码行数:28,代码来源:AnyImporter.cpp

示例11: CORRADE_INTERNAL_ASSERT

Emitter::~Emitter() {
    for(auto connection: connections) {
        const Implementation::AbstractConnectionData* data = connection.second;

        /* Remove connection from receiver, if this is member function connection */
        if(data->type == Implementation::AbstractConnectionData::Type::Member) {
            auto& receiverConnections = static_cast<const Implementation::AbstractMemberConnectionData*>(data)->receiver->connections;
            for(auto end = receiverConnections.end(), rit = receiverConnections.begin(); rit != end; ++rit) {
                if(*rit != data) continue;

                receiverConnections.erase(rit);
                break;
            }
        }

        /* If there is connection object, remove reference to connection data
           from it and mark it as disconnected */
        if(data->connection) {
            CORRADE_INTERNAL_ASSERT(data == data->connection->data);
            data->connection->data = nullptr;
            data->connection->connected = false;
        }

        /* Delete connection data (as they make no sense without emitter) */
        delete data;
    }
}
开发者ID:NextGenIntelligence,项目名称:corrade,代码行数:27,代码来源:Emitter.cpp

示例12: Error

Containers::Array<char> StbPngImageConverter::doExportToData(const ImageView2D& image) {
    #ifndef MAGNUM_TARGET_GLES
    if(image.storage().swapBytes()) {
        Error() << "Trade::StbPngImageConverter::exportToData(): pixel byte swap is not supported";
        return nullptr;
    }
    #endif

    if(image.type() != PixelType::UnsignedByte) {
        Error() << "Trade::StbPngImageConverter::exportToData(): unsupported pixel type" << image.type();
        return nullptr;
    }

    Int components;
    switch(image.format()) {
        #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
        case PixelFormat::Red:
        #endif
        #ifdef MAGNUM_TARGET_GLES2
        case PixelFormat::Luminance:
        #endif
            components = 1;
            break;
        #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
        case PixelFormat::RG:
        #endif
        #ifdef MAGNUM_TARGET_GLES2
        case PixelFormat::LuminanceAlpha:
        #endif
            components = 2;
            break;
        case PixelFormat::RGB: components = 3; break;
        case PixelFormat::RGBA: components = 4; break;
        default:
            Error() << "Trade::StbPngImageConverter::exportToData(): unsupported pixel format" << image.format();
            return nullptr;
    }

    /* Data properties */
    std::size_t offset;
    Math::Vector2<std::size_t> dataSize;
    std::tie(offset, dataSize, std::ignore) = image.dataProperties();

    /* Reverse rows in image data */
    Containers::Array<unsigned char> reversedData{image.data().size()};
    for(Int y = 0; y != image.size().y(); ++y) {
        std::copy(image.data<unsigned char>() + offset + y*dataSize.x(), image.data<unsigned char>() + offset + (y + 1)*dataSize.x(), reversedData + (image.size().y() - y - 1)*dataSize.x());
    }

    Int size;
    unsigned char* const data = stbi_write_png_to_mem(reversedData, dataSize.x(), image.size().x(), image.size().y(), components, &size);
    CORRADE_INTERNAL_ASSERT(data);

    /* Wrap the data in an array with custom deleter (we can't use delete[]) */
    Containers::Array<char> fileData{reinterpret_cast<char*>(data), std::size_t(size),
        [](char* data, std::size_t) { std::free(data); }};

    return fileData;
}
开发者ID:Squareys,项目名称:magnum-plugins,代码行数:59,代码来源:StbPngImageConverter.cpp

示例13: doClose

void AbstractFont::close() {
    if(isOpened()) {
        doClose();
        _size = 0.0f;
        _lineHeight = 0.0f;
        CORRADE_INTERNAL_ASSERT(!isOpened());
    }
}
开发者ID:DYSEQTA,项目名称:magnum,代码行数:8,代码来源:AbstractFont.cpp

示例14: importerManager

int DistanceFieldConverter::exec() {
    /* Load importer plugin */
    PluginManager::Manager<Trade::AbstractImporter> importerManager(Utility::Directory::join(args.value("plugin-dir"), "importers/"));
    if(!(importerManager.load(args.value("importer")) & PluginManager::LoadState::Loaded))
        return 1;
    std::unique_ptr<Trade::AbstractImporter> importer = importerManager.instance(args.value("importer"));

    /* Load converter plugin */
    PluginManager::Manager<Trade::AbstractImageConverter> converterManager(Utility::Directory::join(args.value("plugin-dir"), "imageconverters/"));
    if(!(converterManager.load(args.value("converter")) & PluginManager::LoadState::Loaded))
        return 1;
    std::unique_ptr<Trade::AbstractImageConverter> converter = converterManager.instance(args.value("converter"));

    /* Open input file */
    std::optional<Trade::ImageData2D> image;
    if(!importer->openFile(args.value("input")) || !(image = importer->image2D(0))) {
        Error() << "Cannot open file" << args.value("input");
        return 1;
    }

    /* Decide about internal format */
    TextureFormat internalFormat;
    if(image->format() == PixelFormat::Red) internalFormat = TextureFormat::R8;
    else if(image->format() == PixelFormat::RGB) internalFormat = TextureFormat::RGB8;
    else if(image->format() == PixelFormat::RGBA) internalFormat = TextureFormat::RGBA8;
    else {
        Error() << "Unsupported image format" << image->format();
        return 1;
    }

    /* Input texture */
    Texture2D input;
    input.setMinificationFilter(Sampler::Filter::Linear)
        .setMagnificationFilter(Sampler::Filter::Linear)
        .setWrapping(Sampler::Wrapping::ClampToEdge)
        .setStorage(1, internalFormat, image->size())
        .setSubImage(0, {}, *image);

    /* Output texture */
    Texture2D output;
    output.setStorage(1, TextureFormat::R8, args.value<Vector2i>("output-size"));

    CORRADE_INTERNAL_ASSERT(Renderer::error() == Renderer::Error::NoError);

    /* Do it */
    Debug() << "Converting image of size" << image->size() << "to distance field...";
    TextureTools::distanceField(input, output, {{}, args.value<Vector2i>("output-size")}, args.value<Int>("radius"), image->size());

    /* Save image */
    Image2D result(PixelFormat::Red, PixelType::UnsignedByte);
    output.image(0, result);
    if(!converter->exportToFile(result, args.value("output"))) {
        Error() << "Cannot save file" << args.value("output");
        return 1;
    }

    return 0;
}
开发者ID:SajasKK,项目名称:magnum,代码行数:58,代码来源:distancefieldconverter.cpp

示例15: switch

bool NaClApplication::HandleInputEvent(const pp::InputEvent& event) {
    /* Don't handle anything during switch from/to fullscreen */
    if(flags & Flag::FullscreenSwitchInProgress) return false;

    Flags tmpFlags = flags;

    switch(event.GetType()) {
        case PP_INPUTEVENT_TYPE_KEYDOWN:
        case PP_INPUTEVENT_TYPE_KEYUP: {
            pp::KeyboardInputEvent keyEvent(event);
            KeyEvent e(static_cast<KeyEvent::Key>(keyEvent.GetKeyCode()), static_cast<InputEvent::Modifier>(keyEvent.GetModifiers()));
            event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN ? keyPressEvent(e) : keyReleaseEvent(e);
            if(!e.isAccepted()) return false;
            break;
        }

        case PP_INPUTEVENT_TYPE_MOUSEDOWN:
        case PP_INPUTEVENT_TYPE_MOUSEUP: {
            pp::MouseInputEvent mouseEvent(event);
            MouseEvent e(static_cast<MouseEvent::Button>(mouseEvent.GetButton()), {mouseEvent.GetPosition().x(), mouseEvent.GetPosition().y()}, static_cast<InputEvent::Modifier>(mouseEvent.GetModifiers()));
            event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN ? mousePressEvent(e) : mouseReleaseEvent(e);
            if(!e.isAccepted()) return false;
            break;
        }

        case PP_INPUTEVENT_TYPE_WHEEL: {
            pp::WheelInputEvent wheelEvent(event);
            if(Math::TypeTraits<Float>::equals(wheelEvent.GetDelta().y(), 0.0f)) return false;
            MouseEvent e(wheelEvent.GetDelta().y() > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {}, static_cast<InputEvent::Modifier>(wheelEvent.GetModifiers()));
            mousePressEvent(e);
            if(!e.isAccepted()) return false;
            break;
        }

        case PP_INPUTEVENT_TYPE_MOUSEMOVE: {
            pp::MouseInputEvent mouseEvent(event);
            MouseMoveEvent e({mouseEvent.GetPosition().x(), mouseEvent.GetPosition().y()},  {mouseEvent.GetMovement().x(), mouseEvent.GetMovement().y()}, static_cast<InputEvent::Modifier>(mouseEvent.GetModifiers()));
            mouseMoveEvent(e);
            if(!e.isAccepted()) return false;
            break;
        }

        default: return false;
    }

    /* Assume everything is properly sequential here */
    CORRADE_INTERNAL_ASSERT((tmpFlags & Flag::SwapInProgress) == (flags & Flag::SwapInProgress));

    /* Redraw, if it won't be handled after swap automatically */
    if((flags & Flag::Redraw) && !(flags & Flag::SwapInProgress)) {
        flags &= ~Flag::Redraw;
        drawEvent();
    }

    return true;
}
开发者ID:ArEnSc,项目名称:magnum,代码行数:56,代码来源:NaClApplication.cpp


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