Calculating exact VRAM size of image...

Blitz3D Forums/Blitz3D Programming/Calculating exact VRAM size of image...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

It'll likely vary between GPU hardwares as well. I doubt there's a formula for calculating VRAM usage. However if you go with with (Nearest ^2 to fit width)*(nearest ^2 to fit height)*4 you should get a worst-case scenario that works for all cards. Using ^2 sized textures/images is a lot more efficient for some hardwares and is needed for fastest texture scaling too. I've taken to using square textures like 128x128 or 256x256 and for smaller irregular size images crop to the appropriate size by resizing the texture UVs. eg. A 54x38 button image will be saved as a 64x64 .png, applied to a relative 54:38 sprite, and the texture coords stretched to show only the 54x38 pixels of the texture. This ensures fastest results on all hardwares.