Size size = Director::getInstance() -> getWinSize();
RenderTexture * screen = RenderTexture::create(size.width, size.height);
screen -> begin();
Scene *temp = Director::getInstance() -> getRunningScene();
temp -> visit();
screen -> end();
screen -> saveToFile(“coco2d-x-screenshot.png”,Image::Format::PNG);
Hi, thank you for your feed back. We used new renderer for 3.0 beta2. which means visit will only send render command to the renderer. the actual rendering will happen when render::render() function is called. which is in the director::DrawScene();
So, you can not get the renderToTexture Result immediately. but you can get the result in the next frame.
more info for the new renderer: https://docs.google.com/a/cocos2d-x.org/document/d/17zjC55vbP_PYTftTZEuvqXuMb9PbYNxRFu0EGTULPK8/edit
- RenderTexture saveToFile has updated, it logic is similar with V2.x, the texture will be save to file in this frame, but it is not save at the moment when you call the function saveToFile(…).
@mrsimple Thank you, could you give us a detailed description please? Did you get a black image when you save a PNG file? Or despite whatever type of image file, you can only get a black one?