Share your ZGE-development tips and techniques here!
Moderator: Moderators
-
Kjell
- Posts: 1734
- Joined: Sat Feb 23, 2008 11:15 pm
Post
by Kjell » Sat May 07, 2016 8:45 am
In case you're using a lot of imported images, attached is a example that swaps out the data of a imported Bitmap at run-time ( to ensure that only 1 texture resides on the GPU at once ) .. press 1 or 2 on your keyboard to load a image.
K
-
Attachments
-
- Hot-swap.zgeproj
- (188.95 KiB) Downloaded 454 times
-
Rado1
- Posts: 773
- Joined: Wed May 05, 2010 12:16 pm
Post
by Rado1 » Sat May 07, 2016 6:55 pm
Nice trick to use files in this way. But are not embedded files loaded to memory as well? People would maybe appreciate runtime loading of bitmap files from file system.
-
Kjell
- Posts: 1734
- Joined: Sat Feb 23, 2008 11:15 pm
Post
by Kjell » Sat May 07, 2016 7:04 pm
Hi Rado1,
Rado1 wrote:But are not files loaded to memory as well?
The only thing that this method does is recycle the memory allocated for a texture on the GPU.
So if you'd for instance have a slideshow of 20 Bitmaps ( 512x288 ) by simply swapping MaterialTexture.Texture .. it would use 0.6MB of GPU RAM when the slideshow starts, 1.2MB after the 2nd image has been shown and 11MB once all images have been shown. Whereas using this technique you're always using only 0.6MB.
Rado1 wrote:People would maybe appreciate runtime loading of bitmap files from file system.
Sure, you don't have to embed the file if you don't want to
K
-
Lupo
- Posts: 76
- Joined: Wed Sep 09, 2009 6:21 pm
- Location: Montevideo, Uruguay
Post
by Lupo » Wed Jul 22, 2020 4:30 pm
Hi,
Thanks for the example.
Would it be easy to load the bitmaps from an external file instead of embedded?
Close, but not there yet.
-
Kjell
- Posts: 1734
- Joined: Sat Feb 23, 2008 11:15 pm
Post
by Kjell » Thu Jul 23, 2020 9:51 am
Hi Lupo,
Lupo wrote: ↑Wed Jul 22, 2020 4:30 pm
Would it be easy to load the bitmaps from an external file instead of embedded?
The principle is easy .. but since ZGE doesn't have any image decoders built-in ( aside from a JPG subset ) it really depends on the image format(s) that you want to support whether or not it's easy.
K
-
Lupo
- Posts: 76
- Joined: Wed Sep 09, 2009 6:21 pm
- Location: Montevideo, Uruguay
Post
by Lupo » Mon Jul 27, 2020 1:05 am
Thanks for the answer.
I can remember the nano-jpeg embedded... I found the example project.
Thanks,
Luis.
Close, but not there yet.