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


C++ TexturePtr::setSmooth方法代码示例

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


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

示例1: generateLightBubble

TexturePtr LightView::generateLightBubble(float centerFactor)
{
    int bubbleRadius = 256;
    int centerRadius = bubbleRadius * centerFactor;
    int bubbleDiameter = bubbleRadius * 2;
    ImagePtr lightImage = ImagePtr(new Image(Size(bubbleDiameter, bubbleDiameter)));

    for(int x = 0; x < bubbleDiameter; x++) {
        for(int y = 0; y < bubbleDiameter; y++) {
            float radius = std::sqrt((bubbleRadius - x)*(bubbleRadius - x) + (bubbleRadius - y)*(bubbleRadius - y));
            float intensity = stdext::clamp<float>((bubbleRadius - radius) / (float)(bubbleRadius - centerRadius), 0.0f, 1.0f);

            // light intensity varies inversely with the square of the distance
            intensity = intensity * intensity;
            uint8_t colorByte = intensity * 0xff;

            uint8_t pixel[4] = {colorByte,colorByte,colorByte,0xff};
            lightImage->setPixel(x, y, pixel);
        }
    }

    TexturePtr tex = TexturePtr(new Texture(lightImage, true));
    tex->setSmooth(true);
    return tex;
}
开发者ID:DSpeichert,项目名称:otclient,代码行数:25,代码来源:lightview.cpp

示例2: addMultiTexture

void PainterShaderProgram::addMultiTexture(const std::string& file)
{
    if(m_multiTextures.size() > 3)
        g_logger.error("cannot add more multi textures to shader, the max is 3");

    TexturePtr texture = g_textures.getTexture(file);
    if(!texture)
        return;

    texture->setSmooth(true);
    texture->setRepeat(true);

    m_multiTextures.push_back(texture);
}
开发者ID:Anastaciaa,项目名称:otclient-1,代码行数:14,代码来源:paintershaderprogram.cpp

示例3: getTexture

TexturePtr TextureManager::getTexture(const std::string& fileName)
{
    TexturePtr texture;

    // before must resolve filename to full path
    std::string filePath = g_resources.resolvePath(fileName);

    // check if the texture is already loaded
    auto it = m_textures.find(filePath);
    if(it != m_textures.end()) {
        texture = it->second;
    }

    // texture not found, load it
    if(!texture) {
        try {
            std::string filePathEx = g_resources.guessFilePath(filePath, "png");

            // load texture file data
            std::stringstream fin;
            g_resources.readFileStream(filePathEx, fin);
            texture = loadTexture(fin);
        } catch(stdext::exception& e) {
            g_logger.error(stdext::format("Unable to load texture '%s': %s", fileName, e.what()));
            texture = g_textures.getEmptyTexture();
        }

        if(texture) {
            texture->setTime(stdext::time());
            texture->setSmooth(true);
            m_textures[filePath] = texture;
        }
    }

    return texture;
}
开发者ID:Ablankzin,项目名称:otclient,代码行数:36,代码来源:texturemanager.cpp


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