mirror of https://github.com/axmolengine/axmol.git
Merge pull request #6907 from visiblelight/screenshot_refactor
adding comments for the new utility
This commit is contained in:
commit
0b661d8192
|
@ -44,16 +44,11 @@ int ccNextPOT(int x)
|
|||
return x + 1;
|
||||
}
|
||||
|
||||
namespace Utilities
|
||||
namespace utils
|
||||
{
|
||||
void captureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename)
|
||||
{
|
||||
static CustomCommand captureScreenCommand;
|
||||
captureScreenCommand.init(std::numeric_limits<float>::max());
|
||||
captureScreenCommand.func = std::bind(onCaptureScreen, afterCaptured, filename);
|
||||
Director::getInstance()->getRenderer()->addCommand(&captureScreenCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture screen implementation, don't use it directly.
|
||||
*/
|
||||
void onCaptureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename)
|
||||
{
|
||||
auto glView = Director::getInstance()->getOpenGLView();
|
||||
|
@ -112,6 +107,16 @@ void onCaptureScreen(const std::function<void(bool, const std::string&)>& afterC
|
|||
afterCaptured(succeed, outputFile);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Capture screen interface
|
||||
*/
|
||||
void captureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename)
|
||||
{
|
||||
static CustomCommand captureScreenCommand;
|
||||
captureScreenCommand.init(std::numeric_limits<float>::max());
|
||||
captureScreenCommand.func = std::bind(onCaptureScreen, afterCaptured, filename);
|
||||
Director::getInstance()->getRenderer()->addCommand(&captureScreenCommand);
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -47,17 +47,17 @@ Examples:
|
|||
|
||||
int ccNextPOT(int value);
|
||||
|
||||
namespace Utilities
|
||||
namespace utils
|
||||
{
|
||||
/**
|
||||
* Capture screen interface
|
||||
/** Capture the entire screen
|
||||
* To ensure the snapshot is applied after everything is updated and rendered in the current frame,
|
||||
* we need to wrap the operation with a custom command which is then inserted into the tail of the render queue.
|
||||
* @param afterCaptured, specify the callback function which will be invoked after the snapshot is done.
|
||||
* @param filename, specify a filename where the snapshot is stored. This parameter can be either an absolute path or a simple
|
||||
* base filename ("hello.png" etc.), don't use a relative path containing directory names.("mydir/hello.png" etc.)
|
||||
* @since v3.2
|
||||
*/
|
||||
void captureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename);
|
||||
|
||||
/**
|
||||
* The implementation of capturing screen
|
||||
*/
|
||||
void onCaptureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -609,7 +609,7 @@ void CaptureScreenTest::onCaptured(Ref*)
|
|||
Director::getInstance()->getTextureCache()->removeTextureForKey(_filename);
|
||||
removeChildByTag(childTag);
|
||||
_filename = "CaptureScreenTest.png";
|
||||
Utilities::captureScreen(CC_CALLBACK_2(CaptureScreenTest::afterCaptured, this), _filename);
|
||||
utils::captureScreen(CC_CALLBACK_2(CaptureScreenTest::afterCaptured, this), _filename);
|
||||
}
|
||||
|
||||
void CaptureScreenTest::afterCaptured(bool succeed, const std::string& outputFile)
|
||||
|
|
Loading…
Reference in New Issue