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 / Problem with Render Images and Android [BUGS??]

Author
Message
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 12th Jun 2015 00:30 Edited at: 12th Jun 2015 00:32
Well I have briefly mentioned in my post for Doodle Draw in the showcase section about having trouble with render images, check the code below for a simple drawing effect using the attached brush sprite.

It works ok on the PC but when you broadcast it to Android it has serious issues depending on which version of Android you run it on.

4.2.1 - Sprite drawn on screen in wrong location, slightly offset from where you point on the screen and also the screen totally mashes up as if corrupted.

4.4.4 - Sprite drawn on screen again in wrong location but not corrupted screen.

This is a serious problem as the render image commands are really quite useful with fast FPS against the slow FPS with memblocks and get image from memblock commands.

Anyone want to test the code below on Android (various versions) and IOS, etc and see what it is and isn't working on.

@Paul - is there a fix for this or is it something that is being done wrong.

I believe render images work on IOS like it does on the PC, however I have no Apple device to test it on.

If you change the size of the render screen compared to the screen size the offset is worse and drawing is all over the place.




The Amiga and Amos were great!
My website LEAP - Download Paint Pot here!

Attachments

Login to view attachments
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 12th Jun 2015 03:34 Edited at: 12th Jun 2015 03:35
On my PC it works great. On my Galaxy S2 (Android 4.1.2), all I get is a dot that follows your finger around the screen, but leaves no trail at all.

A possible alternative to render images would be to store all the draw locations in an array, and use the drawsprite command to render the complete image on each frame. I tested the theory and it works, although I'm not sure how much you could draw before it affects frame rate. You could also implement a simple line drawing algorithm or perhaps some bezier interpolation between dots to get a smooth line instead of just dots.

You could improve the above by implementing a "GetImage" for the whole picture when the user is not drawing so as to limit the amount of drawsprites required.

I hope any of that made sense. I'll try to find my example code and post it up.

V2 T1 (Mostly)
Uzmadesign
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 12th Jun 2015 07:11
Firstly you need to clear your render targets otherwise they might be filled with random memory data. Secondly render targets must currently be a power of 2 in size. They don't have to match the screen size as they can be scaled to any size when used on a sprite.

However, on mobile GPUs render targets should be cleared after a significant amount of drawing as they work differently to desktop GPUs. Mobile GPUs queue up draw calls until their buffers are flushed by a clear command, so every time you draw a new sprite it adds it to an ever increasing list of polygons that it draws every time the image is updated. It doesn't keep reading the frame buffer and writing it back for every sprite like a desktop GPU would. I've never tested the limits of this but to be safe you should use a method of double buffering your image rendering to help the GPU run smoothly. Try the following code

CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 12th Jun 2015 11:22
Here's my little example using drawsprites... although it looks like Paul has given you everything you need to resolve the problem with render images.



V2 T1 (Mostly)
Uzmadesign
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 12th Jun 2015 19:30
@Paul cheers for looking at this issue so promptly and also commenting the code etc!
Works a treat and there is no issue now, great lesson and will remember this now as render images now work great.
Clearing the renders and double buffering makes a lot of sense and I said I missed the good old days of Amos and the double buffer so can have some fun with this now.

BUG not there and great lesson, cheers

@CJB thanks for your input also, I know Paul has sorted the issue but another good piece of code there that can be put in the bag and used another day

The Amiga and Amos were great!
My website LEAP - Download Paint Pot here!
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 16th Jun 2015 23:11
There seems to be a bit of a strange thing happening with the draw code when broadcasting it on Android which I didn't notice before and that is the colours start to fade and bleed into each other, especially near to the top of the screen.

Very odd.

It seems Android is a bit hit and miss with these render images still.

I have also just noticed that if you go to the home screen and then go back into the app then the screen clears and you have to start drawing again.

Not sure if this is due to just broadcasting from AppGameKit and if this will still do the same with a running APK.

The Amiga and Amos were great!
My website LEAP - Download Paint Pot here!
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 25th Jun 2015 02:01
It seems that render images are a bit hit and miss as they act differently on each platform, Android, PC, Mac and IOS.

The Amiga and Amos were great!
My website LEAP - Download Paint Pot here!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Jun 2015 15:01
Quote: "...the colours start to fade and bleed into each other, especially near to the top of the screen"


Try this advice from Paul...

http://forum.thegamecreators.com/?m=forum_view&t=214664&b=41&msg=2562385#m2562385

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 1st Jul 2015 23:12
Well I have worked on this a bit more and was going to shelve it for a while but the problem seems to only be on Android as PC, MAC and iOS all seem to work great with no issues.
So what I am going to do is release on iOS only as this was only supposed to be a quick fun app anyway and I don't want to turn it into a headache

The Amiga and Amos were great!
My website LEAP - Download Paint Pot here!

Login to post a reply

Server time is: 2024-04-25 21:56:36
Your offset time is: 2024-04-25 21:56:36