Exemplo n.º 1
0
void TextureOgl::getTexels(
    unsigned int mipLevel, unsigned int /*size*/, void *texels ) const
{
    storm_assert( _description.layout != Layout::Separate2dMsaa );
    storm_assert( _description.layout != Layout::Layered2dMsaa );

    storm_assert( mipLevel < _description.mipLevels );

    // TODO: check size

    ScopeTextureBinding scopeTextureBinding( _target, _texture );

    if( _description.layout == Layout::CubeMap ) {

        if( _texelDescription.compressed )
            throwNotImplemented();

        const MipLevelDimensions mipLevelDimensions =
            getMipLevelDimensions( mipLevel );

        setTexelTransferAlignment( mipLevelDimensions.width );

        const GLenum targets[] = {
            GL_TEXTURE_CUBE_MAP_POSITIVE_X,
            GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
            GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
            GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
            GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
            GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
        };

        for( GLenum target : targets ) {
            ::glGetTexImage( target, mipLevel,
                _texelDescription.format, _texelDescription.type, texels );
            checkResult( "::glGetTexImage" );

            texels = static_cast<unsigned char*>( texels ) +
                _texelDescription.size *
                mipLevelDimensions.width *
                mipLevelDimensions.height;
        }

        resetTexelTransferAlignment();
        return;
    }

    if( !_texelDescription.compressed ) {
        setTexelTransferAlignment( getMipLevelDimensions(mipLevel).width );

        ::glGetTexImage( _target, mipLevel,
            _texelDescription.format, _texelDescription.type, texels );
        checkResult( "::glGetTexImage" );

        resetTexelTransferAlignment();
    } else {
        ::glGetCompressedTexImage( _target, mipLevel, texels );
        checkResult( "::glGetCompressedTexImage" );
    }
}
Exemplo n.º 2
0
void RenderingWindowX11::setFullscreen( FullscreenMode fullscreenMode ) {
    if( fullscreenMode.custom )
        throwNotImplemented();

    setDimensionsConstraint( {0, 0} );
    setFullscreen( true );

    ::XMapWindow( _display, _handle );

    _fullscreen = true;
}
Exemplo n.º 3
0
TextureOgl::TextureOgl( const Description &description ) :
    _description( description ),
    _texelDescription( selectTexelDescription(description.format) ),
    _target( selectTarget(description.layout) )
{
    validateDescription();

    ScopeTextureBinding scopeTextureBinding( _target, _texture );

    const unsigned int levelsMaximum = getMipLevelsMaximum( _description );
    const unsigned int levels = _description.mipLevels == CompleteMipMap ?
        levelsMaximum : _description.mipLevels;
    storm_assert( levels <= levelsMaximum );

    if( _description.mipLevels == CompleteMipMap )
        _description.mipLevels = levels;

    switch( _description.layout ) {
    case Layout::Separate1d:
        ::glTexStorage1D(
            _target, levels, _texelDescription.internalFormat,
            description.width );
        checkResult( "::glTexStorage1D" );
        break;
    case Layout::Separate2d:
    case Layout::CubeMap:
        ::glTexStorage2D(
            _target, levels, _texelDescription.internalFormat,
            description.width,
            description.height );
        checkResult( "::glTexStorage2D" );
        break;
    case Layout::Separate3d:
        ::glTexStorage3D(
            _target, levels, _texelDescription.internalFormat,
            description.width,
            description.height,
            description.depth );
        checkResult( "::glTexStorage3D" );
        break;
    case Layout::Layered1d:
        ::glTexStorage2D(
            _target, levels, _texelDescription.internalFormat,
            description.width,
            description.layers );
        checkResult( "::glTexStorage2D" );
        break;
    case Layout::Layered2d:
        ::glTexStorage3D(
            _target, levels, _texelDescription.internalFormat,
            description.width,
            description.height,
            description.layers );
        checkResult( "::glTexStorage3D" );
        break;
    case Layout::Separate2dMsaa:
        ::glTexStorage2DMultisample(
            _target, description.texelSamples,
            _texelDescription.internalFormat,
            description.width,
            description.height,
            GL_TRUE );
        checkResult( "::glTexStorage2DMultisample" );
        break;
    case Layout::Layered2dMsaa:
        ::glTexStorage3DMultisample(
            _target, description.texelSamples,
            _texelDescription.internalFormat,
            description.width,
            description.height,
            description.layers,
            GL_TRUE );
        checkResult( "::glTexStorage3DMultisample" );
        break;
    default:
        throwNotImplemented();
    }
}
Exemplo n.º 4
0
void RenderingWindowX11::setWindowedMaximized() {
    throwNotImplemented();
}