void LayerBase::drawForSreenShot()
{
    const DisplayHardware& hw(graphicPlane(0).displayHardware());
    setFiltering(true);
    onDraw( Region(hw.bounds()) );
    setFiltering(false);
}
void LayerBase::drawForSreenShot()
{
    //Dont draw External-only layers
    if (isLayerExternalOnly(getLayer())) {
        return;
    }
    const DisplayHardware& hw(graphicPlane(0).displayHardware());
    setFiltering(true);
    onDraw( Region(hw.bounds()) );
    setFiltering(false);
}
Esempio n. 3
0
 bool Texture1D::loadFromMemory(UI32 width,
                                I32 internalFormat,
                                UI32 pixelFormat,
                                UI32 pixelType,
                                I32 minFilter,
                                I32 magFilter,
                                I32 wrapMode,
                                const void* data,
                                bool mipmap)
 {
     m_width = width;
     
     // Create a texture
     render::lib::genTextures(1, &m_texture);
     if (m_texture)
     {
         setFiltering(minFilter, magFilter);
         setWrapMode(wrapMode);
         bind();
         render::lib::texImage1D(ODIN_TEXTURE_1D, 0, internalFormat, m_width, 0, pixelFormat, pixelType, data);
         unbind();
         if (mipmap) generateMipmaps();
         
         return true;
     }
     else return false;
 }
void TextureResource::createTexture() {

    if(!textureid) glGenTextures(1, &textureid);

    glBindTexture(target, textureid);

    if(w != 0 && format != 0) {

        GLint internalFormat = 0;

        switch(format) {
            case GL_ALPHA:
                internalFormat = GL_ALPHA;
                break;
            case GL_LUMINANCE:
                internalFormat = GL_LUMINANCE;
                break;
            default:
                internalFormat = GL_RGBA;
                break;
        }

        if(mipmaps) {
            gluBuild2DMipmaps(target, internalFormat, w, h, format, GL_UNSIGNED_BYTE, data);
        } else {
            glTexImage2D(target, 0, internalFormat, w, h, 0, format, GL_UNSIGNED_BYTE, data);
        }
    }

    setFiltering(min_filter, mag_filter);
    setWrapStyle(wrap);
}
Esempio n. 5
0
 //-----------------------------------------------------------------------
 void Sampler::setFiltering(TextureFilterOptions filterType)
 {
     switch (filterType)
     {
     case TFO_NONE:
         setFiltering(FO_POINT, FO_POINT, FO_NONE);
         break;
     case TFO_BILINEAR:
         setFiltering(FO_LINEAR, FO_LINEAR, FO_POINT);
         break;
     case TFO_TRILINEAR:
         setFiltering(FO_LINEAR, FO_LINEAR, FO_LINEAR);
         break;
     case TFO_ANISOTROPIC:
         setFiltering(FO_ANISOTROPIC, FO_ANISOTROPIC, Root::getSingleton().getRenderSystem()->hasAnisotropicMipMapFilter() ? FO_ANISOTROPIC : FO_LINEAR);
         break;
     }
 }
Esempio n. 6
0
TextureNodeRGBA::TextureNodeRGBA(QQuickWindow& window, const bool dynamic)
    : _window(window)
    , _dynamicTexture(dynamic)
    , _texture(window.createTextureFromId(0, QSize(1, 1)))
{
    if (_texture) // needed for null texture in unit tests without a scene graph
        setTexture(_texture.get());
    setFiltering(QSGTexture::Linear);
    setMipmapFiltering(QSGTexture::Linear);
}
Esempio n. 7
0
TextureNode::TextureNode( const QSize& size, QQuickWindow* window,
                          TextureFormat )
    : _window( window )
    , _frontTexture( window->createTextureFromId( 0 , QSize( 1 ,1 )))
    , _backTexture( _createTexture( size ))
{
    setTexture( _frontTexture.get( ));
    setFiltering( QSGTexture::Linear );
    setMipmapFiltering( QSGTexture::Linear );
}
Esempio n. 8
0
PluginDialog::PluginDialog(QWidget *parent)
    : QDialog(parent),
      m_view(new ExtensionSystem::PluginView(this))
{
    QVBoxLayout *vl = new QVBoxLayout(this);

    auto filterEdit = new Utils::FancyLineEdit(this);
    filterEdit->setFiltering(true);
    connect(filterEdit, &Utils::FancyLineEdit::filterChanged,
            m_view, &ExtensionSystem::PluginView::setFilter);
    vl->addWidget(filterEdit);

    vl->addWidget(m_view);

    m_detailsButton = new QPushButton(tr("Details"), this);
    m_errorDetailsButton = new QPushButton(tr("Error Details"), this);
    m_closeButton = new QPushButton(tr("Close"), this);
    m_detailsButton->setEnabled(false);
    m_errorDetailsButton->setEnabled(false);
    m_closeButton->setEnabled(true);
    m_closeButton->setDefault(true);

    m_restartRequired = new QLabel(tr("Restart required."), this);
    if (!s_isRestartRequired)
        m_restartRequired->setVisible(false);

    QHBoxLayout *hl = new QHBoxLayout;
    hl->addWidget(m_detailsButton);
    hl->addWidget(m_errorDetailsButton);
    hl->addSpacing(10);
    hl->addWidget(m_restartRequired);
    hl->addStretch(5);
    hl->addWidget(m_closeButton);

    vl->addLayout(hl);

    resize(650, 400);
    setWindowTitle(tr("Installed Plugins"));

    connect(m_view, &ExtensionSystem::PluginView::currentPluginChanged,
            this, &PluginDialog::updateButtons);
    connect(m_view, &ExtensionSystem::PluginView::pluginActivated,
            this, &PluginDialog::openDetails);
    connect(m_view, &ExtensionSystem::PluginView::pluginSettingsChanged,
            this, &PluginDialog::updateRestartRequired);
    connect(m_detailsButton, &QAbstractButton::clicked,
            [this]  { openDetails(m_view->currentPlugin()); });
    connect(m_errorDetailsButton, &QAbstractButton::clicked,
            this, &PluginDialog::openErrorDetails);
    connect(m_closeButton, &QAbstractButton::clicked,
            this, &PluginDialog::closeDialog);
    updateButtons();
}
MirBufferSGTexture::MirBufferSGTexture(std::shared_ptr<mir::graphics::Buffer> buffer)
    : QSGTexture()
    , m_mirBuffer(buffer)
    , m_textureId(0)
{
    glGenTextures(1, &m_textureId);

    setFiltering(QSGTexture::Linear);
    setHorizontalWrapMode(QSGTexture::ClampToEdge);
    setVerticalWrapMode(QSGTexture::ClampToEdge);

    mg::Size size = m_mirBuffer->size();
    m_height = size.height.as_int();
    m_width = size.width.as_int();
}
Esempio n. 10
0
 bool Cubemap::loadFromMemory(UI32 width, UI32 height,
                              const void* dataPX,
                              const void* dataNX,
                              const void* dataPY,
                              const void* dataNY,
                              const void* dataPZ,
                              const void* dataNZ,
                              I32 internalFormat,
                              UI32 pixelFormat,
                              UI32 pixelType,
                              I32 minFilter,
                              I32 magFilter,
                              I32 wrapMode,
                              bool mipmap)
 
 {
     m_width = width;
     m_height = height;
     
     const void* data[6] =
     {
         dataPX,
         dataNX,
         dataPY,
         dataNY,
         dataPZ,
         dataNZ
     };
     
     render::lib::genTextures(1, &m_texture);
     if (m_texture)
     {
         setFiltering(minFilter, magFilter);
         setWrapMode(wrapMode);
         bind();
         for (UI32 i = 0; i < 6; ++i)
         {
             render::lib::texImage2D(ODIN_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internalFormat, m_width, m_height, 0, pixelFormat, pixelType, data[i]);
         }
         unbind();
         
         if (mipmap) generateMipmaps();
         
         return true;
     }
     else return false;
     
 }
Esempio n. 11
0
void Texture::Create(const void *pixels,bool mipmaps){
	//Alocate space for texture in GPU and return handler
	glGenTextures(1, &m_texture);
	//bind the texture for use
	Bind();
	//Texture wraping
	GLint clamp = m_clamp ? GL_CLAMP_TO_EDGE : GL_REPEAT;
	setWrap(clamp);
	//Texture filtering
	setFiltering(mipmaps ? GL_NEAREST_MIPMAP_LINEAR : m_filter);

	if (mipmaps)
		glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP,GL_TRUE);

	glTexImage2D(GL_TEXTURE_2D, 0, m_iternalFormat, m_width, m_height, 0, m_format, m_type, pixels);
	
}
Esempio n. 12
0
PluginDialog::PluginDialog(QWidget *parent)
    : QDialog(parent),
      m_view(new ExtensionSystem::PluginView(this))
{
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    QVBoxLayout *vl = new QVBoxLayout(this);

    auto filterLayout = new QHBoxLayout;
    vl->addLayout(filterLayout);
    auto filterEdit = new Utils::FancyLineEdit(this);
    filterEdit->setFiltering(true);
    connect(filterEdit, &Utils::FancyLineEdit::filterChanged,
            m_view, &ExtensionSystem::PluginView::setFilter);
    filterLayout->addWidget(filterEdit);
    m_view->setShowHidden(false);
    auto showHidden = new QCheckBox(tr("Show all"));
    showHidden->setToolTip(tr("Show all installed plugins, including base plugins "
                              "and plugins that are not available on this platform."));
    showHidden->setChecked(m_view->isShowingHidden());
    connect(showHidden, &QCheckBox::stateChanged,
            m_view, &ExtensionSystem::PluginView::setShowHidden);
    filterLayout->addWidget(showHidden);

    vl->addWidget(m_view);

    m_detailsButton = new QPushButton(tr("Details"), this);
    m_errorDetailsButton = new QPushButton(tr("Error Details"), this);
    m_closeButton = new QPushButton(tr("Close"), this);
    m_detailsButton->setEnabled(false);
    m_errorDetailsButton->setEnabled(false);
    m_closeButton->setEnabled(true);
    m_closeButton->setDefault(true);

    m_restartRequired = new QLabel(tr("Restart required."), this);
    if (!s_isRestartRequired)
        m_restartRequired->setVisible(false);

    QHBoxLayout *hl = new QHBoxLayout;
    hl->addWidget(m_detailsButton);
    hl->addWidget(m_errorDetailsButton);
    hl->addSpacing(10);
    hl->addWidget(m_restartRequired);
    hl->addStretch(5);
    hl->addWidget(m_closeButton);

    vl->addLayout(hl);

    resize(650, 400);
    setWindowTitle(tr("Installed Plugins"));

    connect(m_view, &ExtensionSystem::PluginView::currentPluginChanged,
            this, &PluginDialog::updateButtons);
    connect(m_view, &ExtensionSystem::PluginView::pluginActivated,
            this, &PluginDialog::openDetails);
    connect(m_view, &ExtensionSystem::PluginView::pluginSettingsChanged,
            this, &PluginDialog::updateRestartRequired);
    connect(m_detailsButton, &QAbstractButton::clicked,
            [this]  { openDetails(m_view->currentPlugin()); });
    connect(m_errorDetailsButton, &QAbstractButton::clicked,
            this, &PluginDialog::openErrorDetails);
    connect(m_closeButton, &QAbstractButton::clicked,
            this, &PluginDialog::closeDialog);
    updateButtons();
}
Esempio n. 13
0
// constructor for DDS textures
void COpenGLTexture::updateDDSTexture(ISGPImage* surface)
{
	COpenGLConfig* pOpenGLConfig = COpenGLConfig::getInstance();
	SGPImageDDS *pSurface = static_cast<SGPImageDDS*>(surface);
	InternalFormat = pSurface->getInternalFormat();
	PixelFormat = pSurface->getExternalFormat();
	PixelType = pSurface->getPixelType();	

	ImageSize = surface->getDimension();
	TextureSize = ImageSize.getOptimalSize( !RenderDevice->queryDriverFeature(SGPVDF_TEXTURE_NPOT) );
	m_ColorFormat = getColorFormatFromInternalFormat(InternalFormat);

	glGenTextures(1, &OpenGLTextureID);

	// Loading a volume texture: 3D Texture
	if( pSurface->isVolume() )
	{
		TextureTarget = GL_TEXTURE_3D;
		bool bindsucceed = BindTexture3D(0);
		if( !bindsucceed || RenderDevice->testGLError() )
			Logger::getCurrentLogger()->writeToLog(String("Could not bind Texture"), ELL_ERROR);

		glTexImage3D(GL_TEXTURE_3D, 0, InternalFormat, 
			pSurface->getMipmapSize(0).Width, 
			pSurface->getMipmapSize(0).Height,
			pSurface->getMipmapDepth(0), 0, PixelFormat, 
			pSurface->getPixelType(), pSurface->getMipmapData(0));
		
		HasMipMaps = false;
		if( !pOpenGLConfig->Force_Disable_MIPMAPPING )
		{
			for(int i = 1; i < pSurface->getNumberOfMipmaps(); i++)
			{	
				HasMipMaps = true;
				glTexImage3D(GL_TEXTURE_3D, i, InternalFormat, 
					pSurface->getMipmapSize(i).Width, 
					pSurface->getMipmapSize(i).Height, 
					pSurface->getMipmapDepth(i), 0, PixelFormat, 
					pSurface->getPixelType(), pSurface->getMipmapData(i));
			}
			MipMapLevels = pSurface->getNumberOfMipmaps();
		}
		//unBindTexture3D(0);
	}
	else if( pSurface->isCubemap() )
	{
		TextureTarget = GL_TEXTURE_CUBE_MAP_ARB;
		//uncompressed cubemap texture
		bool bindsucceed = BindTextureCubeMap(0);
		if( !bindsucceed || RenderDevice->testGLError() )
			Logger::getCurrentLogger()->writeToLog(String("Could not bind Texture"), ELL_ERROR);
		
		uint32 MipMapNum = pSurface->getNumberOfMipmaps() / 6;

		for(int n = 0; n < 6; n++)
		{
			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+n, 0, InternalFormat,
				pSurface->getMipmapSize(0).Width, 
				pSurface->getMipmapSize(0).Height,
				0, PixelFormat, pSurface->getPixelType(), 
				pSurface->getCubemap(n));

			HasMipMaps = false;
			if( !pOpenGLConfig->Force_Disable_MIPMAPPING )
			{
				for(uint32 i = 1; i < MipMapNum; i++)
				{
					HasMipMaps = true;
					glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+n, i, InternalFormat, 
						pSurface->getMipmapSize(n*MipMapNum+i).Width, 
						pSurface->getMipmapSize(n*MipMapNum+i).Height,
						0, PixelFormat, pSurface->getPixelType(),
						pSurface->getMipmapData(n*MipMapNum+i));
				}
				MipMapLevels = MipMapNum;
			}
		}
		//unBindTextureCubeMap(0);
	}
	else	// 2D texture
	{
		TextureTarget = GL_TEXTURE_2D;
		bool bindsucceed = BindTexture2D(0);
		if( !bindsucceed || RenderDevice->testGLError() )
			Logger::getCurrentLogger()->writeToLog(String("Could not bind Texture"), ELL_ERROR);

		if( pSurface->isCompressed() )
		{
			RenderDevice->extGlCompressedTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, 
				pSurface->getMipmapSize(0).Width,
				pSurface->getMipmapSize(0).Height, 0, 
				pSurface->getMipmapDataBytes(0), 
				pSurface->getMipmapData(0));

			HasMipMaps = false;
			if( !pOpenGLConfig->Force_Disable_MIPMAPPING )
			{
				for (int i = 1; i < pSurface->getNumberOfMipmaps(); i++)
				{
					HasMipMaps = true;
					RenderDevice->extGlCompressedTexImage2D(GL_TEXTURE_2D, i, InternalFormat, 
						pSurface->getMipmapSize(i).Width,
						pSurface->getMipmapSize(i).Height, 0, 
						pSurface->getMipmapDataBytes(i), 
						pSurface->getMipmapData(i));
				}
				MipMapLevels = pSurface->getNumberOfMipmaps();
			}
		}
		else
		{
			if( pSurface->isSwap() )
				glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_TRUE );

			glPixelStorei( GL_UNPACK_ROW_LENGTH, pSurface->getMipmapSize(0).Width );
			glTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, 
				pSurface->getMipmapSize(0).Width, 
				pSurface->getMipmapSize(0).Height, 0,
				PixelFormat, pSurface->getPixelType(), 
				pSurface->getMipmapData(0));

			HasMipMaps = false;
			if( !pOpenGLConfig->Force_Disable_MIPMAPPING )
			{
				for(int i = 1; i < pSurface->getNumberOfMipmaps(); i++)
				{
					HasMipMaps = true;
					glPixelStorei( GL_UNPACK_ROW_LENGTH, pSurface->getMipmapSize(i).Width );
					glTexImage2D(GL_TEXTURE_2D, i, InternalFormat, 
						pSurface->getMipmapSize(i).Width,
						pSurface->getMipmapSize(i).Height, 0,
						PixelFormat, pSurface->getPixelType(), 
						pSurface->getMipmapData(i));
				}
				MipMapLevels = pSurface->getNumberOfMipmaps();
			}
			glPixelStorei( GL_UNPACK_SWAP_BYTES, GL_FALSE );
			glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
		}

		if( HasMipMaps )
			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, pSurface->getNumberOfMipmaps()-1 );
		
		//unBindTexture2D(0);
	}

	setFiltering(TEXTURE_FILTER_MAG_BILINEAR, TEXTURE_FILTER_MIN_TRILINEAR);
	//if( HasMipMaps )
	//	MaxMinificationLevel = TEXTURE_FILTER_MIN_TRILINEAR;
}