Updating a texture in realtime

bloodlinebloodline Posts: 19Member

In SDL2 a texture can be updated in real-time (known as a streaming texture) from a pixel buffer in RAM which can be manipulated by the CPU. This is useful for games like Worms where one might want to have the landscape as a texture and have it “destructed” by events in the game.

Is there any way to do this in Godot?


  • bloodlinebloodline Posts: 19Member
    edited February 14

    So if I’ve understood the documentation correctly, the way to do this in Godot is thusly...

    One must start by creating an Image, this will be the pixel buffer, and can be modified as required.

    The next step is to create an ImageTexture, and use SetData() the previously created Image for the data source.

    Then a Sprite must be added to the scene and its texture needs to be set to the ImageTexture.

    Now one only needs to modify the Image and call SetData() to have the sprite’s texture modified.

    I need to test this out, but that is how my mental model works at the moment.

  • cyberealitycybereality Posts: 651Member

    Sounds like a reasonable method.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file