draw_texture_flush

Clears all textures from texture memory.

Syntax:

GML Code Example

draw_texture_flush();


Returns: N/A


Description

With this function you can remove all textures from video memory, and they will then be reloaded on first use. This is the only effective way to manage video memory when you have multiple texture pages for a game, and you should flush the texture memory between levels on your game and organise the graphics using the texture group feature to ensure that the minimum number of textures are used.

It is worth noting that this function works on all target platforms except for Windows (YYC and standard), since the Directx graphics pipeline handles things differently, meaning that all textures will always be loaded into memory on start-up for these targets. If you are making a cross platform game, then you can leave this function in your code for the Windows target as it will not give any error, but rather silently fail.

NOTE: There is a performance hit as the texture is uploaded to texture memory on most devices, so the best idea is to do a dummy render of the required graphics at the start of a level to avoid any stalls. You would only need to render a single graphic from each texture page to ensure that texture is loaded, and you should be aware that texture groups can have more than one texture page which means that each load will cause a stall.


Example:

GML Code Example

draw_texture_flush();
 

The above code flushes the video memory of texture data, and would probably be placed in the create event of the first instance of an object placed in the room.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here