Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Better Clear for RennderTarget — Gideros Forum

Better Clear for RennderTarget

antixantix Member
edited October 2015 in Suggestions & requests
I would like to suggest/request that there should be some more functionality in RenderTarget so you can opt to clear a rectangular area of the RenderTarget. Maybe a new method called RenderTarget:clearRect(x1, y1, x2, y2, color, alpha)

Only being able to clear the entire thing imposes nasty limitations on RenderTargets.

In theory it should be easy to implement since you can already clear the entire RenderTarget.

Comments

  • hgy29hgy29 Maintainer
    Well in fact, OpenGL only propose a global clear function (glClear), so we want to clear a single part, we have to find some other way. I am pretty sure there should be some blending op which would allow that, perhaps not accessible through lua yet.
    Can you add a feature request (issue) on github about that ?

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
  • keszeghkeszegh Member
    edited October 2015
  • @hgy29 - Cool, submitted. Maybe a new blendMode Sprite.REPLACE that overwrites the destination with the source exactly?
  • SinisterSoftSinisterSoft Maintainer
    edited October 2015
    This would be useful, or/and optional clear parameters that do the same as clear but clipped to a specific area.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • antixantix Member
    So will something like this ever be added? Can it even be added?
  • Likes: antix

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    edited March 2016
    @SinisterSoft, awesome! When was that done? I never saw any mention in release notes :(
  • antixantix Member
    So how does this actually work?

    In the following code when I load my backdrop image I want the 128x128 sized area at location 0,128 of the RenderTarget to be cleared. Instead the whole thing is still being cleared.
    local texture_atlas
    local backdrop
    local player
     
    local texture_regions = {
      {  0, 128, 128, 128}, -- BACKDROP
      {  0,   0,  64,  64}, -- PLAYER
    }
     
    local function getRegion(region)
      local r = texture_regions[region]
      return TextureRegion.new(texture_atlas, r[1], r[2], r[3], r[4])
    end
     
    local function loadAtlas()
      texture_atlas = RenderTarget.new(256, 256)
      texture_atlas:draw(Bitmap.new(Texture.new("atlas.png")))
    end
     
    local function loadBackdrop(number)
      texture_atlas:clear(0x000044, 1, 0, 128, 128, 128) -- CLEAR ONLY THE SPECIFIC REGION OF THE ATLAS
      local bitmap = Bitmap.new(Texture.new("backdrop"..number..".png"))
      bitmap:setPosition(0, 128)
      texture_atlas:draw(bitmap)
    end
     
    loadAtlas()
    loadBackdrop(1)
     
    player = Bitmap.new(getRegion(2))
    backdrop = Bitmap.new(getRegion(1))
     
    stage:addChild(backdrop)
    stage:addChild(player)
    What am I doing wrong here? I'm using Gideros 2015.10
    zip
    zip
    RTClear.zip
    29K

    Likes: rolfpancake

    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    Cancel that.. I just downloaded 2015.12 and it's working now :-B

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • Must have been added then. ;)

    Likes: antix

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    Must have been. It is really a fantastic feature to have!
Sign In or Register to comment.