QgsRectangle QgsMapSettings::computeExtentForScale( const QgsPointXY &point, double scale, const QgsCoordinateReferenceSystem &sourceCrs ) const { QgsPointXY center = QgsCoordinateTransform( sourceCrs, destinationCrs(), mTransformContext ).transform( point ); // Output width in inches double outWIn = outputSize().width() / double( outputDpi() ); // Desired visible width (honouring scale) double scaledWIn = outWIn * scale; if ( mapUnits() == QgsUnitTypes::DistanceDegrees ) { // Start with an 1x1 extent around the center QgsRectangle ext( center.x() - 0.5, center.y() - 0.5, center.x() + 0.5, center.y() + 0.5 ); // Get scale at extent, and then scale extent to the desired scale double testScale = mScaleCalculator.calculate( ext, outputSize().width() ); ext.scale( scale / testScale ); return ext; } // Conversion from inches to mapUnits double conversionFactor = 12 * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::DistanceFeet, mapUnits() ); double delta = 0.5 * scaledWIn * conversionFactor; return QgsRectangle( center.x() - delta, center.y() - delta, center.x() + delta, center.y() + delta ); }
void MKLDNNConvLayer::reshape( int& bs, int& ic, int& ih, int& iw, int& oc, int& oh, int& ow) { reshapeInput(bs, ih, iw); // cal output sizes // oc can not be changed int fh = (fh_ - 1) * dh_ + 1; int fw = (fw_ - 1) * dw_ + 1; oh = outputSize(ih, fh, ph_, sh_, caffeMode_); ow = outputSize(iw, fw, pw_, sw_, caffeMode_); reshapeOutput(oh, ow); resizeOutput(bs, oc * oh * ow); }
size_t ConvBaseLayer::calOutputSize() { auto clearAndReserve = [this](IntV* vec) { vec->clear(); vec->reserve(this->inputLayers_.size()); }; clearAndReserve(&imgSizeH_); clearAndReserve(&imgSizeW_); clearAndReserve(&outputH_); clearAndReserve(&outputW_); size_t layerSize = 0; auto setLayerSize = [&](IntV& inH, IntV& inW, IntV& outH, IntV& outW) { size_t filterSizeY; size_t filterSize; for (size_t i = 0; i < inputLayers_.size(); i++) { filterSizeY = (filterSizeY_[i] - 1) * dilationY_[i] + 1; filterSize = (filterSize_[i] - 1) * dilation_[i] + 1; inH.push_back(inputLayers_[i]->getOutput().getFrameHeight()); inW.push_back(inputLayers_[i]->getOutput().getFrameWidth()); const ConvConfig& conf = config_.inputs(i).conv_conf(); if (isDeconv_) { if (inH[i] == 0) inH[i] = conf.has_output_y() ? conf.output_y() : conf.output_x(); if (inW[i] == 0) inW[i] = conf.output_x(); outH.push_back(imageSize( inH[i], filterSizeY, paddingY_[i], strideY_[i], caffeMode_)); outW.push_back( imageSize(inW[i], filterSize, padding_[i], stride_[i], caffeMode_)); } else { if (inH[i] == 0) inH[i] = conf.has_img_size_y() ? conf.img_size_y() : conf.img_size(); if (inW[i] == 0) inW[i] = conf.img_size(); outH.push_back(outputSize( inH[i], filterSizeY, paddingY_[i], strideY_[i], caffeMode_)); outW.push_back(outputSize( inW[i], filterSize, padding_[i], stride_[i], caffeMode_)); } CHECK_EQ(outH[i], outH[0]); CHECK_EQ(outW[i], outW[0]); } getOutput().setFrameHeight(outH[0]); getOutput().setFrameWidth(outW[0]); layerSize = outH[0] * outW[0] * size_t(numFilters_); }; setLayerSize(imgSizeH_, imgSizeW_, outputH_, outputW_); return layerSize; }
void MKLDNNPoolLayer::reshape( int& bs, int& ic, int& ih, int& iw, int& oc, int& oh, int& ow) { reshapeInput(bs, ih, iw); // ic_ and oc can not be changed CHECK_EQ((size_t)ic, inputLayers_[0]->getOutputValue()->getElementCnt() / bs / ih / iw) << "Input channel can not be changed"; // cal output sizes // paddle used false caffeMode for pooling oh = outputSize(ih, fh_, ph_, sh_, false); ow = outputSize(iw, fw_, pw_, sw_, false); reshapeOutput(oh, ow); resizeOutput(bs, oc * oh * ow); }
vec3 ewol::compositing::Text::calculateSizeChar(const char32_t& _charcode) { // get a pointer on the glyph property : ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode); int32_t fontHeigh = getHeight(); if (myGlyph == nullptr) { if (m_font == nullptr) { EWOL_WARNING("no Glyph... in no font"); } else { EWOL_WARNING("no Glyph... in font : " << m_font->getName()); } return vec3((float)(0.2), (float)(fontHeigh), (float)(0.0)); } // get the kerning ofset : float kerningOffset = 0.0; if (m_kerning == true) { kerningOffset = myGlyph->kerningGet(m_previousCharcode); } vec3 outputSize((float)(myGlyph->m_advance.x() + kerningOffset), (float)(fontHeigh), (float)(0.0)); // Register the previous character m_previousCharcode = _charcode; return outputSize; }
void VolumeRaycasterCL::setKernelArguments() { outputOffset(outputOffset_); outputSize(outputSize_); samplingRate(samplingRate()); setLightingProperties(light_.shadingMode, light_.position.xyz(), light_.ambientColor.xyz(), light_.diffuseColor.xyz(), light_.specularColor.xyz(), light_.specularExponent); }
QPolygonF QgsMapSettings::visiblePolygon() const { QPolygonF poly; const QSize& sz = outputSize(); const QgsMapToPixel& m2p = mapToPixel(); poly << m2p.toMapCoordinatesF( 0, 0 ).toQPointF(); poly << m2p.toMapCoordinatesF( sz.width(), 0 ).toQPointF(); poly << m2p.toMapCoordinatesF( sz.width(), sz.height() ).toQPointF(); poly << m2p.toMapCoordinatesF( 0, sz.height() ).toQPointF(); return poly; }
QPolygonF QgsMapSettings::visiblePolygon() const { QPolygonF poly; const QSize &sz = outputSize(); const QgsMapToPixel &m2p = mapToPixel(); poly << m2p.toMapCoordinates( 0.0, 0.0 ).toQPointF(); poly << m2p.toMapCoordinates( static_cast<double>( sz.width() ), 0.0 ).toQPointF(); poly << m2p.toMapCoordinates( static_cast<double>( sz.width() ), static_cast<double>( sz.height() ) ).toQPointF(); poly << m2p.toMapCoordinates( 0.0, static_cast<double>( sz.height() ) ).toQPointF(); return poly; }
size_t ConvProjection::calOutputSize() { imageH_ = in_->getFrameHeight(); imageW_ = in_->getFrameWidth(); if (imageH_ == 0) imageH_ = configImgH_; if (imageW_ == 0) imageW_ = configImgW_; outputH_ = outputSize(imageH_, filterH_, paddingH_, strideH_, /* caffeMode */ true); outputW_ = outputSize(imageW_, filterW_, paddingW_, strideW_, /* caffeMode */ true); const_cast<Argument *>(out_)->setFrameHeight(outputH_); const_cast<Argument *>(out_)->setFrameWidth(outputW_); inputOffset_ = (configChannels_ / groups_) * imageH_ * imageW_; outputOffset_ = (configNumFilters_ / groups_) * outputH_ * outputW_; return outputH_ * outputW_ * configNumFilters_; }
float NN_File::trainSet(TiXmlElement * pSet) { std::vector<float> input(inputSize()); std::vector<float> out(outputSize()); //Get input and output from Set TiXmlElement * pInput = pSet->FirstChildElement("i"); for(int i=0; i<inputSize(); i++) { input[i] = atof(pInput->GetText()); pInput = pInput->NextSiblingElement("i"); } TiXmlElement * pOutput = pSet->FirstChildElement("o"); for(int i=0; i<outputSize(); i++) { out[i] = atof(pOutput->GetText()); pOutput = pOutput->NextSiblingElement("o"); } //Train the network. Returns the error. return NeuralNetwork::train(input, out); }
void QgsMapSettings::updateDerived() { QgsRectangle extent = mExtent; if ( extent.isEmpty() || !extent.isFinite() ) { mValid = false; return; } // Don't allow zooms where the current extent is so small that it // can't be accurately represented using a double (which is what // currentExtent uses). Excluding 0 avoids a divide by zero and an // infinite loop when rendering to a new canvas. Excluding extents // greater than 1 avoids doing unnecessary calculations. // The scheme is to compare the width against the mean x coordinate // (and height against mean y coordinate) and only allow zooms where // the ratio indicates that there is more than about 12 significant // figures (there are about 16 significant figures in a double). if ( extent.width() > 0 && extent.height() > 0 && extent.width() < 1 && extent.height() < 1 ) { // Use abs() on the extent to avoid the case where the extent is // symmetrical about 0. double xMean = ( qAbs( extent.xMinimum() ) + qAbs( extent.xMaximum() ) ) * 0.5; double yMean = ( qAbs( extent.yMinimum() ) + qAbs( extent.yMaximum() ) ) * 0.5; double xRange = extent.width() / xMean; double yRange = extent.height() / yMean; static const double minProportion = 1e-12; if ( xRange < minProportion || yRange < minProportion ) { mValid = false; return; } } double myHeight = mSize.height(); double myWidth = mSize.width(); if ( !myWidth || !myHeight ) { mValid = false; return; } // calculate the translation and scaling parameters double mapUnitsPerPixelY = mExtent.height() / myHeight; double mapUnitsPerPixelX = mExtent.width() / myWidth; mMapUnitsPerPixel = mapUnitsPerPixelY > mapUnitsPerPixelX ? mapUnitsPerPixelY : mapUnitsPerPixelX; // calculate the actual extent of the mapCanvas double dxmin = mExtent.xMinimum(), dxmax = mExtent.xMaximum(), dymin = mExtent.yMinimum(), dymax = mExtent.yMaximum(), whitespace; if ( mapUnitsPerPixelY > mapUnitsPerPixelX ) { whitespace = (( myWidth * mMapUnitsPerPixel ) - mExtent.width() ) * 0.5; dxmin -= whitespace; dxmax += whitespace; } else { whitespace = (( myHeight * mMapUnitsPerPixel ) - mExtent.height() ) * 0.5; dymin -= whitespace; dymax += whitespace; } mVisibleExtent.set( dxmin, dymin, dxmax, dymax ); // update the scale mScaleCalculator.setDpi( mDpi ); mScale = mScaleCalculator.calculate( mVisibleExtent, mSize.width() ); mMapToPixel.setParameters( mapUnitsPerPixel(), visibleExtent().center().x(), visibleExtent().center().y(), outputSize().width(), outputSize().height(), mRotation ); #if 1 // set visible extent taking rotation in consideration if ( mRotation ) { QgsPoint p1 = mMapToPixel.toMapCoordinates( QPoint( 0, 0 ) ); QgsPoint p2 = mMapToPixel.toMapCoordinates( QPoint( 0, myHeight ) ); QgsPoint p3 = mMapToPixel.toMapCoordinates( QPoint( myWidth, 0 ) ); QgsPoint p4 = mMapToPixel.toMapCoordinates( QPoint( myWidth, myHeight ) ); dxmin = std::min( p1.x(), std::min( p2.x(), std::min( p3.x(), p4.x() ) ) ); dymin = std::min( p1.y(), std::min( p2.y(), std::min( p3.y(), p4.y() ) ) ); dxmax = std::max( p1.x(), std::max( p2.x(), std::max( p3.x(), p4.x() ) ) ); dymax = std::max( p1.y(), std::max( p2.y(), std::max( p3.y(), p4.y() ) ) ); mVisibleExtent.set( dxmin, dymin, dxmax, dymax ); } #endif QgsDebugMsg( QString( "Map units per pixel (x,y) : %1, %2" ).arg( qgsDoubleToString( mapUnitsPerPixelX ), qgsDoubleToString( mapUnitsPerPixelY ) ) ); QgsDebugMsg( QString( "Pixmap dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( mSize.width() ), qgsDoubleToString( mSize.height() ) ) ); QgsDebugMsg( QString( "Extent dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( mExtent.width() ), qgsDoubleToString( mExtent.height() ) ) ); QgsDebugMsg( mExtent.toString() ); QgsDebugMsg( QString( "Adjusted map units per pixel (x,y) : %1, %2" ).arg( qgsDoubleToString( mVisibleExtent.width() / myWidth ), qgsDoubleToString( mVisibleExtent.height() / myHeight ) ) ); QgsDebugMsg( QString( "Recalced pixmap dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( mVisibleExtent.width() / mMapUnitsPerPixel ), qgsDoubleToString( mVisibleExtent.height() / mMapUnitsPerPixel ) ) ); QgsDebugMsg( QString( "Scale (assuming meters as map units) = 1:%1" ).arg( qgsDoubleToString( mScale ) ) ); QgsDebugMsg( QString( "Rotation: %1 degrees" ).arg( mRotation ) ); mValid = true; }
double QgsMapSettings::computeScaleForExtent( const QgsRectangle &extent ) const { return mScaleCalculator.calculate( extent, outputSize().width() ); }
////////////////////////////////////////////////////////////////////////////// // // void ExportGraphicComponent( RComponentView* pComponentView, RMBCString *pInitialDir ) // // export a graphic to file from a component view // ////////////////////////////////////////////////////////////////////////////// void ExportGraphicComponent( RComponentView* pComponentView, RMBCString *pInitialDir /*=NULL*/) { RImageLibrary rLibrary ; CArray<int, int> arrFileFormats ; // // Build the export file filter list... // CString strFilter, str ; for (int i = 0; i < kNumFormats - 1; i++) { if (rLibrary.IsFormatSupported( (EImageFormat) kImageExportFilters[i][0] )) { str.LoadString( kImageExportFilters[i][1] ) ; strFilter += str ; arrFileFormats.Add( kImageExportFilters[i][0] ) ; } } TpsAssert( kImageExportFilters[i][0] == kImageFormatXRX, "Invalid export format!" ) ; str.LoadString( kImageExportFilters[i][1] ) ; strFilter += str ; strFilter += "|" ; arrFileFormats.Add( kImageExportFilters[i][0] ) ; // // Create and execute the dialog... // RExportGraphicDlg dlg( pComponentView, strFilter ) ; // Load in the dialog title string CString strTitle ; strTitle.LoadString( STRING_EXPORT_IMAGE_DIALOG_TITLE ) ; dlg.m_ofn.lpstrTitle = (LPCTSTR) strTitle ; if( pInitialDir ) { dlg.m_ofn.lpstrInitialDir = (LPCTSTR)*pInitialDir; } if (IDOK == dlg.DoModal()) { RMBCString strPathName = dlg.GetPathName() ; RIntSize szImageSize = dlg.GetSize() ; _nFilterIndex = dlg.m_ofn.nFilterIndex ; EImageFormat eFormat = (EImageFormat) arrFileFormats[dlg.m_ofn.nFilterIndex - 1] ; RRealSize pictureSize = pComponentView->GetReferenceSize() ; try { if (kImageFormatXRX == eFormat) { RRealSize outputSize( szImageSize.m_dx, szImageSize.m_dy ) ; // = pictureSize ; RRealSize screenDPI = ::GetScreenDPI() ; RVectorImage vectorImage ; vectorImage.SetSuggestedWidthInInches( ::PixelsToInches( outputSize.m_dx, (uLONG) screenDPI.m_dx ) ) ; vectorImage.SetSuggestedHeightInInches( ::PixelsToInches( outputSize.m_dy, (uLONG) screenDPI.m_dy ) ) ; // Create an offscreen drawing surface and set the picture ROffscreenDrawingSurface drawingSurface; drawingSurface.SetImage( &vectorImage ); R2dTransform transform ; // Scale to the device DPI RRealSize deviceDPI = drawingSurface.GetDPI( ); transform.PreScale( (YFloatType) deviceDPI.m_dx / screenDPI.m_dy, (YFloatType) deviceDPI.m_dy / screenDPI.m_dy ); transform.PreScale( outputSize.m_dx / pictureSize.m_dx, outputSize.m_dy / pictureSize.m_dy ) ; // Render the component RRealRect outputRect( pictureSize ) ; pComponentView->Render( drawingSurface, transform, outputRect ) ; drawingSurface.ReleaseImage( ); rLibrary.ExportImage( vectorImage, strPathName, kImageFormatXRX ) ; if (rLibrary.GetLastException() != kNoError) { throw rLibrary.GetLastException() ; } } // if (XRX) else { // Check for a image interface RImageInterface* pInterface = (RImageInterface *) pComponentView->GetInterface( kImageInterfaceId ) ; if (pInterface) { pInterface->Export( strPathName, eFormat ) ; delete pInterface ; } else { // Initialize the new bitmap at a bit depth of 24 RBitmapImage image ; image.Initialize( szImageSize.m_dx, szImageSize.m_dy, 24 ) ; ROffscreenDrawingSurface dsMem ; dsMem.SetImage( &image ) ; R2dTransform transform ; transform.PreScale( szImageSize.m_dx / pictureSize.m_dx, szImageSize.m_dy / pictureSize.m_dy ) ; // Render the component dsMem.SetFillColor( RSolidColor( kWhite ) ) ; dsMem.FillRectangle( RRealRect( pictureSize ), transform ) ; pComponentView->Render( dsMem, transform, RIntRect( RIntSize( pictureSize.m_dx, pictureSize.m_dy ) ) ) ; dsMem.ReleaseImage() ; rLibrary.ExportImage( image, strPathName, eFormat ) ; } if (rLibrary.GetLastException() != kNoError) { throw rLibrary.GetLastException() ; } } // else } // try catch( YException e) { ReportException( e ) ; } } // if (IDOK) }
//Searching for nearest clauses Output* Database::search(Output* goal){ int K = goal->getSize(); //number of K-nearest neighbor that we are looking at, should be equal to #clauses at least /* std::vector<Object*> neighbors; std::vector<double> distances; outputVPTree->search(goal, 100, &neighbors, &distances); int minimumDistance = INT_MAX; Output* result = (Output*)neighbors[0]; for(int i=0;i< neighbors.size();i++){ Output* current = (Output*)neighbors[i]; if(!current->getMask()){ if( current->getDistanceFactor()*goal->distance(current) < minimumDistance ){ minimumDistance=current->getDistanceFactor()*goal->distance(current); result = current; } } } result->miss(); if(result->getMask()){ cout << "Woah! The search space is empty, we should restart the urbana" << endl ; } return result; */ if(enableMVP==0){ int minimumDistance = INT_MAX; Output* result = getOutput(0); for(int i=0;i< outputSize();i++){ if(!getOutput(i)->getMask()){ if( getOutput(i)->getDistanceFactor()*goal->distance(getOutput(i)) < minimumDistance ){ minimumDistance=getOutput(i)->getDistanceFactor()*goal->distance(getOutput(i)); result = getOutput(i); } } } result->miss(); if(result->getMask()){ cout << "Woah! The search space is empty, we should restart the urbana" << endl ; } return result; } //todo: find optimum K, how much trouble will I get into if I don't set K to #clauses? //in case that we have less than K output in the database if(outputSize()<=K){ //perform linear search int minimumDistance = INT_MAX; Output* result = getOutput(0); for(int i=0;i< outputSize();i++){ if(!getOutput(i)->getMask()){ if( getOutput(i)->getDistanceFactor()*goal->distance(getOutput(i)) < minimumDistance ){ minimumDistance= getOutput(i)->getDistanceFactor()*goal->distance(getOutput(i)); result = getOutput(i); } } } result->miss(); if(result->getMask()){ cout << "Woah! The search space is empty, we should restart the urbana" << endl ; } return result; } float radius = 1; mvp::MVPError err; unsigned int nbresults=0; mvp::MVPDP **results; while(nbresults<K){ //gradually increase radius until we find at least K nearest neighbors //Clean-up if(results!=0) delete results; //Create a new MVP-node mvp::MVPDP* node = new mvp::MVPDP(); node->datalen = goal->getSize(); node->data = goal; char scratch[32]; snprintf(scratch, 32, "point%llu", goal->getID()); node->id = strdup(scratch); //search the mvp for K nearest neighbor within radius (the actual number of neaerest neighbor might be more than just K) results = mvp::mvptree_retrieve(outputVPT, node, K, radius, &nbresults, &err); radius*=5; //todo: find the optimum variable, how sensitive are we on thing thing? } //The MVP is going to nag becuase there are usually more than just K nearest neighbor in the radius we are searching //if(err != mvp::MVP_SUCCESS){ // cout << "[error] db::mvp " << mvp::mvp_errstr( err ) << endl; //} //Finally, choose the suitable candidate among those N nodes int minimumDistance = INT_MAX; Output* result = ((Output*)(results[0]->data)); for (int i=1;i<nbresults;i++){ Output* current = (Output*)(results[i]->data); double currentDistance=goal->distance(current); if(!current->getMask()){ if( current->getDistanceFactor()*currentDistance < minimumDistance ){ minimumDistance=current->getDistanceFactor()*currentDistance; result = current; } } } result->miss(); if(result->getMask()){ cout << "Woah! The search space is empty, we should restart the urbana" << endl ; } return result; }
fwData::Image::sptr Resampler::resample(const fwData::Image::csptr& _img, const ::fwData::TransformationMatrix3D::csptr& _trf, const ::fwData::Image::SpacingType& _outputSpacing) { using PointType = ::itk::Point<double, 3>; using VectorContainerType = ::itk::VectorContainer<int, PointType>; using BoundingBoxType = ::itk::BoundingBox<int, 3, double, VectorContainerType>; const auto& inputSize = _img->getSize(); const auto& inputOrigin = _img->getOrigin(); const auto& inputSpacing = _img->getSpacing(); SLM_ASSERT("Image dimension must be 3.", inputOrigin.size() == 3 && inputSpacing.size() == 3 && inputSize.size() == 3); typename BoundingBoxType::Pointer inputBB = BoundingBoxType::New(); const PointType min(inputOrigin.data()); PointType max; for(std::uint8_t i = 0; i < 3; ++i) { max[i] = inputOrigin[i] + static_cast<double>(inputSize[i]) * inputSpacing[i]; } inputBB->SetMinimum(min); inputBB->SetMaximum(max); const auto inputCorners = inputBB->GetCorners(); const ::itk::Matrix<double, 4, 4> matrix(::fwItkIO::helper::Transform::convertToITK(_trf).GetInverse()); // Apply transform matrix to all bounding box corners. typename VectorContainerType::Pointer outputCorners = VectorContainerType::New(); outputCorners->Reserve(inputCorners->Size()); std::transform(inputCorners->begin(), inputCorners->end(), outputCorners->begin(), [&matrix](const PointType& _in) { // Convert input to homogeneous coordinates. const ::itk::Point<double, 4> input(std::array<double, 4>({{_in[0], _in[1], _in[2], 1.}}).data()); const auto p = matrix * input; return PointType(p.GetDataPointer()); }); // Compute the transformed axis aligned bounding box. typename BoundingBoxType::Pointer outputBB = BoundingBoxType::New(); outputBB->SetPoints(outputCorners); outputBB->ComputeBoundingBox(); // Compute output size and origin. ::fwData::Image::sptr output = ::fwData::Image::New(); ::fwData::Image::OriginType outputOrigin(3); ::fwData::Image::SizeType outputSize(3); for(std::uint8_t i = 0; i < 3; ++i) { outputOrigin[i] = outputBB->GetMinimum()[i]; outputSize[i] = size_t((outputBB->GetMaximum()[i] - outputOrigin[i]) / _outputSpacing[i]); } output->setSize(outputSize); output->setSpacing(_outputSpacing); output->setOrigin(outputOrigin); resample(_img, output, _trf, output); return output; }
QSize QgsMapSettings::deviceOutputSize() const { return outputSize() * mDevicePixelRatio; }
//opt_sharpness [0...2] default 1.0f //opt_edge_strength [0...1] default 0.6f void XunoGLSLFilter::superscale(GLfloat opt_sharpness, GLfloat opt_edge_strength) { if ( geometries==Q_NULLPTR) geometries = new GeometryEngine; QOpenGLFunctions *f=opengl()->openGLContext()->functions(); if (!f) return; //if (initSize.isEmpty()){ initSize=outputSize(); //} //qDebug()<<"superscale" << initSize; //setOutputSize(initSize*2); //qDebug()<<"superscale x2" << outputSize(); //initTextures(); frame++; // Enable depth buffer f->glEnable(GL_DEPTH_TEST); // Enable back face culling // QtAV move freeze with it. //f->glEnable(GL_CULL_FACE); //--------------------------------------------- //GLuint fbotextid=texture->textureId(); GLuint fbotextid=fbo()->texture(); //used last fbo of player as source frame //qDebug()<<"Texture id start"<<fbotextid<<"texure size:"<<texture->width()<<"x"<<texture->height(); for (pass=0;pass<=maxPass;pass++){ bool rotate=false;//(pass>0); //qDebug()<<"Programs:"<< addProgram(); if (initShaders_xbr(pass) && !scales.isEmpty()){ int fboID=addFBO(scales.at(pass),/*rotate*/0); QOpenGLShaderProgram *program=Q_NULLPTR; if (pass<=programs.size()){ program=programs.at(pass); } m_fbo[fboID]->bind(); f->glViewport(0,0,m_fbo[fboID]->width(),m_fbo[fboID]->height()); // Use texture unit 0 which contains cube.png program->bind(); //qDebug()<<"texture0 is"; program->setUniformValue("texture0", 0); QVector2D textureSize=QVector2D (float(m_fbo[fboID]->width()),float(m_fbo[fboID]->height())); //qDebug()<<"texture_size0 is"; program->setUniformValue("texture_size0", textureSize); //qDebug()<<"pixel_size0 is"; program->setUniformValue("pixel_size0", QVector2D(1.0f,1.0f)/textureSize); //qDebug()<<"texture_rot0 is"; program->setUniformValue("texture_rot0", QVector2D(0.0f,0.0f)); //options program->setUniformValue("sharpness", opt_sharpness); // [0...2] default 1.0f program->setUniformValue("edge_strength",opt_edge_strength); // [0...1] default 0.6f QMatrix4x4 matrix; matrix.setToIdentity(); if (rotate) { int sign=(pass==2)?-1:1; matrix.rotate(180*sign,0.,0.,1.); } program->setUniformValue("MVPMatrix", matrix); //if (1) { //if (0){ //pass==0 // f->glActiveTexture(GL_TEXTURE0); // texture->bind(); //}else{ f->glActiveTexture(GL_TEXTURE0); f->glBindTexture(GL_TEXTURE_2D, fbotextid); f->glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);//GL_NEAREST GL_LINEAR f->glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); //f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);//GL_CLAMP_TO_EDGE //f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); //} f->glClearColor(1.0,0.0,0.0,1.0);//RED f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw cube geometry geometries->drawCubeGeometry(program); // if (0){//pass==0 // texture->release(); // }else{ f->glBindTexture(GL_TEXTURE_2D, 0); // } // } program->release(); m_fbo[fboID]->release(); #if (unix) // QString filename=QString("/home/lex/temp/savefbo_pass_%1_%2x%3-%4.bmp").arg(pass).arg(m_fbo[fboID]->width()).arg(m_fbo[fboID]->height()).arg(frame); #else // QString filename=QString("e:/temp/shader/savefbo_pass_%1_%2x%3-%4.bmp").arg(pass).arg(m_fbo[fboID]->width()).arg(m_fbo[fboID]->height()).arg(frame); #endif // qDebug()<<"Saving:"<<filename; // m_fbo[fboID]->toImage(false).save(filename); fbotextid=m_fbo[fboID]->texture(); //qDebug()<<"Texture id"<<fbotextid<<"texure size:"<<m_fbo[fboID]->width()<<"x"<<m_fbo[fboID]->height(); }else{ qDebug()<<"initShaders error (pass)"<<pass; } } if (fbotextid) lastSuperscaleTexureId=fbotextid; }