dxCreateTexture | Multi Theft Auto: Wiki Skip to content

dxCreateTexture

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function creates a texture element that can be used in the dxDraw functions.

Note

The times shown at the right of the page are only the time needed to add the thing to the draw queue, its not the actual time it takes to draw them.

Tip

It is recommended to pre-convert textures to whatever format you want to load them as. ARGB should be PNG, all other formats are self explanatory. By doing this you can load textures on the fly without any hickups (Note: There might still be some if the user has a slow HHD). See DirectXTex texconv tool .

Important

This function uses significant process RAM, make sure you don't load a lot of textures, because you'll run out of memory and crash MTA on your gaming PC beyond the technical limit of 3.5 GB (weak PC users much earlier). Besides that, don't make the common mistake of causing a memory leak by not destroying textures (causing dxTextures to pile up) when they should no longer display per your script, which causes FPS lag and crashes all over MTA due to so many scripters missing it

Syntax

dxCreateTexture ( )

Code Examples

client
addEventHandler( "onClientRender", root,
function()
if myImage then
dxDrawImage( 100, 350, 300, 350, myImage )
end
end
)
-- Use 'toggle' command to switch image on and off
addCommandHandler( "toggle",
function()
if not myImage then
myImage = dxCreateTexture( "moonpig.png" ) -- Create texture
else
destroyElement( myImage ) -- Destroy texture
myImage = nil
end
end
)