DxSetRenderTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 18: Line 18:


==Usage restrictions==
==Usage restrictions==
*Items drawn with ''postGUI'' set to ''true'' will not appear on a custom render target.
{{Deprecated feature|3.0139|1.3.0-9.04433|
*dxSetRenderTarget can only be called during the [[onClientRender]], [[onClientHUDRender]] and [[onClientRestore]] events.
*dxSetRenderTarget can only be called during the [[onClientRender]], [[onClientHUDRender]] and [[onClientRestore]] events.
*Items drawn with ''postGUI'' set to ''true'' will not appear on a custom render target.
}}


==Example==  
==Example==  
Line 41: Line 43:
)
)
</syntaxhighlight>
</syntaxhighlight>
==Changelog==
{{ChangelogHeader}}
{{ChangelogItem|1.3.0-9.04433|Removed restrictions on when dxSetRenderTarget could be called}}


==See Also==
==See Also==
{{Drawing_functions}}
{{Drawing_functions}}

Revision as of 23:35, 19 December 2012

This function changes the drawing destination for the dx functions. It can be used to select a previously created render target, or if called with no arguments, restore drawing directly to the screen.

Syntax

bool dxSetRenderTarget ( [ element renderTarget, bool clear = false ] )

If no arguments are supplied, the screen is restored as the drawing destination.

Optional Arguments

  • renderTarget: The render target element whose pixels we want to draw on.
  • clear: If set to true, the render target will also be cleared.

Returns

Returns true if the render target was successfully changed, false otherwise.

Usage restrictions

  • Items drawn with postGUI set to true will not appear on a custom render target.

Example

addEventHandler("onClientResourceStart", resourceRoot,
    function()
        myRenderTarget = dxCreateRenderTarget( 80, 100 )  -- Create a render target texture which is 80 x 100 pixels
    end
)

addEventHandler( "onClientRender", root,
    function()
        if myRenderTarget then
            dxSetRenderTarget( myRenderTarget )  -- Select custom render target
            dxDrawText ( "Hello", 10, 20 )       -- The message 'Hello' will be drawn on myRenderTarget

            dxSetRenderTarget()                  -- Select default render target
            dxDrawText ( "Goodbye", 10, 20 )     -- The message 'Goodbye' will be drawn directly to the screen
        end
    end
)


Changelog

Version Description
1.3.0-9.04433 Removed restrictions on when dxSetRenderTarget could be called

See Also