void ImageExporterResolutionWidget::resolutionValueChanged(int i)
{
    double value;
    bool old;
    if (m_ui->aspectCheckBox->isChecked())
    {
        if (m_widthState->type == pixelString)
        {
            value = pixelsTo(m_widthState->value, m_heightState->type);
            m_resolutionState->value = i;
            m_widthState->value = toPixels(value, m_heightState->type);

            old = m_ui->widthDoubleSpinBox->blockSignals(true);
            m_ui->widthDoubleSpinBox->setValue(std::round(m_widthState->value));
            m_ui->widthDoubleSpinBox->blockSignals(old);
        }
        else if (m_heightState->type == pixelString)
        {
            value = pixelsTo(m_heightState->value, m_widthState->type);
            m_resolutionState->value = i;
            m_heightState->value = toPixels(value, m_widthState->type);

            old = m_ui->heightDoubleSpinBox->blockSignals(true);
            m_ui->heightDoubleSpinBox->setValue(std::round(m_heightState->value));
            m_ui->heightDoubleSpinBox->blockSignals(old);
        }
    }
    else
        m_resolutionState->value = i;

    updateResolutionSummary();
}
示例#2
0
 inline void shoot()
 {
     assets.playSound("Sounds/spark.wav");
     Vec2i shootPos{
         body.getPosition() + getVecFromDir8<int>(direction) * 600};
     wpn.shoot(
         this, shootPos, getDegFromDir8(direction), toPixels(shootPos));
 }
void ImageExporterResolutionWidget::heightValueChanged(double d)
{
    if (m_ui->aspectCheckBox->isChecked())
    {
        double newValue{ toPixels(d, m_heightState->type) * toPixels(m_widthState->value, m_widthState->type) / toPixels(m_heightState->value, m_heightState->type) };
        m_widthState->value = pixelsTo(newValue, m_widthState->type);

        bool old = m_ui->widthDoubleSpinBox->blockSignals(true);
        if (m_widthState->type == pixelString)
            m_ui->widthDoubleSpinBox->setValue(std::round(m_widthState->value));
        else
            m_ui->widthDoubleSpinBox->setValue(m_widthState->value);
        m_ui->widthDoubleSpinBox->blockSignals(old);
    }

    m_heightState->value = d;

    updateResolutionSummary();
}
void ImageExporterResolutionWidget::updateResolutionSummary()
{
    // TODO: detect unsigned long long overflow
    int height{ static_cast<int>(std::round(toPixels(m_heightState->value, m_heightState->type))) };
    int width{ static_cast<int>(std::round(toPixels(m_widthState->value, m_widthState->type))) };
    emit resolutionChanged(QSize(width, height));

    unsigned long long pixelNumber{ static_cast<unsigned long long>(width) * static_cast<unsigned long long>(height) };
    QString unit;
    double byte;
    if (pixelNumber * 4 < 1024)
    {
        unit = "Byte";
        byte = static_cast<double>(pixelNumber) * 4;
    }
    else if (pixelNumber * 4 < static_cast<unsigned long long>(std::pow<int, int>(1024, 2)))
    {
        unit = "KiB";
        byte = static_cast<double>(pixelNumber) * 4 / 1024;
    }
    else if (pixelNumber * 4 < static_cast<unsigned long long>(std::pow<int, int>(1024, 3)))
    {
        unit = "MiB";
        byte = static_cast<double>(pixelNumber) * 4 / std::pow<int, int>(1024, 2);
    }
    else if (pixelNumber * 4 < static_cast<unsigned long long>(std::pow<int, int>(1024, 4)))
    {
        unit = "GiB";
        byte = static_cast<double>(pixelNumber) * 4 / std::pow<int, int>(1024, 3);
    }
    else //if (pixelNumber * 4 < static_cast<unsigned long long>(std::pow<int, int>(1024, 5)))
    {
        unit = "TiB";
        byte = static_cast<double>(pixelNumber) * 4 / std::pow<int, int>(1024, 4);
    }
    QString summary{ QString::number(pixelNumber) + " pixels (" + QString::number(std::round(byte * 100) / 100) + " " + unit + " uncompressed)" };
    //m_ui->resolutionSummaryLabel->setText(summary);
    emit resolutionSummaryChanged(summary);
}
示例#5
0
void DOFFilter::drawFullscreen() {
  mGlslProg->uniform("uRenderedTexture", 0);
  mGlslProg->uniform("uDepthTexture", 1);
  mGlslProg->uniform("uFocalDepth", mManualFocalDepth);
  mGlslProg->uniform("uMaxBlur", mMaxBlur * displayScale());
#ifdef ADVANCED_SHADER
  mGlslProg->uniform("uRenderedTextureWidth", (float)mSceneFBO->getWidth());
  mGlslProg->uniform("uRenderedTextureHeight", (float)mSceneFBO->getHeight());
  mGlslProg->uniform("uUseAutofocus", mUseAutofocus);
  mGlslProg->uniform("uAutofocusCenter", mAutofocusCenter);
  mGlslProg->uniform("uNumRings", mNumRings);
  mGlslProg->uniform("uNumSamples", mNumSamples);
  mGlslProg->uniform("uHighlightThreshold", mHighlightThreshold);
  mGlslProg->uniform("uHighlightGain", mHighlightGain);
  mGlslProg->uniform("uBokehEdgeBias", mBokehEdgeBias);
  mGlslProg->uniform("uBokehFringe", mBokehFringe);
  mGlslProg->uniform("uAperture", mAperture / displayScale());
#else
  mGlslProg->uniform("uAspectRatio", getWindowAspectRatio());
  mGlslProg->uniform("uAperture", mAperture / displayScale() / 15);
#endif

  gl::ScopedTextureBind tex0(mSceneFBO->getColorTexture(), 0);
  gl::ScopedTextureBind tex1(mSceneFBO->getDepthTexture(), 1);
  
  const gl::ScopedViewport scopedViewport(ivec2(0), toPixels(getWindowSize()));
  const gl::ScopedMatrices scopedMatrices;
  gl::setMatricesWindow(toPixels(getWindowSize()));
  gl::translate(toPixels(getWindowSize() / 2));
  gl::scale(toPixels(getWindowSize()));
  
  gl::disableDepthRead();
  gl::disableDepthWrite();

  gl::clear(Color::black());
  mQuadBatch->draw();
}
示例#6
0
void Window::DPIToWindowCoords(double *x, double *y) const
{
	double dpix = x != nullptr ? *x : 0.0;
	double dpiy = y != nullptr ? *y : 0.0;

	double px = 0.0;
	double py = 0.0;

	toPixels(dpix, dpiy, px, py);
	pixelToWindowCoords(&px, &py);

	if (x != nullptr)
		*x = px;
	if (y != nullptr)
		*y = py;
}
void ImageExporterResolutionWidget::heightUnitChanged(const QString& text)
{
    if (text == pixelString)
    {
        m_heightState->value = toPixels(m_heightState->value, m_heightState->type);

        if (m_ui->widthComboBox->currentText() == pixelString)
            enableResolution(false);
        
        setDecimals(m_ui->heightDoubleSpinBox, 0);
    }
    else if (text == inchString)
    {
        if (m_heightState->type == pixelString)
        {
            m_heightState->value = pixelsToInch(m_heightState->value);

            setDecimals(m_ui->heightDoubleSpinBox, 2);
            enableResolution(true);
        }
        else if (m_heightState->type == cmString)
            m_heightState->value = m_heightState->value * INCH_PER_CM;
    }
    else
    {
        if (m_heightState->type == pixelString)
        {
            m_heightState->value = pixelsToCm(m_heightState->value);
            
            setDecimals(m_ui->heightDoubleSpinBox, 2);
            enableResolution(true);
        }
        else if (m_heightState->type == inchString)
            m_heightState->value = m_heightState->value * CM_PER_INCH;
    }

    m_ui->heightDoubleSpinBox->setValue(m_heightState->value);
    m_heightState->type = text;
}
void SystemCinderApp::drawSimulator()
{
	gl::viewport(getWindowSize());
	gl::setMatricesWindow(getWindowSize());
	gl::clear(Color(0.0f, 0.0f, 0.2f));

	// for testing show the rendered scene to the FBO at the top left corner
	gl::setMatricesWindow(toPixels(getWindowSize()));
	gl::draw(mFbo->getColorTexture(), Rectf(0, 0, 129, 128));
	// also get the depth texture
	gl::draw(mFbo->getDepthTexture(), Rectf(129, 0, 256, 128));

	gl::setMatrices(mCamFbo);

	// If the Display type is not the real hardware sphere, we need to call simulator methods.
	if (mDisplayType != 3){
		mVirtualDisplay->setUpFboShouldBeMappedTexture(mFbo);
		mVirtualDisplay->createShaders();
		mVirtualDisplay->createDisplay();

		{
			mVirtualDisplay->mDisplay->draw();
		}

		mVirtualDisplay->createGrid();
		mVirtualDisplay->mGrid->draw();
		gl::drawCoordinateFrame(4);

		mVirtualDisplay->setUpProjectors();
		mVirtualDisplay->drawProjectors();

#if ! defined( CINDER_GL_ES )
		if (mVirtualDisplay->mParams)
			mVirtualDisplay->mParams->draw();
#endif

	}
}
示例#9
0
QPointF Box2DMouseJoint::target() const
{
    return toPixels(mMouseJointDef.target);
}
示例#10
0
 inline ssvs::Vec2f toPixels(const ssvs::Vec2<T>& mValue)
 {
     return {toPixels(mValue.x), toPixels(mValue.y)};
 }
示例#11
0
QPointF Box2DFrictionJoint::localAnchorB() const
{
    if (frictionJoint())
        return toPixels(frictionJoint()->GetAnchorB());
    return toPixels(mFrictionJointDef.localAnchorB);
}
示例#12
0
QPointF Box2DFrictionJoint::getReactionForce(float32 inv_dt) const
{
    if (frictionJoint())
        return toPixels(frictionJoint()->GetReactionForce(inv_dt));
    return QPointF();
}
示例#13
0
void DOFFilter::createBuffers(int samples) {
  mSceneFBO = gl::Fbo::create(toPixels(getWindowWidth()), toPixels(getWindowHeight()), gl::Fbo::Format().depthTexture().samples(samples));
}