M MY Multiplayer: Wiki
Side
Kind

dxCreateRenderTarget

Client

Creates a render target: an image the dx functions can draw into and that can be used like any other image.

texture|false dxCreateRenderTarget(int width, height [, bool|string withAlpha = false])

Parameters

NameTypeDescription
width, heightintSize in pixels, from 1 to 16384. A vec2 also works.
withAlphabool|stringKeep the alpha channel. Also takes the name of an MTA surface format (a8r8g8b8, x8r8g8b8, r5g6b5...): those with a keep alpha, the others do not.default false

Returns

The render target, or false when the size is outside 1 to 16384, there is no free video memory or the format is not supported.

Example

local canvas = dxCreateRenderTarget(256, 64, true)

addEventHandler("onClientRender", root, function()
    dxSetRenderTarget(canvas, true)
    dxDrawText("Placar: 3 x 1", 0, 0, 256, 64, tocolor(255, 255, 255), 2, "default", "center", "center")
    dxSetRenderTarget()
    dxDrawImage(20, 20, 256, 64, canvas)
end)
NoteA format name MYMP does not know (such as the depth formats) logs a warning and returns false.

See also