本文整理汇总了C++中sf::RenderWindow::capture方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderWindow::capture方法的具体用法?C++ RenderWindow::capture怎么用?C++ RenderWindow::capture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RenderWindow
的用法示例。
在下文中一共展示了RenderWindow::capture方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
Level::Level(sf::RenderWindow& window,const std::string& filename) :
onPickup(defaultFunc),
_map(sfutils::VMap::createMapFromFile(filename)),
_viewer(window,*_map,Configuration::mapInputs),
_mouseLayer(new sfutils::Layer<sf::ConvexShape>("ConvexShape",1)),
_entitiesLayer(new sfutils::Layer<Entity*>("Entity",2))
{
//Map
if(_map == nullptr)
{
//do some error
throw std::runtime_error("Impossible to load file " + filename);
}
{
_mouse_light = _mouseLayer->add(_map->getShape());
_mouse_light->setFillColor(sf::Color(255,255,255,64));
_map->add(_mouseLayer);
}
_map->add(_entitiesLayer);
//Viewer
_viewer.bind(Configuration::MapInputs::TakeScreen,[&window](const sf::Event& event) {
sf::Image screen = window.capture();
time_t rawtime;
struct tm * timeinfo;
char buffer[128];
std::time(&rawtime);
timeinfo = std::localtime(&rawtime);
std::strftime (buffer,128,"screen/%F_%T.png",timeinfo);
screen.saveToFile(std::string(buffer));
});
//ES
systems.add<SysAIMain>();
systems.add<SysAIWarrior>(*this);
systems.add<SysAIDefender>(*this);
systems.add<SysAISpawner>(*this);
systems.add<SysAIWalker>(*this);
systems.add<SysAIFlyer>(*this);
systems.add<SysSkin>();
systems.add<SysHp>(*this);
systems.add<SysEffect>(*this);
}
示例2: fadeOut
void EffectsHandler::fadeOut(sf::RenderWindow &rw)
{
sf::Texture ScreenCap;
ScreenCap.loadFromImage(rw.capture());
sf::Sprite SpleenCrap;
SpleenCrap.setTexture(ScreenCap);
sf::Clock timer;
float opacity = 0;
while (opacity < 255) {
rw.clear();
opacity += timer.restart().asSeconds() * 100;
SpleenCrap.setColor(sf::Color(0,0,0,opacity));
rw.draw(SpleenCrap);
rw.display();
}
}
示例3: window_loop
/*
* Simple window loop, won't redraw (but fuck it, this is testing)
*/
void window_loop(sf::RenderWindow &window) {
sf::Image img = window.capture();
sf::Texture texture;
texture.loadFromImage(img);
sf::Sprite sprite;
sprite.setTexture(texture, true);
sf::Event event;
while (window.isOpen()) {
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
} else if (event.type == sf::Event::KeyPressed) {
if (event.key.code == sf::Keyboard::Escape) {
window.close();
}
}
}
window.draw(sprite);
window.display();
sf::sleep(sf::seconds(0.1f));
}
}