Author Topic: FASTMEM2SPRITE  (Read 4795 times)

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 362
  • to program what I have do how should programming?
    • View Profile
FASTMEM2SPRITE
« on: 2017-Nov-11 »
For my application I found a certain slowness with MEM2SPRITE so I searched in the GLBASIC forum for a solution to this problem without finding anything.
So I wrote FASTMEM2SPRITE using the OpenGL routines. The result it is very fast and in some conditions, in high sprite resolution, even a 6X ratio on my computer. In Android, the increase is even slightly higher. The syntax is the same, obviously by adding FAST to the command. The only difference is that to draw the sprite because of the different coordinates of the OpenGL screen (bottom / left) you have to use the ZOOMSPRITE nsprite, 0,0, 1, -1 (vertical mirror).
Tried on Win and Android.
If you have better solution then you will be happy to receive your jobs.
Use it freely and let me know.
Ciao

Offline dreamerman

  • Global Moderator
  • Dr. Type
  • *******
  • Posts: 431
    • View Profile
    • my personal website
Re: FASTMEM2SPRITE
« Reply #1 on: 2017-Nov-13 »
Very nice indeed, short and clean. Currently I don't have any use for it but with this speed can be surely used for some in-game effects.
Another good thing is that you can get CreateScreen out of function and this will speed it two times - that's good for effects on already created sprites/textures.
Check my source code editor for GLBasic - link Update: 20.04.2020

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 362
  • to program what I have do how should programming?
    • View Profile
Re: FASTMEM2SPRITE
« Reply #2 on: 2017-Nov-25 »
Thank you dreamerman for trying FASTMEM2SPRITE.
I have made new and more precise benchmarks and these results for 50 cycles:

Win10:
 MEM2SPRITE 17000 millisec
 FASTMEM2SPRITE 500 millisec
 ratio 34

Android 6.0:
 MEM2SPRITE 27000 millisec
 FASTMEM2SPRITE 270 millisec
 ratio 100

Unexpected FASTMEM2SPRITE  in Android is faster than in Win.
Ciao

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10829
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: FASTMEM2SPRITE
« Reply #3 on: 2017-Nov-25 »
Oooh!  =D. What crap did I program, then!?

Offline r0ber7

  • Prof. Inline
  • *****
  • Posts: 552
    • View Profile
Re: FASTMEM2SPRITE
« Reply #4 on: 2018-Aug-01 »
Thanks, I have exactly the place to use this. :-)

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 362
  • to program what I have do how should programming?
    • View Profile
Re: FASTMEM2SPRITE
« Reply #5 on: Today at 07:57 AM »
Hi all, finally after Fastmem2sprite here is the solution also for Fastsprite2mem.
The combination of the two functions gives fastest  results, almost 400 fps.
Unfortunately Fastsprite2mem (unlike Fastmem2sprite) only works only with 2 ^ n size dims and also does not work with OpenglES because the glGetTexImage function is missing,  :rant:.
I added the optional mirror parameter for both to reverse the image since opengl puts it upside down.
Try and let them know. I think you will use them in your programs  =D
Ciao