2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2009 Jason Booth
|
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "2d/CCNode.h"
|
|
|
|
#include "2d/CCSprite.h"
|
|
|
|
#include "platform/CCImage.h"
|
|
|
|
#include "renderer/CCGroupCommand.h"
|
|
|
|
#include "renderer/CCCustomCommand.h"
|
|
|
|
#include "renderer/CCCallbackCommand.h"
|
|
|
|
#include "renderer/backend/Types.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
namespace backend
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
class TextureBackend;
|
|
|
|
class RenderTarget;
|
|
|
|
} // namespace backend
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
class EventCustom;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup _2d
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief RenderTexture is a generic rendering target. To render things into it,
|
|
|
|
* simply construct a render target, call begin on it, call visit on any cocos
|
|
|
|
* scenes or objects to render them, and call end. For convenience, render texture
|
|
|
|
* adds a sprite as it's display child with the results, so you can simply add
|
|
|
|
* the render texture to your scene and treat it like any other CocosNode.
|
|
|
|
* There are also functions for saving the render texture to disk in PNG or JPG format.
|
|
|
|
* @since v0.8.1
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
class CC_DLL RenderTexture : public Node
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
public:
|
2021-12-26 23:26:34 +08:00
|
|
|
using SaveFileCallbackType = std::function<void(RenderTexture*, std::string_view)>;
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats
|
|
|
|
* are valid ) and depthStencil format.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param w The RenderTexture object width.
|
|
|
|
* @param h The RenderTexture object height.
|
|
|
|
* @param format In Points and a pixel format( only RGB and RGBA formats are valid ).
|
|
|
|
* @param depthStencilFormat The depthStencil format.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
static RenderTexture* create(int w, int h, backend::PixelFormat format, backend::PixelFormat depthStencilFormat);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are
|
|
|
|
* valid.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param w The RenderTexture object width.
|
|
|
|
* @param h The RenderTexture object height.
|
|
|
|
* @param format In Points and a pixel format( only RGB and RGBA formats are valid ).
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
static RenderTexture* create(int w, int h, backend::PixelFormat format);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Creates a RenderTexture object with width and height in Points, pixel format is RGBA8888.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param w The RenderTexture object width.
|
|
|
|
* @param h The RenderTexture object height.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
static RenderTexture* create(int w, int h);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
// Overrides
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) override;
|
|
|
|
|
|
|
|
virtual void draw(Renderer* renderer, const Mat4& transform, uint32_t flags) override;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
/** Starts grabbing. */
|
|
|
|
virtual void begin();
|
|
|
|
|
|
|
|
/** Starts rendering to the texture while clearing the texture first.
|
|
|
|
* This is more efficient then calling -clear first and then -begin.
|
|
|
|
*
|
|
|
|
* @param r Red.
|
|
|
|
* @param g Green.
|
|
|
|
* @param b Blue.
|
|
|
|
* @param a Alpha.
|
|
|
|
*/
|
|
|
|
virtual void beginWithClear(float r, float g, float b, float a);
|
|
|
|
|
|
|
|
/** Starts rendering to the texture while clearing the texture first.
|
|
|
|
* This is more efficient then calling -clear first and then -begin.
|
|
|
|
*
|
|
|
|
* @param r Red.
|
|
|
|
* @param g Green.
|
|
|
|
* @param b Blue.
|
|
|
|
* @param a Alpha.
|
|
|
|
* @param depthValue The depth Value.
|
|
|
|
*/
|
|
|
|
virtual void beginWithClear(float r, float g, float b, float a, float depthValue);
|
|
|
|
|
|
|
|
/** Starts rendering to the texture while clearing the texture first.
|
2021-12-25 10:04:45 +08:00
|
|
|
* This is more efficient then calling -clear first and then -begin.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param r Red.
|
|
|
|
* @param g Green.
|
|
|
|
* @param b Blue.
|
|
|
|
* @param a Alpha.
|
|
|
|
* @param depthValue A specified depth value.
|
|
|
|
* @param stencilValue A specified stencil value.
|
|
|
|
*/
|
|
|
|
virtual void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue);
|
|
|
|
|
|
|
|
/** Ends grabbing.
|
|
|
|
* @lua endToLua
|
|
|
|
*/
|
|
|
|
virtual void end();
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Clears the texture with a color.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param r Red.
|
|
|
|
* @param g Green.
|
|
|
|
* @param b Blue.
|
|
|
|
* @param a Alpha.
|
|
|
|
*/
|
|
|
|
void clear(float r, float g, float b, float a);
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Clears the texture with a specified depth value.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param depthValue A specified depth value.
|
|
|
|
*/
|
|
|
|
virtual void clearDepth(float depthValue);
|
|
|
|
|
|
|
|
/** Clears the texture with a specified stencil value.
|
|
|
|
*
|
|
|
|
* @param stencilValue A specified stencil value.
|
|
|
|
*/
|
|
|
|
virtual void clearStencil(int stencilValue);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/* Creates a new Image from with the texture's data.
|
|
|
|
* Caller is responsible for releasing it by calling delete.
|
|
|
|
*
|
|
|
|
* @param flipImage Whether or not to flip image.
|
|
|
|
* @return An image.
|
|
|
|
* @js NA
|
|
|
|
*/
|
2020-09-11 11:57:55 +08:00
|
|
|
void newImage(std::function<void(RefPtr<Image>)> imageCallback, bool flipImage = true);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/** Saves the texture into a file using JPEG format. The file will be saved in the Documents folder.
|
|
|
|
* Returns true if the operation is successful.
|
|
|
|
*
|
|
|
|
* @param filename The file name.
|
|
|
|
* @param isRGBA The file is RGBA or not.
|
|
|
|
* @param callback When the file is save finished,it will callback this function.
|
|
|
|
* @return Returns true if the operation is successful.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
bool saveToFileAsNonPMA(std::string_view filename, bool isRGBA = true, SaveFileCallbackType = nullptr);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
/** Saves the texture into a file using JPEG format. The file will be saved in the Documents folder.
|
|
|
|
* Returns true if the operation is successful.
|
|
|
|
*
|
|
|
|
* @param filename The file name.
|
|
|
|
* @param isRGBA The file is RGBA or not.
|
|
|
|
* @param callback When the file is save finished,it will callback this function.
|
|
|
|
* @return Returns true if the operation is successful.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
bool saveToFile(std::string_view filename, bool isRGBA = true, SaveFileCallbackType = nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/** saves the texture into a file in non-PMA. The format could be JPG or PNG. The file will be saved in the
|
|
|
|
Documents folder. Returns true if the operation is successful.
|
|
|
|
* Notes: since v3.x, saveToFile will generate a custom command, which will be called in the following
|
|
|
|
render->render().
|
|
|
|
* So if this function is called in a event handler, the actual save file will be called in the next frame. If we
|
|
|
|
switch to a different scene, the game will crash.
|
|
|
|
* To solve this, add Director::getInstance()->getRenderer()->render(); after this function.
|
|
|
|
*
|
|
|
|
* @param filename The file name.
|
|
|
|
* @param format The image format.
|
|
|
|
* @param isRGBA The file is RGBA or not.
|
|
|
|
* @param callback When the file is save finished,it will callback this function.
|
|
|
|
* @return Returns true if the operation is successful.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
bool saveToFileAsNonPMA(std::string_view fileName,
|
2021-12-25 10:04:45 +08:00
|
|
|
Image::Format format,
|
|
|
|
bool isRGBA,
|
2021-12-26 23:26:34 +08:00
|
|
|
SaveFileCallbackType callback);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
/** saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder.
|
|
|
|
Returns true if the operation is successful.
|
2021-12-25 10:04:45 +08:00
|
|
|
* Notes: since v3.x, saveToFile will generate a custom command, which will be called in the following
|
|
|
|
render->render().
|
|
|
|
* So if this function is called in a event handler, the actual save file will be called in the next frame. If we
|
|
|
|
switch to a different scene, the game will crash.
|
2019-11-23 20:27:39 +08:00
|
|
|
* To solve this, add Director::getInstance()->getRenderer()->render(); after this function.
|
|
|
|
*
|
|
|
|
* @param filename The file name.
|
|
|
|
* @param format The image format.
|
|
|
|
* @param isRGBA The file is RGBA or not.
|
|
|
|
* @param callback When the file is save finished,it will callback this function.
|
|
|
|
* @return Returns true if the operation is successful.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
bool saveToFile(std::string_view filename,
|
2021-12-25 10:04:45 +08:00
|
|
|
Image::Format format,
|
2021-12-26 23:26:34 +08:00
|
|
|
bool isRGBA = true,
|
|
|
|
SaveFileCallbackType callback = nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/** Listen "come to background" message, and save render texture.
|
|
|
|
* It only has effect on Android.
|
2021-12-25 10:04:45 +08:00
|
|
|
*
|
2019-11-23 20:27:39 +08:00
|
|
|
* @param event Event Custom.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void listenToBackground(EventCustom* event);
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/** Listen "come to foreground" message and restore the frame buffer object.
|
|
|
|
* It only has effect on Android.
|
|
|
|
*
|
|
|
|
* @param event Event Custom.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void listenToForeground(EventCustom* event);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
/** Valid when "autoDraw" is true.
|
|
|
|
*
|
|
|
|
* @return Clear flags.
|
|
|
|
*/
|
|
|
|
inline ClearFlag getClearFlags() const { return _clearFlags; }
|
|
|
|
|
|
|
|
/** Set flags.
|
|
|
|
*
|
|
|
|
* @param clearFlags set clear flags.
|
|
|
|
*/
|
|
|
|
void setClearFlags(ClearFlag clearFlags);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/** Clear color value. Valid only when "autoDraw" is true.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @return Color value.
|
|
|
|
*/
|
|
|
|
inline const Color4F& getClearColor() const { return _clearColor; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/** Set color value.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param clearColor Color value.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
inline void setClearColor(const Color4F& clearColor) { _clearColor = clearColor; }
|
|
|
|
|
|
|
|
/** Value for clearDepth. Valid only when "autoDraw" is true.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @return Value for clearDepth.
|
|
|
|
*/
|
|
|
|
inline float getClearDepth() const { return _clearDepth; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/** Set Value for clearDepth.
|
|
|
|
*
|
|
|
|
* @param clearDepth Value for clearDepth.
|
|
|
|
*/
|
|
|
|
inline void setClearDepth(float clearDepth) { _clearDepth = clearDepth; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/** Value for clear Stencil. Valid only when "autoDraw" is true.
|
|
|
|
*
|
|
|
|
* @return Value for clear Stencil.
|
|
|
|
*/
|
|
|
|
inline int getClearStencil() const { return _clearStencil; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
/** Set Value for clear Stencil.
|
|
|
|
*
|
|
|
|
* @param clearStencil Value for clear Stencil.
|
|
|
|
*/
|
|
|
|
inline void setClearStencil(int clearStencil) { _clearStencil = clearStencil; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/** When enabled, it will render its children into the texture automatically. Disabled by default for compatibility
|
|
|
|
* reasons. Will be enabled in the future.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @return Return the autoDraw value.
|
|
|
|
*/
|
|
|
|
inline bool isAutoDraw() const { return _autoDraw; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/** Set a valve to control whether or not render its children into the texture automatically.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param isAutoDraw Whether or not render its children into the texture automatically.
|
|
|
|
*/
|
|
|
|
inline void setAutoDraw(bool isAutoDraw) { _autoDraw = isAutoDraw; }
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Gets the Sprite being used.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @return A Sprite.
|
|
|
|
*/
|
|
|
|
inline Sprite* getSprite() const { return _sprite; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/** Sets the Sprite being used.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param sprite A Sprite.
|
|
|
|
*/
|
|
|
|
void setSprite(Sprite* sprite);
|
|
|
|
|
|
|
|
/** Flag: Use stack matrix computed from scene hierarchy or generate new modelView and projection matrix.
|
|
|
|
*
|
2021-12-25 10:04:45 +08:00
|
|
|
* @param keepMatrix Whether or not use stack matrix computed from scene hierarchy or generate new modelView and
|
|
|
|
* projection matrix.
|
2019-11-23 20:27:39 +08:00
|
|
|
* @js NA
|
|
|
|
*/
|
|
|
|
inline void setKeepMatrix(bool keepMatrix) { _keepMatrix = keepMatrix; }
|
2021-12-25 10:04:45 +08:00
|
|
|
/**Used for grab part of screen to a texture.
|
2019-11-23 20:27:39 +08:00
|
|
|
* @param rtBegin The position of renderTexture on the fullRect.
|
|
|
|
* @param fullRect The total size of screen.
|
|
|
|
* @param fullViewport The total viewportSize.
|
|
|
|
*/
|
|
|
|
void setVirtualViewport(const Vec2& rtBegin, const Rect& fullRect, const Rect& fullViewport);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** FIXME: should be protected.
|
|
|
|
* but due to a bug in PowerVR + Android,
|
|
|
|
* the constructor is public again.
|
|
|
|
* @js ctor
|
|
|
|
*/
|
|
|
|
RenderTexture();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @js NA
|
2021-12-25 10:04:45 +08:00
|
|
|
* @lua NA
|
2019-11-23 20:27:39 +08:00
|
|
|
*/
|
|
|
|
virtual ~RenderTexture();
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats
|
|
|
|
* are valid.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param w The RenderTexture object width.
|
|
|
|
* @param h The RenderTexture object height.
|
|
|
|
* @param format In Points and a pixel format( only RGB and RGBA formats are valid ).
|
|
|
|
* @return If succeed, it will return true.
|
|
|
|
*/
|
|
|
|
bool initWithWidthAndHeight(int w, int h, backend::PixelFormat format);
|
2021-12-25 10:04:45 +08:00
|
|
|
/** Initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats
|
|
|
|
* are valid ) and depthStencil format.
|
2019-11-23 20:27:39 +08:00
|
|
|
*
|
|
|
|
* @param w The RenderTexture object width.
|
|
|
|
* @param h The RenderTexture object height.
|
|
|
|
* @param format In Points and a pixel format( only RGB and RGBA formats are valid ).
|
|
|
|
* @param depthStencilFormat The depthStencil format.
|
|
|
|
* @return If succeed, it will return true.
|
|
|
|
*/
|
|
|
|
bool initWithWidthAndHeight(int w, int h, backend::PixelFormat format, backend::PixelFormat depthStencilFormat);
|
|
|
|
|
|
|
|
protected:
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void
|
|
|
|
beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue, ClearFlag flags);
|
|
|
|
// renderer caches and callbacks
|
2019-11-23 20:27:39 +08:00
|
|
|
void onBegin();
|
|
|
|
void onEnd();
|
|
|
|
void clearColorAttachment();
|
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
void onSaveToFile(std::string_view fileName, bool isRGBA = true, bool forceNonPMA = false);
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool _keepMatrix = false;
|
|
|
|
Rect _rtTextureRect;
|
|
|
|
Rect _fullRect;
|
|
|
|
Rect _fullviewPort;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
Viewport _oldViewport;
|
|
|
|
|
|
|
|
Texture2D* _texture2D = nullptr;
|
2019-11-23 20:27:39 +08:00
|
|
|
Texture2D* _depthStencilTexture = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
Texture2D* _texture2DCopy = nullptr; // a copy of _texture
|
|
|
|
|
|
|
|
backend::RenderTarget* _renderTarget = nullptr;
|
2020-09-21 22:10:50 +08:00
|
|
|
backend::RenderTarget* _oldRenderTarget = nullptr;
|
|
|
|
RenderTargetFlag _renderTargetFlags{};
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
Image* _UITextureImage = nullptr;
|
2020-09-25 11:07:56 +08:00
|
|
|
backend::PixelFormat _pixelFormat = backend::PixelFormat::RGBA8;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
Color4F _clearColor;
|
2021-12-25 10:04:45 +08:00
|
|
|
float _clearDepth = 1.f;
|
|
|
|
int _clearStencil = 0;
|
|
|
|
bool _autoDraw = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
ClearFlag _clearFlags = ClearFlag::NONE;
|
|
|
|
|
|
|
|
/** The Sprite being used.
|
2021-12-25 10:04:45 +08:00
|
|
|
The sprite, by default, will use the following blending function: BlendFactor::ONE,
|
|
|
|
BlendFactor::ONE_MINUS_SRC_ALPHA. The blending function can be changed in runtime by calling:
|
2019-11-23 20:27:39 +08:00
|
|
|
- renderTexture->getSprite()->setBlendFunc((BlendFunc){BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA});
|
|
|
|
*/
|
|
|
|
Sprite* _sprite = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
GroupCommand _groupCommand;
|
|
|
|
CallbackCommand _beginCommand;
|
|
|
|
CallbackCommand _endCommand;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
CallbackCommand _beforeClearAttachmentCommand;
|
|
|
|
CallbackCommand _afterClearAttachmentCommand;
|
|
|
|
/*this command is used to encapsulate saveToFile,
|
|
|
|
call saveToFile twice will overwrite this command and callback
|
|
|
|
and the command and callback will be executed twice.
|
|
|
|
*/
|
|
|
|
CallbackCommand _saveToFileCommand;
|
2021-12-26 23:26:34 +08:00
|
|
|
std::function<void(RenderTexture*, std::string_view)> _saveFileCallback = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
Mat4 _oldTransMatrix, _oldProjMatrix;
|
|
|
|
Mat4 _transformMatrix, _projectionMatrix;
|
|
|
|
|
|
|
|
private:
|
|
|
|
CC_DISALLOW_COPY_AND_ASSIGN(RenderTexture);
|
|
|
|
};
|
|
|
|
|
|
|
|
// end of textures group
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
NS_CC_END
|