void DefaultPointHandleRenderer::render(Vbo& vbo, RenderContext& context) { const Vec4f::List& positionList = positions(); if (positionList.empty()) return; SetVboState activateVbo(vbo, Vbo::VboActive); if (m_vertexArray == NULL) { Vec3f::List vertices = sphere(); unsigned int vertexCount = static_cast<unsigned int>(vertices.size()); m_vertexArray = new VertexArray(vbo, GL_TRIANGLES, vertexCount, Attribute::position3f()); SetVboState mapVbo(vbo, Vbo::VboMapped); Vec3f::List::const_iterator vIt, vEnd; for (vIt = vertices.begin(), vEnd = vertices.end(); vIt != vEnd; ++vIt) { const Vec3f& vertex = *vIt; m_vertexArray->addAttribute(vertex); } } Renderer::ActivateShader shader(context.shaderManager(), Renderer::Shaders::PointHandleShader); shader.currentShader().setUniformVariable("Color", color()); shader.currentShader().setUniformVariable("CameraPosition", context.camera().position()); shader.currentShader().setUniformVariable("ScalingFactor", scalingFactor()); shader.currentShader().setUniformVariable("MaximumDistance", maximumDistance()); Vec4f::List::const_iterator pIt, pEnd; for (pIt = positionList.begin(), pEnd = positionList.end(); pIt != pEnd; ++pIt) { const Vec4f& position = *pIt; shader.currentShader().setUniformVariable("Position", position); m_vertexArray->render(); } }
// Private Method(s) // Setup Tiles void Puzzle::setupTiles() { int tilesSquared = static_cast<int>(sqrt(mTiles.size())); int curCol = 0, curRow = 0; sf::FloatRect outlineRect = mGrid.getOutlineRect(); sf::Vector2f tileRect(outlineRect.width / tilesSquared, outlineRect.height / tilesSquared); sf::Vector2f textureSize(mTexture.getSize()); sf::Vector2f textureRect(textureSize.x / tilesSquared, textureSize.y / tilesSquared); sf::Vector2f scalingFactor(tileRect.x / textureRect.x, tileRect.y / textureRect.y); for (unsigned i = 0; i < mTiles.size(); i++) { mTiles[i].first->setTextureRect(static_cast<sf::IntRect> (sf::FloatRect(curCol * textureRect.x, curRow * textureRect.y, textureRect.x, textureRect.y))); mTiles[i].first->setTexture(mTexture); mTiles[i].first->scale(scalingFactor); mTiles[i].first->setPosition(mGrid.getTilePos(i)); curCol++; if (curCol % tilesSquared == 0) { curRow++; curCol = 0; } } }
QRectF ScreenSetup::transformedRect(QRectF const& _rect) const { auto _zoom = scalingFactor(); /// Transformed desktop rect auto _desktopRect = transformedRect(); return QRectF( _desktopRect.x() + _rect.x() * _zoom, _desktopRect.y() + _rect.y() * _zoom, _rect.width() * _zoom, _rect.height() * _zoom); }
void AbstractGeneratorConfig::computeLinearScalePartitioning(const string& key) { I64u cardinality = static_cast<I64u>(scalingFactor() * getInt("partitioning." + key + ".base-cardinality")); double chunkSize = cardinality / static_cast<double> (numberOfChunks()); I64u genIDBegin = static_cast<ID> ((chunkSize * nodeID()) + 0.5); I64u genIDEnd = static_cast<ID> ((chunkSize * (nodeID() + 1) + 0.5)); setString("generator." + key + ".sequence.base_cardinality", getString("partitioning." + key + ".base-cardinality")); setString("generator." + key + ".sequence.cardinality", toString(cardinality)); setString("generator." + key + ".partition.begin", toString(genIDBegin)); setString("generator." + key + ".partition.end", toString(genIDEnd)); }
QRectF ScreenSetup::transformedRect() const { auto _windowRect = this->rect(); auto _zoom = scalingFactor(); QRect _desktopRect = omni::proj::ScreenSetup::desktopRect(); return QRectF( 0.5*(_windowRect.width() - _zoom * (_desktopRect.width())), 0.5*(_windowRect.height() - _zoom * (_desktopRect.height())), _zoom * _desktopRect.width(), _zoom * _desktopRect.height()); }
void QFontEngineQPF::doKerning(int num_glyphs, QGlyphLayout *g, QTextEngine::ShaperFlags flags) const { if (!kerning_pairs_loaded) { kerning_pairs_loaded = true; if (freetype) { lockFace(); if (freetype->face->size->metrics.x_ppem != 0) { QFixed scalingFactor(freetype->face->units_per_EM/freetype->face->size->metrics.x_ppem); unlockFace(); const_cast<QFontEngineQPF *>(this)->loadKerningPairs(scalingFactor); } else { unlockFace(); } } } QFontEngine::doKerning(num_glyphs, g, flags); }
void InstancedPointHandleRenderer::render(Vbo& vbo, RenderContext& context) { SetVboState activateVbo(vbo, Vbo::VboActive); if (!valid()) { delete m_vertexArray; m_vertexArray = NULL; const Vec4f::List& positionList = positions(); if (!positionList.empty()) { Vec3f::List vertices = sphere(); unsigned int vertexCount = static_cast<unsigned int>(vertices.size()); unsigned int instanceCount = static_cast<unsigned int>(positionList.size()); m_vertexArray = new InstancedVertexArray(vbo, GL_TRIANGLES, vertexCount, instanceCount, Attribute::position3f()); SetVboState mapVbo(vbo, Vbo::VboMapped); Vec3f::List::iterator it, end; for (it = vertices.begin(), end = vertices.end(); it != end; ++it) m_vertexArray->addAttribute(*it); m_vertexArray->addAttributeArray("position", positionList); } validate(); } if (m_vertexArray != NULL) { Renderer::ActivateShader shader(context.shaderManager(), Renderer::Shaders::InstancedPointHandleShader); shader.currentShader().setUniformVariable("Color", color()); shader.currentShader().setUniformVariable("CameraPosition", context.camera().position()); shader.currentShader().setUniformVariable("ScalingFactor", scalingFactor()); shader.currentShader().setUniformVariable("MaximumDistance", maximumDistance()); m_vertexArray->render(shader.currentShader()); } }