dxSetBlendMode | Multi Theft Auto: Wiki Skip to content

dxSetBlendMode

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 sets the current blend mode for the dxDraw functions. Changing the blend mode can increase the quality when drawing text or certain other images to a render target. As a general guide use modulate_add when drawing text to a render target, and add when drawing the render target to the screen. Don't forget to restore the default blend at the end - See the example below.

Syntax

dxSetBlendMode ( )

Code Examples

client

This example shows how to usemodulate_addandaddto avoid quality problems when using a render target:

local myRenderTarget = dxCreateRenderTarget(500, 500, true)
--
-- Function to draw text to our render target texture when the 'r' key is pressed
--
function updateRenderTarget()
dxSetRenderTarget(myRenderTarget, true)
dxSetBlendMode("modulate_add") -- Set 'modulate_add' when drawing stuff on the render target
dxDrawText("Testing "..getTickCount(), 0, 0, 0, 0, tocolor(255, 255, 255, 255), 2, "clear")
dxSetBlendMode("blend") -- Restore default blending
dxSetRenderTarget() -- Restore default render target
end
bindKey("r", "down", updateRenderTarget )
--
-- Display render target contents
--
addEventHandler("onClientRender", root,
function()
dxSetBlendMode("add") -- Set 'add' when drawing the render target on the screen
dxDrawImage(100, 200, 500, 500, myRenderTarget, -10)
dxSetBlendMode("blend") -- Restore default blending
end
)