Best way to update texture data...?!

I have a class and this extend from Sprite, this class init with texture.
I update the texture with data(buffer video) in a loop.
I don’t know if this is correct, but workly… :sweat_smile:
If anyone can advise me alternative method, i appreciate.

Perhaps show us what you have done thus far…

Example:

Player.h

class VideoPlayer : public cocos2d::Sprite {
public:
    ~VideoPlayer();
    static VideoPlayer* create(cocos2d::Size size);
    void play(const std::string &path, bool repeat = true);
    char *m_videobuf;

Player.cpp

VideoPlayer *VideoPlayer::create(Size size) {
    auto player = new VideoPlayer;
    if(player && player->init(size)) {
        player->autorelease();
    } else {
        CC_SAFE_DELETE(player);
    }
    return player;
}
bool VideoPlayer::init(Size &size) {
    m_videobuf = (char *)malloc((width * height) << 2);
    memset(m_videobuf, 0, (width * height) << 2);
    ...
    Texture2D *texture = new Texture2D();
    texture->initWithData(m_videobuf, (width * height) << 2, PixelFormat::RGBA8888, width, height, size);
    texture->autorelease();
    initWithTexture(texture);
    scheduleUpdate();
    return true;
}
void VideoPlayer::update(float dt) {
    _texture->updateWithData(m_videobuf, 0, 0, width, height);
}

Alternative for draw texture? Shaders or by GPU?!
I think is heavy for CPU… or not? Thanks.