當前位置: 首頁>>代碼示例>>C++>>正文


C++ CORRADE_ASSERT函數代碼示例

本文整理匯總了C++中CORRADE_ASSERT函數的典型用法代碼示例。如果您正苦於以下問題:C++ CORRADE_ASSERT函數的具體用法?C++ CORRADE_ASSERT怎麽用?C++ CORRADE_ASSERT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CORRADE_ASSERT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: CORRADE_ASSERT

Trade::MeshData3D Capsule3D::solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords) {
    CORRADE_ASSERT(hemisphereRings >= 1 && cylinderRings >= 1 && segments >= 3, "Capsule must have at least one hemisphere ring, one cylinder ring and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, std::vector<UnsignedInt>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector3>>{}, std::vector<std::vector<Vector2>>{}));

    Implementation::Spheroid capsule(segments, textureCoords == TextureCoords::Generate ?
        Implementation::Spheroid::TextureCoords::Generate :
        Implementation::Spheroid::TextureCoords::DontGenerate);

    Float height = 2.0f+2.0f*halfLength;
    Float hemisphereTextureCoordsVIncrement = 1.0f/(hemisphereRings*height);
    Rad hemisphereRingAngleIncrement(Constants::pi()/(2*hemisphereRings));

    /* Bottom cap vertex */
    capsule.capVertex(-height/2, -1.0f, 0.0f);

    /* Rings of bottom hemisphere */
    capsule.hemisphereVertexRings(hemisphereRings-1, -halfLength, -Rad(Constants::pi())/2+hemisphereRingAngleIncrement, hemisphereRingAngleIncrement, hemisphereTextureCoordsVIncrement, hemisphereTextureCoordsVIncrement);

    /* Rings of cylinder */
    capsule.cylinderVertexRings(cylinderRings+1, -halfLength, 2.0f*halfLength/cylinderRings, 1.0f/height, 2.0f*halfLength/(cylinderRings*height));

    /* Rings of top hemisphere */
    capsule.hemisphereVertexRings(hemisphereRings-1, halfLength, hemisphereRingAngleIncrement, hemisphereRingAngleIncrement, (1.0f + 2.0f*halfLength)/height+hemisphereTextureCoordsVIncrement, hemisphereTextureCoordsVIncrement);

    /* Top cap vertex */
    capsule.capVertex(height/2, 1.0f, 1.0f);

    /* Faces */
    capsule.bottomFaceRing();
    capsule.faceRings(hemisphereRings*2-2+cylinderRings);
    capsule.topFaceRing();

    return capsule.finalize();
}
開發者ID:Driky,項目名稱:magnum,代碼行數:33,代碼來源:Capsule.cpp

示例2: CORRADE_ASSERT

Trade::MeshData3D Cylinder::solid(const UnsignedInt rings, const UnsignedInt segments, const Float halfLength, const Flags flags) {
    CORRADE_ASSERT(rings >= 1 && segments >= 3, "Primitives::Cylinder::solid(): cylinder must have at least one ring and three segments", Trade::MeshData3D(MeshPrimitive::Triangles, {}, {}, {}, {}));

    Implementation::Spheroid cylinder(segments, flags & Flag::GenerateTextureCoords ? Implementation::Spheroid::TextureCoords::Generate : Implementation::Spheroid::TextureCoords::DontGenerate);

    const Float length = 2.0f*halfLength;
    const Float textureCoordsV = flags & Flag::CapEnds ? 1.0f/(length+2.0f) : 0.0f;

    /* Bottom cap */
    if(flags & Flag::CapEnds) {
        cylinder.capVertex(-halfLength, -1.0f, 0.0f);
        cylinder.capVertexRing(-halfLength, textureCoordsV, Vector3::yAxis(-1.0f));
    }

    /* Vertex rings */
    cylinder.cylinderVertexRings(rings+1, -halfLength, length/rings, textureCoordsV, length/(rings*(flags & Flag::CapEnds ? length + 2.0f : length)));

    /* Top cap */
    if(flags & Flag::CapEnds) {
        cylinder.capVertexRing(halfLength, 1.0f - textureCoordsV, Vector3::yAxis(1.0f));
        cylinder.capVertex(halfLength, 1.0f, 1.0f);
    }

    /* Faces */
    if(flags & Flag::CapEnds) cylinder.bottomFaceRing();
    cylinder.faceRings(rings, flags & Flag::CapEnds ? 1 : 0);
    if(flags & Flag::CapEnds) cylinder.topFaceRing();

    return cylinder.finalize();
}
開發者ID:Ali-Wassouf,項目名稱:magnum,代碼行數:30,代碼來源:Cylinder.cpp

示例3: CORRADE_ASSERT

template<UnsignedInt dimensions> ImageData<dimensions>::operator CompressedImageView<dimensions>() const
{
    CORRADE_ASSERT(_compressed, "Trade::ImageData::type(): the image is not compressed", (CompressedImageView<dimensions>{_compressedStorage, _compressedFormat, _size}));
    return CompressedImageView<dimensions>{
        _compressedStorage,
        _compressedFormat, _size, _data};
}
開發者ID:Squareys,項目名稱:magnum,代碼行數:7,代碼來源:ImageData.cpp

示例4: CORRADE_ASSERT

Trade::MeshData3D UVSphere::solid(UnsignedInt rings, UnsignedInt segments, TextureCoords textureCoords) {
    CORRADE_ASSERT(rings >= 2 && segments >= 3, "UVSphere must have at least two rings and three segments", Trade::MeshData3D(Mesh::Primitive::Triangles, {}, {}, {}, {}));

    Implementation::Spheroid sphere(segments, textureCoords == TextureCoords::Generate ?
        Implementation::Spheroid::TextureCoords::Generate :
        Implementation::Spheroid::TextureCoords::DontGenerate);

    Float textureCoordsVIncrement = 1.0f/rings;
    Rad ringAngleIncrement(Constants::pi()/rings);

    /* Bottom cap vertex */
    sphere.capVertex(-1.0f, -1.0f, 0.0f);

    /* Vertex rings */
    sphere.hemisphereVertexRings(rings-1, 0.0f, -Rad(Constants::pi())/2+ringAngleIncrement, ringAngleIncrement, textureCoordsVIncrement, textureCoordsVIncrement);

    /* Top cap vertex */
    sphere.capVertex(1.0f, 1.0f, 1.0f);

    /* Faces */
    sphere.bottomFaceRing();
    sphere.faceRings(rings-2);
    sphere.topFaceRing();

    return sphere.finalize();
}
開發者ID:awoland,項目名稱:magnum,代碼行數:26,代碼來源:UVSphere.cpp

示例5: CORRADE_ASSERT

Shader& Shader::addFile(const std::string& filename) {
    CORRADE_ASSERT(Utility::Directory::fileExists(filename),
        "Shader file " << '\'' + filename + '\'' << " cannot be read.", *this);

    addSource(Utility::Directory::readString(filename));
    return *this;
}
開發者ID:ArEnSc,項目名稱:magnum,代碼行數:7,代碼來源:Shader.cpp

示例6: CORRADE_ASSERT

Containers::Array<unsigned char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::u32string&) const
#else
Containers::Array<unsigned char> AbstractFontConverter::doExportFontToSingleData(AbstractFont&, GlyphCache&, const std::vector<char32_t>&) const
#endif
{
    CORRADE_ASSERT(false,
        "Text::AbstractFontConverter::exportFontToSingleData(): feature advertised but not implemented", nullptr);
}
開發者ID:DYSEQTA,項目名稱:magnum,代碼行數:8,代碼來源:AbstractFontConverter.cpp

示例7: CORRADE_ASSERT

AbstractTexture* AbstractTexture::generateMipmap() {
    #ifndef MAGNUM_TARGET_GLES
    CORRADE_ASSERT(_target != GL_TEXTURE_RECTANGLE, "AbstractTexture: rectangle textures cannot have mipmaps", this);
    #endif

    (this->*mipmapImplementation)();
    return this;
}
開發者ID:JanDupal,項目名稱:magnum,代碼行數:8,代碼來源:AbstractTexture.cpp

示例8: CORRADE_ASSERT

std::vector<std::pair<std::string, Containers::Array<char>>> AbstractFontConverter::doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const {
    CORRADE_ASSERT(!(features() & Feature::MultiFile),
                   "Text::AbstractFontConverter::exportGlyphCacheToData(): feature advertised but not implemented", {});

    std::vector<std::pair<std::string, Containers::Array<char>>> out;
    out.emplace_back(filename, std::move(doExportGlyphCacheToSingleData(cache)));
    return out;
}
開發者ID:BrainlessLabsInc,項目名稱:magnum,代碼行數:8,代碼來源:AbstractFontConverter.cpp

示例9: CORRADE_ASSERT

bool Sdl2Application::tryCreateContext(const Configuration& configuration) {
    CORRADE_ASSERT(!context, "Platform::Sdl2Application::tryCreateContext(): context already created", false);

    /* Enable double buffering and 24bt depth buffer */
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

    /* Multisampling */
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, configuration.sampleCount() > 1 ? 1 : 0);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, configuration.sampleCount());

    #ifndef CORRADE_TARGET_EMSCRIPTEN
    /* Context flags */
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, int(configuration.flags()));
    #endif

    /* Flags: if not hidden, set as shown */
    Uint32 windowFlags(configuration.windowFlags());
    if(!(configuration.windowFlags() & Configuration::WindowFlag::Hidden)) windowFlags |= SDL_WINDOW_SHOWN;

    /** @todo Remove when Emscripten has proper SDL2 support */
    #ifndef CORRADE_TARGET_EMSCRIPTEN
    /* Set context version, if requested */
    if(configuration.version() != Version::None) {
        Int major, minor;
        std::tie(major, minor) = version(configuration.version());
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor);

        #ifndef MAGNUM_TARGET_GLES
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, configuration.version() >= Version::GL310 ?
            SDL_GL_CONTEXT_PROFILE_CORE : SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
        #else
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
        #endif
    }

    #ifdef MAGNUM_TARGET_GLES
    else {
        #ifdef MAGNUM_TARGET_GLES3
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
        #elif defined(MAGNUM_TARGET_GLES2)
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
        #else
        #error Unsupported OpenGL ES version
        #endif
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
    }

    /* On OS X we need to create 3.2 context, as the default (2.1) contains
       compatibility features which are not implemented for newer GL versions
       in Apple's GL drivers, thus we would be forever stuck on 2.1 without the
       new features. In practice SDL fails to create 2.1 context on recent OS X
       versions. */
    #elif defined(__APPLE__)
    else {
開發者ID:vesper666,項目名稱:magnum,代碼行數:57,代碼來源:Sdl2Application.cpp

示例10: CORRADE_ASSERT

template<class Transformation> Object<Transformation>& Object<Transformation>::setParentKeepTransformation(Object<Transformation>* parent) {
    CORRADE_ASSERT(scene() == parent->scene(), "SceneGraph::Object::setParentKeepTransformation(): both parents must be in the same scene", *this);

    const auto transformation = Implementation::Transformation<Transformation>::compose(
        Implementation::Transformation<Transformation>::inverted(parent->absoluteTransformation()), absoluteTransformation());
    setParent(parent);
    Transformation::setTransformation(transformation);

    return *this;
}
開發者ID:BrainlessLabsInc,項目名稱:magnum,代碼行數:10,代碼來源:Object.hpp

示例11: CORRADE_ASSERT

std::pair<Float, Float> AbstractFont::doOpenFile(const std::string& filename, const Float size) {
    CORRADE_ASSERT(features() & Feature::OpenData && !(features() & Feature::MultiFile),
        "Text::AbstractFont::openFile(): not implemented", {});

    /* Open file */
    if(!Utility::Directory::fileExists(filename)) {
        Error() << "Trade::AbstractFont::openFile(): cannot open file" << filename;
        return {};
    }

    return doOpenSingleData(Utility::Directory::read(filename), size);
}
開發者ID:DYSEQTA,項目名稱:magnum,代碼行數:12,代碼來源:AbstractFont.cpp

示例12: CORRADE_ASSERT

void* Buffer::mapSub(const GLintptr offset, const GLsizeiptr length, const MapAccess access) {
    /** @todo Enable also in Emscripten (?) when extension loader is available */
    #ifdef CORRADE_TARGET_NACL
    CORRADE_ASSERT(!_mappedBuffer, "Buffer::mapSub(): the buffer is already mapped", nullptr);
    return _mappedBuffer = glMapBufferSubDataCHROMIUM(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access));
    #else
    CORRADE_INTERNAL_ASSERT(false);
    static_cast<void>(offset);
    static_cast<void>(length);
    static_cast<void>(access);
    #endif
}
開發者ID:jakubsuchybio,項目名稱:magnum,代碼行數:12,代碼來源:Buffer.cpp

示例13: CORRADE_ASSERT

template<> Long AbstractQuery::result<Long>() {
    CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {});

    /** @todo Re-enable when extension loader is available for ES */
    Long result;
    #ifndef MAGNUM_TARGET_GLES
    glGetQueryObjecti64v(_id, GL_QUERY_RESULT, &result);
    #else
    CORRADE_INTERNAL_ASSERT(false);
    //glGetQueryObjecti64vEXT(_id, GL_QUERY_RESULT, &result);
    #endif
    return result;
}
開發者ID:severin-lemaignan,項目名稱:magnum,代碼行數:13,代碼來源:Query.cpp

示例14: CORRADE_ASSERT

bool AbstractImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) {
    CORRADE_ASSERT(features() & Feature::ConvertData, "Trade::AbstractImageConverter::exportToFile(): not implemented", false);

    const auto data = doExportToData(image);
    if(!data) return false;

    /* Open file */
    if(!Utility::Directory::write(filename, data)) {
        Error() << "Trade::AbstractImageConverter::exportToFile(): cannot write to file" << filename;
        return false;
    }

    return true;
}
開發者ID:jkhoogland,項目名稱:magnum,代碼行數:14,代碼來源:AbstractImageConverter.cpp

示例15: combineIndexArrays

std::pair<std::vector<UnsignedInt>, std::vector<UnsignedInt>> combineIndexArrays(const std::vector<UnsignedInt>& interleavedArrays, const UnsignedInt stride) {
    CORRADE_ASSERT(stride != 0, "MeshTools::combineIndexArrays(): stride can't be zero", {});
    CORRADE_ASSERT(interleavedArrays.size() % stride == 0, "MeshTools::combineIndexArrays(): array size is not divisible by stride", {});

    /* Hash map with index combinations, containing just indices into
       interleavedArrays vector, hashing and comparison is done using IndexHash
       and IndexEqual functors. Reserving more buckets than necessary (i.e. as
       if each combination was unique). */
    std::unordered_map<UnsignedInt, UnsignedInt, IndexHash, IndexEqual> indexCombinations(
        interleavedArrays.size()/stride,
        IndexHash(interleavedArrays, stride),
        IndexEqual(interleavedArrays, stride));

    /* Make the index combinations unique. Original indices into original
       `interleavedArrays` array were 0, 1, 2, 3, ..., `combinedIndices`
       contains new ones into new (shorter) `newInterleavedArrays` array. */
    std::vector<UnsignedInt> combinedIndices;
    combinedIndices.reserve(interleavedArrays.size()/stride);
    std::vector<UnsignedInt> newInterleavedArrays;
    for(std::size_t oldIndex = 0, end = interleavedArrays.size()/stride; oldIndex != end; ++oldIndex) {
        /* Try to insert new index combination to the map */
        const auto result = indexCombinations.emplace(oldIndex, indexCombinations.size());

        /* Add the (either new or already existing) index to resulting index array */
        combinedIndices.push_back(result.first->second);

        /* If this is new combination, copy it to new interleaved arrays */
        if(result.second) newInterleavedArrays.insert(newInterleavedArrays.end(),
            interleavedArrays.begin()+oldIndex*stride,
            interleavedArrays.begin()+(oldIndex+1)*stride);
    }

    CORRADE_INTERNAL_ASSERT(combinedIndices.size() == interleavedArrays.size()/stride &&
                            newInterleavedArrays.size() <= interleavedArrays.size());

    return {std::move(combinedIndices), std::move(newInterleavedArrays)};
}
開發者ID:RobertoMalatesta,項目名稱:magnum,代碼行數:37,代碼來源:CombineIndexedArrays.cpp


注:本文中的CORRADE_ASSERT函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。