Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How to NOT clear backbuffer on mobile devices?

Author
Message
Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 10th May 2014 17:49
Hi all,

I'm making an app that requires a "blending" effect. Actually more like trails behind every object that moves. On PC, EnableClearColor(0) works a treat to keep the backbuffer uncleared, and I just use a fullscreen transparent black sprite to fade out the previously rendered sprites. The problem is, I can't make this work on my phone (Samsung Galaxy S3). I did some research, and as far as I can tell, the backbuffer is forcibly cleared on some devices (but it works on my Nexus 7).

My question is this: Is there a way around this? If not, can anyone suggest an alternate solution? Preferably as fast as possible as my app is pretty performance-heavy as it is.

I'd appreciate any help you can give, because this may completely sutff weeks/months of work if I can't figure out a solution

Markus
Valued Member
22
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 10th May 2014 17:54
my experience with EnableClearColor is , do not touch.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 10th May 2014 18:04
Quote: "my experience with EnableClearColor is , do not touch."


Mmm, I get that feeling. The only problem is that I have no idea what else to do...

xCept
23
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 10th May 2014 19:10
EnableClearColor doesn't work on most devices and causes incredibly unpredictable results. V2 supports render-to-image features, which could be used to achieve some effect. However, I have had no luck getting that feature to work on anything but Windows yet despite Paul stating in the change log they should work on all devices.
Markus
Valued Member
22
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 10th May 2014 20:22 Edited at: 12th May 2014 14:03
hmm, maybe try v2 alpha,
i believe the new sprite blendmodes or render to image are ready.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 11th May 2014 04:07
Quote: "EnableClearColor doesn't work on most devices and causes incredibly unpredictable results."


Yeah...

Quote: "hmm, maybe try v2 alpha,
i believe the new sprite blendmodes or render to image are ready."


I can't really. My app is complete except for this one nasty bug, and I assume most of V2 is not actually working yet. I need a stable platform. Plus, I can't afford V2 even at that price.

NOW what am I going to do...

Naphier
15
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 11th May 2014 07:20
This is a tough one!
I think I understand what effect you're after, but doing it with making the backbuffer static for a frame doesn't sound like a stable way to go. Can you do a short video on the effect? Maybe I'll be able to better understand what you're after. The only thing I can think of right now is to make clones of your sprites as they move, set the clone transparency to 50%, then delete the clone on the next frame, or leave it alive but always have it move 1 frame slower. It's not a simple thing to do!

Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 11th May 2014 09:11
Quote: "This is a tough one!"

Quote: "It's not a simple thing to do!"


Indeed, but it was actually the AGK help files that told me to do it the way I did, and made it seem to simple.

Quote: "Can you do a short video on the effect? Maybe I'll be able to better understand what you're after."


Sure, just give me a while.

Quote: "The only thing I can think of right now is to make clones of your sprites as they move, set the clone transparency to 50%, then delete the clone on the next frame, or leave it alive but always have it move 1 frame slower."


That's one "solution" (it wouldn't look very good) that I already thought of, but the problem is that my app is already pushing performance to the limits and has 1000-5000 sprites on screen. Still, a lot of the performance drain is in the calculations required for the sprites, so I'll do some experiments...

Digital Awakening
AGK Developer
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 11th May 2014 12:16 Edited at: 11th May 2014 12:18
Render to image should work in Alpha 3. I have tested it on PC and Ouya. It wasn't difficult to add to RTA once I figured out how it worked. But this means that you will do a full screen redraw and if you are short on fillrate, that could be a problem. You can always render to a smaller image and scale that up, I do that with RTA on Ouya. I use render to image to allow users to shrink the image and adjust for overscan.

Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 11th May 2014 15:29
Rendering to a smaller image would be bad because my app relies on crisp graphics (if it feels like I'm being intentionally cryptic about what my app is, it's because I am ).

My current thinking is that I might try to create an image via memblocks and modify it each frame underneath sprite positions. The only problem is that creating a new fullscreen image from a memblock each frame may simply kill performance. I just can't win.

I'm also looking into the possibility of converting all of my code over to Cocos2D-X, because I already have my code running in C++. Unfortunately Cocos doesn't have very clear documentation and it may simply be too difficult. Not sure what I would do then...

The Zoq2
16
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 11th May 2014 16:01
Quote: "My current thinking is that I might try to create an image via memblocks and modify it each frame underneath sprite positions. The only problem is that creating a new fullscreen image from a memblock each frame may simply kill performance. I just can't win."


I did some experiments with that a while back and it turned out that it is not viable at all. If I recall correctly I was only able to keep it above 60 fps if the image was smaller than 200x200 and that was on a PC. Render to image should be a lot faster and I don't see why you wouldn't be able to render at the real resolution.

Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy
Clonkex
Forum Vice President
16
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 11th May 2014 16:12
Hmm... Yeah, I now remember that I did some tests a while back relating to realtime landscape modification and it was really slow.

The biggest problem with render-to-texture is that I can't afford V2 yet, and I don't even know what its status is; i.e., does it work reliably for everything V1 can do?

The Zoq2
16
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 11th May 2014 17:17
I think V2 the current V2 alpha is pretty stable, I was able to complete my nexus competition entry using it and right now im pretty sure that it's fully backwards compatible with V1

Say ONE stupid thing and it ends up as a forum signature forever. - Neuro Fuzzy

Login to post a reply

Server time is: 2026-07-28 05:49:29
Your offset time is: 2026-07-28 05:49:29