DxCreateShader: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element dxCreateShader ( string filepath )
element, string dxCreateShader ( string filepath )
</syntaxhighlight>  
</syntaxhighlight>  


Line 15: Line 15:


===Returns===
===Returns===
Returns a [[shader]] element if successful, ''false'' if invalid arguments were passed to the function.
*'''element:''' A [[shader]] element if successful, ''false'' if invalid arguments were passed to the function.
*'''string:''' The name of the technique that will be used.


==Example==  
==Example==  

Revision as of 12:05, 13 June 2011

Only available in 1.1 This function creates a shader element that can be used in the dxDraw functions.

Syntax

element, string dxCreateShader ( string filepath )

Required Arguments

  • filepath: The filepath of the shader .fx file

Returns

  • element: A shader element if successful, false if invalid arguments were passed to the function.
  • string: The name of the technique that will be used.

Example

addEventHandler( "onClientRender", root,
    function()
        if myShader then
            dxDrawImage( 100, 350, 300, 350, myShader )
        end
    end
)

-- Use 'toggle' command to switch shader on and off
addCommandHandler( "toggle",
    function()
        if not myShader then
            myShader = dxCreateShader( "fancything.fx" )  -- Create shader
        else        
            destroyElement( myShader )                    -- Destroy shader
            myShader = nil
        end
    end
)

See Also