本文整理汇总了C++中sf::RenderTexture::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderTexture::getSize方法的具体用法?C++ RenderTexture::getSize怎么用?C++ RenderTexture::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RenderTexture
的用法示例。
在下文中一共展示了RenderTexture::getSize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawRenderTexture
void GuiElement::drawRenderTexture(sf::RenderTexture& texture, sf::RenderTarget& window, sf::Color color, const sf::RenderStates& states)
{
texture.display();
sf::Sprite sprite(texture.getTexture());
sprite.setTextureRect(sf::IntRect(0, 0, texture.getSize().x * texture.getView().getViewport().width, texture.getSize().y * texture.getView().getViewport().height));
sprite.setColor(color);
sprite.setPosition(rect.left, rect.top);
sprite.setScale(rect.width / float(texture.getSize().x * texture.getView().getViewport().width), rect.height / float(texture.getSize().y * texture.getView().getViewport().height));
window.draw(sprite, states);
}
示例2: MakeTexture
void Layer::MakeTexture(sf::RenderTexture& textureImage) const {
if (WidthPixels == textureImage.getSize().x && HeightPixels == textureImage.getSize().y) { //layer is big enough to support creating a textured background from... if not, the texture will be left fully black
VertexVector vertices[NUMBEROFTILESETTEXTURES]; //don't reuse Layer::Vertices, in case this layer needs to get drawn soon
for (int x = 0; x < Width; ++x)
for (int y = 0; y < Height; ++y)
DrawTileToVertexArrays(vertices, x,y);
for (int i = 0; i < NUMBEROFTILESETTEXTURES; ++i)
if (!vertices[i].empty())
textureImage.draw(vertices[i].data(), vertices[i].size(), OpenGLPrimitive, LevelPtr->TilesetPtr->TileImages[i]);
}
textureImage.display();
}
示例3: downsample
void BloomEffect::downsample(const sf::RenderTexture& input, sf::RenderTexture& output)
{
sf::Shader& downSampler = mShaders.get(Shaders::DownSamplePass);
downSampler.setParameter("source", input.getTexture());
downSampler.setParameter("sourceSize", sf::Vector2f(input.getSize()));
applyShader(downSampler, output);
output.display();
}
示例4: downSample
void PostBloom::downSample(const sf::RenderTexture& src, sf::RenderTexture& dst)
{
auto& shader = m_shaderResource.get(Shader::DownSample);
shader.setUniform("u_sourceTexture", src.getTexture());
shader.setUniform("u_sourceSize", sf::Vector2f(src.getSize()));
applyShader(shader, dst);
dst.display();
}
示例5: apply
//public
void PostChromeAb::apply(const sf::RenderTexture& src, sf::RenderTarget& dst)
{
float windowRatio = static_cast<float>(dst.getSize().y) / static_cast<float>(src.getSize().y);
m_shader.setUniform("u_sourceTexture", src.getTexture());
m_shader.setUniform("u_time", accumulatedTime * (10.f * windowRatio));
m_shader.setUniform("u_lineCount", windowRatio * scanlineCount);
applyShader(m_shader, dst);
}
示例6: apply
//public
void PostChromeAb::apply(const sf::RenderTexture& src, sf::RenderTarget& dst)
{
float windowRatio = static_cast<float>(dst.getSize().y) / static_cast<float>(src.getSize().y);
auto& shader = m_shaderResource.get(Shader::Type::PostChromeAb);
shader.setParameter("u_sourceTexture", src.getTexture());
shader.setParameter("u_time", accumulatedTime * (10.f * windowRatio));
shader.setParameter("u_lineCount", windowRatio * scanlineCount);
applyShader(shader, dst);
}
示例7: apply
void BloomEffect::apply(const sf::RenderTexture& input, sf::RenderTarget& output)
{
prepareTextures(input.getSize());
filterBright(input, mBrightnessTexture);
downsample(mBrightnessTexture, mFirstPassTextures[0]);
blurMultipass(mFirstPassTextures);
downsample(mFirstPassTextures[0], mSecondPassTextures[0]);
blurMultipass(mSecondPassTextures);
add(mFirstPassTextures[0], mSecondPassTextures[0], mFirstPassTextures[1]);
mFirstPassTextures[1].display();
add(input, mFirstPassTextures[1], output);
}
示例8: adjustRenderTexture
void GuiElement::adjustRenderTexture(sf::RenderTexture& texture)
{
P<WindowManager> window_manager = engine->getObject("windowManager");
//Hack the rectangle for this element so it sits perfectly on pixel boundaries.
sf::Vector2f half_pixel = (window_manager->mapPixelToCoords(sf::Vector2i(1, 1)) - window_manager->mapPixelToCoords(sf::Vector2i(0, 0))) / 2.0f;
sf::Vector2f top_left = window_manager->mapPixelToCoords(window_manager->mapCoordsToPixel(sf::Vector2f(rect.left, rect.top) + half_pixel));
sf::Vector2f bottom_right = window_manager->mapPixelToCoords(window_manager->mapCoordsToPixel(sf::Vector2f(rect.left + rect.width, rect.top + rect.height) + half_pixel));
rect.left = top_left.x;
rect.top = top_left.y;
rect.width = bottom_right.x - top_left.x;
rect.height = bottom_right.y - top_left.y;
sf::Vector2i texture_size = window_manager->mapCoordsToPixel(sf::Vector2f(rect.width, rect.height) + half_pixel) - window_manager->mapCoordsToPixel(sf::Vector2f(0, 0));
unsigned int sx = powerOfTwo(texture_size.x);
unsigned int sy = powerOfTwo(texture_size.y);
if (texture.getSize().x != sx && texture.getSize().y != sy)
{
texture.create(sx, sy, false);
}
//Set the view so it covers this elements normal rect. So we can draw exactly the same on this texture as no the normal screen.
sf::View view(rect);
view.setViewport(sf::FloatRect(0, 0, float(texture_size.x) / float(sx), float(texture_size.y) / float(sy)));
texture.setView(view);
}
示例9: Apply
void BloomEffect::Apply( const sf::RenderTexture& input, sf::RenderTarget& output )
{
pImpl->PrepareTextures( input.getSize() );
pImpl->FilterBright( input, pImpl->mBrightnessTexture );
pImpl->Downsample( pImpl->mBrightnessTexture, pImpl->mFirstPassTextures[ 0 ] );
pImpl->BlurMultipass( pImpl->mFirstPassTextures );
pImpl->Downsample( pImpl->mFirstPassTextures[ 0 ], pImpl->mSecondPassTextures[ 0 ] );
pImpl->BlurMultipass( pImpl->mSecondPassTextures );
pImpl->Add( pImpl->mFirstPassTextures[ 0 ], pImpl->mSecondPassTextures[ 0 ], pImpl->mFirstPassTextures[ 1 ] );
pImpl->mFirstPassTextures[ 1 ].display();
pImpl->Add( input, pImpl->mFirstPassTextures[ 1 ], output );
}
示例10: apply
//public
void PostBloom::apply(const sf::RenderTexture& src, sf::RenderTarget& dest)
{
initTextures(src.getSize());
filterBright(src, m_brightnessTexture);
downSample(m_brightnessTexture, m_firstPassTextures[0]);
blurMultipass(m_firstPassTextures);
downSample(m_firstPassTextures[0], m_secondPassTextures[0]);
blurMultipass(m_secondPassTextures);
add(m_firstPassTextures[0], m_secondPassTextures[0], m_firstPassTextures[1]);
m_firstPassTextures[1].display();
add(src, m_firstPassTextures[1], dest);
}
示例11: vertices
void draw (sf::RenderTarget & target, sf::RenderStates states = sf::RenderStates::Default) const
{
lightBuffer.clear();
texture.display();
states.texture = &texture.getTexture();
for (const auto & light : lights)
{
light.draw(lightBuffer, getView(), states);
}
sf::Vector2f dimensions = sf::Vector2f(texture.getSize());
sf::VertexArray vertices(sf::Quads, 4);
vertices[0] = sf::Vertex(sf::Vector2f(0.f, 0.f), sf::Color(255, 255, 255, minAlpha), sf::Vector2f(0.f, 0.f));
vertices[1] = sf::Vertex(sf::Vector2f(dimensions.x, 0.f), sf::Color(255, 255, 255, minAlpha), sf::Vector2f(dimensions.x, 0.f));
vertices[2] = sf::Vertex(dimensions, sf::Color(255, 255, 255, minAlpha), dimensions);
vertices[3] = sf::Vertex(sf::Vector2f(0.f, dimensions.y), sf::Color(255, 255, 255, minAlpha), sf::Vector2f(0.f, dimensions.y));
lightBuffer.draw(vertices, states);
lightBuffer.display();
target.draw(sf::Sprite(lightBuffer.getTexture()));
}