B4A Library [Lib] Accelerated surface

Informatix

Expert
Licensed User
Longtime User
You've said so yourself:

You misunderstood what I wrote. I never suggested to hide anything, just to avoid repeating the same static drawings to save FPS.
What I suggest is to draw your background, render it into a bitmap and reuse this bitmap instead of redrawing all the complex stuff composing your background. The drawing is done in the Render event, the copy to a bitmap is done in the Update event and a flag is set to say "hey, you can now render this bitmap instead" that will be read by the next Render event. No need for a second Accel. Surf.
It's a bit strange that drawing only 50 bitmaps take so much time that you need to hide the process (unless you load these bitmaps in the Render event which is a terrible idea).
 

ilan

Expert
Licensed User
Longtime User
hi

i am working on a new simple puzzle game and i tried first to use only the core lib (draw everything via canvas)
the code works but the performance was not good enough so i decided to try acclerated surface since libgdx would be to much for such a simple game
and it is working really great.

just wanted to thank you for this lib
 

ilan

Expert
Licensed User
Longtime User
sorry for my ignorance, what is a halo?

is there maybe an example how to draw a glowing line?

thank you
 

Informatix

Expert
Licensed User
Longtime User
i wanted to use this: https://www.b4x.com/android/forum/t...with-a-gradient-or-texture.57246/#post-361056

but AC ist not a canvas that can use that option.
This code does what I said: it draws a halo (a radiant light around an object) and a line, the halo being just a blurred line. You can reuse the same idea with AC but I don't have the time for now to create an example. In brief, you create the mask and the paint objects and you set the paint property of AC to this paint object before drawing. It's mainly a copy/paste operation.
 

ilan

Expert
Licensed User
Longtime User

i could not figure out how to do it with AS (tried for 2 days), currently i am using a transparent panel and i am drawing via canvas and the code i posted above on that panel but i would like to use AS for that since it is using Hardware Acceleration. if you will find time to make a simple short example code (only how to draw 1 line) i will really appreciate it. thanx in advance
 

Informatix

Expert
Licensed User
Longtime User
As I said, it's just a copy/paste and you replace the canvasJO part to draw the line by:
B4X:
Line1.CreateLine(50%x, 50%y, False)
Line1.Paint = paintJO
AC.DrawObjectAt(Line1, 10dip, 10dip)
BUT this effect requires to disable the hardware acceleration because in accelerated mode, the canvas draws a solid line for the halo.
 

Attachments

  • Glowing line.zip
    1.3 KB · Views: 308

ilan

Expert
Licensed User
Longtime User
Thank you @Informatix , i didnot understood you well that i should use javaobject for that.

I thought i could do it by creating a gradientline with as_texture (color to transparent) and like this get a glowing effect.

So i guess i have to use box2d lights for that. Drawing with canvas get me 9-12 fps.

Thank you
 

Informatix

Expert
Licensed User
Longtime User
Did you try to measure the performance with my lib?
Anyway, the simplest and fastest method to draw things like a laser beam is to draw a texture containing the effect already rendered on a transparent background. You have a complete explanation by following the link given in my guide "How to make games".
 

ilan

Expert
Licensed User
Longtime User
Did you try to measure the performance with my lib?

i am using your FPS code from one of your AS examples.

maybe i will use your advice and create (about 30 small pngs) that got only the glow effect and draw the image behind the line.
i will need to draw each line instead of drawing the whole path like i do know so i hope that the performance wont go down.

btw this is the game i am working on it now and i would like to draw instead of the filled shapes only glowing frames without any filled color in it.


EDIT: this game is using Only Accelerated Surface and Core lib + lots of math

https://www.b4x.com/android/forum/threads/power-blocks-puzzle-game.67933/#post-430681
 
Last edited:

sorex

Expert
Licensed User
Longtime User
@Informatix ,

I'm testing this lib again and notice that it's a lot smoother on my poor 2.3 Samsung Ace phone than it was on my 2.2 Samsung Apolo that didn't seem to have acceleration on board.
Even smoother than in genymotion for some reason.

So I got a wrong impression all these years about being faster etc

What I seem to mis as 'basic function' is a _longClick trigger?
 

sorex

Expert
Licensed User
Longtime User
does that count for _Click aswell?

I mean having both a click & longclick event.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…