예제 #1
0
void VideoProgress::onLoadResource() {
  const size_t numRes = sp.size();
  if (sp[resourceLoadIndex].bind == ShaderParameter::BindTextureSampler) {
    QImage image = QImage(sp[resourceLoadIndex].texture.c_str());
    renderSurface->addTexture(sp[resourceLoadIndex].name, image);
  }
  if (++resourceLoadIndex == numRes) {
    bar->setValue(0);
    onNextFrame();
  } else {
    bar->setValue(resourceLoadIndex/float(numRes)*100);
    QTimer::singleShot(0, this, SLOT(onLoadResource()));
  }
}
예제 #2
0
        //************************************
        // Method:    Load
        // FullName:  ResourceManager<T, deleter_type>::Load
        // Access:    public
        // Returns:   ptr_t
        // Parameter: const std::string & key
        //   Returns a reference to the resource associated with the file name 'key' if it exists in memory.
        //   Otherwise it loads the texture into memory, and returns a reference to the the resource.
        //************************************
        T &Load(const std::string &key)
        {
            map_i i = m_map.find(key);
            if(i != m_map.end())
                return *i->second.get(); //return resource if exists

            //else, load resource
            ptr_t p(onLoadResource(key));
            if(p.get() == NULL)
                throw Exception("Error loading Image at " + key); //figure out better way to throw exceptions later

            m_map.insert(std::make_pair(key, std::move(p)));
            return *m_map[key].get();
        }
예제 #3
0
VideoProgress::VideoProgress(const VideoParameters& videoParameters,  const ShaderParameters& shaderParameters, QWidget* parent) : QWidget(parent), vp(videoParameters), sp(shaderParameters), renderSurface(0) {
  setWindowTitle("Export");

  QWidget* central = this;//new QWidget(this);
  //setCentralWidget(central);
  QVBoxLayout* renderLayout = new QVBoxLayout(central);
  renderLayout->addStretch();

  frame = new QLabel(this);
  frame->setAlignment(Qt::AlignCenter);
  frame->setText("Loading...");

  renderLayout->addWidget(frame);
  renderLayout->addStretch();

  bar = new QProgressBar(this);
  renderLayout->addWidget(bar);

  //renderLayout->addStretch();
  QHBoxLayout* hlayout = new QHBoxLayout(this);
  renderLayout->addLayout(hlayout);
  button = new QPushButton("Cancel", this);
  connect(button, SIGNAL(pressed()), this, SLOT(onFinalPress()));
  hlayout->addStretch();
  hlayout->addWidget(button);
  //hlayout->addStretch();

  finalFrame = false;
  captureDone = false;
  renderSurface = new RenderSurface(vp.width, vp.height);
  if (!renderSurface->setShaderCode(vp.code)) {
    finishCapture("An error occured during capture: Shader error:\n\n" + renderSurface->getShaderError());
    return;
  }

  renderSurface->setShaderParameters(sp);
  encoder = new VideoEncoder(vp.path, vp.fps, vp.bitrate);
  frameCount = 0;
  durationSeconds = vp.duration;

  if (!sp.size()) {
    onNextFrame();
  } else { /* stuff to load */
    resourceLoadIndex = 0;
    onLoadResource();
  }
}
예제 #4
0
        //Returns a reference to the resource associated with the file name 'key' if it exists in memory.
        //Otherwise it loads the texture into memory, and returns a reference to the the resource.
        T &Load(key_type const &key) noexcept(false)
        {
            map_i i = m_map.find(key);
            if(i != m_map.end())
            {
                return *i->second.get(); //return resource if exists
            }

            //else, load resource
            ptr_t p {onLoadResource(key)};
            if(p.get() == NULL)
            {
                throw Exception(std::string("Error loading Image at ") + key);
            }

            m_map.insert(std::make_pair(key, std::move(p)));
            return *m_map[key].get();
        }