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.

DarkBASIC Professional Discussion / Animation frames from 1 image to texture?

Author
Message
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 20th Aug 2011 18:14
Is is possible to have create animated sprite command for textures? I need different menu backgrounds for a handheld device in game, and would be very simple to have all those screen menu backgrounds layed on top of each other in one image, rather than loading 10 images for every background...
The exact way how animated sprites work in DB.

I'm looking for simple way that would be more convenient than separately loading every image... No need for transparency, but able to choose 1 frame at a time.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Aug 2011 18:47
You could load all the backgrounds on one image as a bitmap and grab the current image you want as you need it then texture the object.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st Aug 2011 04:18
Grabbing images used to be slow, maybe it is faster now. I don't see the problem with just loading the images instead.

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 21st Aug 2011 04:37
Theres no problem using get image with DB these days, It's pretty fast as long as you don't go mad. I think he may mean in the loading stages rather than on the fly, as in loading one image and cutting into many. There is no automated way to do this, as in create animated sprite. However it is very simple to grab the images manually in a loop rather than loading them separately and applying them as the current texture for your object.

http://s6.bitefight.org/c.php?uid=103081
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st Aug 2011 15:51 Edited at: 21st Aug 2011 15:57
I think he means background screens, and then swapping the screens around as textures. I get the impression that the poster thinks you have to load each screen when you swap them. But of course you can load them as images, and then texture them. That misses out grabbing them. I just seems strange to me to make something more complicated, and slower.

TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 21st Aug 2011 16:14 Edited at: 21st Aug 2011 16:16
I was thinking about the FPS performance while using bitmaps, but the background shouldn't be used in loop so it should be fine.

I'm using bitmaps now for the first time, I managed to get it work like animated sprite, but as I'm printing text in loop on bitmap it drops my framerate from 400 to 80.
Even without loading the background!


I wonder why this is so slow when looped... I need to have this reading done atleast every second.
When reduced to be done only once in second, it drops on average only about -20 FPS and twitches when updated...

Btw. is it possible to load the backgrounf bitmap only once, and then update the reading on top of the background bitmap without loading it again?
I need to have the background image and then the reading on top of it and then texture it to 3D object.

This is what I'm getting now, but I need to load the background bitmap every second...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st Aug 2011 19:30 Edited at: 21st Aug 2011 19:35
If you want text that moves in 3D then make the clock into 3D rectangular limbs. Then texture those instead. Load everything as images. You will need 9 numbers, and zero, then use those to texture the limbs.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Aug 2011 21:30
You can load the bitmap into bitmap 1 at the start, and then copy it to bitmap 0 (the screen) each frame. Make sure to use "set current bitmap 0" after loading in bitmap 1 though.

[b]
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 21st Aug 2011 22:30 Edited at: 21st Aug 2011 22:34
Quote: "If you want text that moves in 3D then make the clock into 3D rectangular limbs. Then texture those instead. Load everything as images. You will need 9 numbers, and zero, then use those to texture the limbs."

That's a cool idea, but I think it would get complicated to use the screen with variables. And I'd have to load all 10 numbers individually. It isn't a big problem, but I wonder why it can't be done like the sprites.

Quote: "You can load the bitmap into bitmap 1 at the start, and then copy it to bitmap 0 (the screen) each frame. Make sure to use "set current bitmap 0" after loading in bitmap 1 though."

Nice, I was able to get 20fps increase with that. Doesn't explain why fps drops from 450 to 60 when I loop this:



For some reason printing text and getting the 128x86 image is crazy heavy. It works 450fps when done 1 time per second though.
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 21st Aug 2011 23:11 Edited at: 21st Aug 2011 23:13
I'm not entirely sure what you are trying to do with the above code. if all you want is a backdrop to a screen with text, sprites etc, just do as Diggsey suggested. Heres the basic structure (not actual code just an example).

Load in your bitmap into bitmap 1.
set current bitmap 0
do
Copy bitmap 1 to 0
Display text etc.
sync
loop

Anything displayed on screen is using bitmap 0, so copying bitmap 1 at the start of your loop into 0 will act like a screen cls, enabling you to put text and whatever else you want on top. The next loop it will refresh the backdrop and reposition the text. Rinse and repeat.
If you are using a 3D plane rather than just a bitmap simply use get image and texture the plane with the image instead.
I noticed in some code above you were loading bitmaps in on the fly, never do that if you want any sort of speed Always load in at the start and grab from memory.
Text is slow on DB. Although it seems faster now than it was awhile back. But unless you are printing a lot or changing a lot of ink colours, it shouldn't slow it THAT much.

http://s6.bitefight.org/c.php?uid=103081
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 21st Aug 2011 23:24 Edited at: 21st Aug 2011 23:25
Quote: "If you are using a 3D plane rather than just a bitmap simply use get image and texture the plane with the image instead."

This is what I'm doing(image above) and it works fine now, I just wonder why getting image from bitmap in loop is so slow...
As you can see in the last post, I changed it to copying instead of loading like Diggsey suggested.
It works fine and fast when I do it only 1 time in a second though.

Thanks for the help!

Login to post a reply

Server time is: 2026-07-10 20:58:37
Your offset time is: 2026-07-10 20:58:37