draw_texture_flush

Clears all textures from texture memory.

Syntax:

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:

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.


Back: Drawing
Next: draw_enable_drawevent
© Copyright YoYo Games Ltd. 2015 All Rights Reserved