Author Topic: Cheap & dirty image copy command  (Read 3479 times)

Offline Wampus

  • Prof. Inline
  • *****
  • Posts: 1004
    • View Profile
Cheap & dirty image copy command
« on: 2010-Sep-09 »
Sometimes a sprite is much more than is needed!

The sprite related functions of GLBasic are great for most 2D things; wonderful and very powerful. However, sometimes it would be very useful when speed is a necessity to be able to treat simple image copying as purely image copying, a bit like the BLIT command request from this thread: http://www.glbasic.com/forum/index.php?topic=3084.0

The reason I ask is because of this thread: http://www.glbasic.com/forum/index.php?topic=5007.0

In order to create the 2D water ripple effect I used an old 16-bit era technique to draw the background image line by line. On an iPhone screen that's 480 calls of DRAWANIM to fill the screen. Unfortunately DRAWANIM is CPU expensive so I can't use this technique without taking a big FPS hit, making it no good for 60 FPS games.

This is the forth time I've found a reason to draw a big image line by line in order to create certain effects. If there was a crude, cheap but fast way of copying an image I would benefit a lot from that.

Alternatively I could just learn enough C/C++ to do it using INLINE or something like that.

Do you think there is a need for a simpler but faster image copying command?

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
Re: Cheap & dirty image copy command
« Reply #1 on: 2010-Sep-11 »
It would be great as those underpowered apple machines need a lot of optimization.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10711
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Cheap & dirty image copy command
« Reply #2 on: 2010-Sep-14 »
I don't know an OpenGL command to do that. Does anyone else?

MrTAToad

  • Guest
Re: Cheap & dirty image copy command
« Reply #3 on: 2010-Sep-14 »

Offline Cliff3D

  • Dr. Type
  • ****
  • Posts: 268
    • View Profile
Re: Cheap & dirty image copy command
« Reply #4 on: 2010-Sep-14 »
I could load much larger bitmaps into memory and only pass on the parts that need to be displayed.


Regardless of the technique used behind-the-scenes to achieve it, this goal alone is a worthy one IMHO.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10711
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Cheap & dirty image copy command
« Reply #5 on: 2010-Sep-14 »
ah, right. Then it works:
Code: GLBasic [Select]
CREATESCREEN 1, 101, 512, 512
USESCREEN 1
PRINT "Test", 0,0
USESCREEN -1; USESCREEN 1 // do you need these 2 ?? I don't even think so
DRAWSPRITE 101, 10,10 // now draw the current texture INTO the current texture
USESCREEN -1
CLEARSCREEN
DRAWSPRITE 101,0,0
SHOWSCREEN
MOUSEWAIT
AWESOME