Results 1 to 7 of 7

Thread: Is possible to replace texture part?

  1. #1

    Is possible to replace texture part?

    Hi there,

    how is possible to erase texture part (without shader but opengles 1.1)?

    I have a background image


    and a foreground image


    When i move the player/mouse, erase part of foreground image


    Thanks in advance
    Sesilla
    Attached Images Attached Images
    Last edited by SesillaAndromeda; 17-09-2015 at 12:27 PM.

  2. #2
    Of course you can. Modify the foreground making it transparent (alpha channel) and update the "scene".

    If you're asking for code, it depends on what are you using. I mean, if you're using Allegro you'll do it different than using SDL...
    No signature provided yet.

  3. #3
    Hi Ñuño,

    yes, the code is very valued! I'm using opengles 1.x without framework.

    Thanks
    Sesilla

  4. #4
    Then, it will take a lot of time and explanation (and I have no idea how to make it without a "framework" ).

    Anyway, the work is the same in any case:

    1. Keep two bit-maps that contains the foreground and the background.
    2. Upload them and use the "foreground" to hide the "background", but don't remove them from "system" memory.
    3. Now, as user moves the mouse, make "foreground" bitmap pixels transparent and upload it, substituting the old foreground (i.e., use the same GL ID).
    4. Repeat.
    No signature provided yet.

  5. #5
    Load the colored background as 1 texture into GPU, and then the grayscale in memory. When you want to erase parts of the grayscale, just set those pixels alpha to 0. Reload the grayscale into videomemory after updates, but with certain interval and area. You may also be able to update just a rectangular part of the grayscale image at the time to optimize speed, or split it into a grid of multiple textures. It's similar to game like Worms, where i'd definitely split the texture into say 10x10 set of textures.

    This example few years back for example used such split: https://www.youtube.com/watch?v=cEKD4CNvexU

  6. #6
    Thanks User137, have you a sample code?

    Regards
    Sesilla

  7. #7
    Yeah here is project source, you need nxPascal to compile. I remembered wrong though, this demo is using framebuffer for realtime texture editing. For that reason it propably can't be pixel-perfect, but it's efficient. May be difficult code to digest, i can only barely keep up with it myself. Material map is a separate dynamic array.

    Framebuffer allows things like even rendering actual 3D-models into the texture.
    Attached Files Attached Files
    Last edited by User137; 19-11-2015 at 04:15 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •