예제 #1
0
bool GLTextureCubeMap::set( GLCubeMapFace face,
    Array2DReadView< uint8x4 > data, GLImageFormat format,
    const Vector2i& dstOffset )
{
    if( dstOffset.x + data.width() > sideLength() ||
        dstOffset.y + data.height() > sideLength() )
    {
        return false;
    }
    if( format != GLImageFormat::RGBA &&
        format != GLImageFormat::BGRA )
    {
        return false;
    }

    //glPushClientAttribDefaultEXT( GL_CLIENT_PIXEL_STORE_BIT );
    // TODO: alignment, strides, ..., has to be packed

    // DSA treats a cube map as a 2D array texture.
    glTextureSubImage3D
    (
        id(), 0,
        dstOffset.x, dstOffset.y, static_cast< int >( face ),
        data.width(), data.height(), 1, // 1 face
        static_cast< GLenum >( format ), GL_UNSIGNED_BYTE,
        data.pointer()
    );

    //glPopClientAttrib();

    return true;
}
예제 #2
0
bool GLTextureRectangle::set( Array2DReadView< uint8x2 > srcData,
    GLImageFormat srcFormat,
    const Vector2i& dstOffset )
{
    if( srcFormat != GLImageFormat::RG )
    {
        return false;
    }
    if( !srcData.packed() )
    {
        return false;
    }
    const GLPixelType srcType = GLPixelType::UNSIGNED_BYTE;
    return set2D( srcData.pointer(), srcData.size(), srcFormat, srcType,
                 dstOffset );
}
예제 #3
0
bool GLTextureRectangle::set( Array2DReadView< Vector4f > srcData,
    GLImageFormat srcFormat,
    const Vector2i& dstOffset )
{
    if( srcFormat != GLImageFormat::RGBA && srcFormat != GLImageFormat::BGRA )
    {
        return false;
    }
    if( !srcData.packed() )
    {
        return false;
    }
    const GLPixelType srcType = GLPixelType::FLOAT;
    return set2D( srcData.pointer(), srcData.size(), srcFormat, srcType,
                 dstOffset );
}
예제 #4
0
// static
bool PNGIO::write( const std::string& filename,
    Array2DReadView< uint8x4 > image )
{
    Array2D< uint8x4 > tmpImage;
    const uint8_t* srcPointer;

    if( !image.packed() )
    {
        tmpImage.resize( image.size() );
        copy< uint8x4 >( image, tmpImage );
        srcPointer = reinterpret_cast< const uint8_t* >( tmpImage.pointer() );
    }
    else
    {
        srcPointer = reinterpret_cast< const uint8_t* >( image.pointer() );
    }

    unsigned int errVal = lodepng::encode(
        filename, srcPointer, image.width(), image.height(), LCT_RGBA );
    bool succeeded = ( errVal == 0 );
    return succeeded;
}