HU/dxCreateRenderTarget: Difference between revisions
No edit summary |
No edit summary |
||
Line 76: | Line 76: | ||
[[en:dxCreateRenderTarget]] | [[en:dxCreateRenderTarget]] | ||
==Fordította== | |||
* '''''[https://wiki.multitheftauto.com/wiki/User:Surge Surge]''''' |
Revision as of 14:56, 14 October 2018
This function creates a render target element, which is a special type of texture that can be drawn on with the dx functions. Successful render target creation is not guaranteed, and may fail due to hardware or memory limitations.
Használja a dxGetStatus-t a hibák megtalálásához. (Ha a VideoMemoryFreeForMTA nulla, akkor a hiba garantált.)
Tipp: Használja a dxSetBlendMode hogy jobb minőséget kapjon |
Tipp: Nagyon ajánlott a dxSetTestMode használata, amikor a dxCreateRenderTarget-t használva írunk és tesztelünk scripteket. |
Megjegyzés: Render targets are usually cleared when the player minimizes MTA (i.e. alt-tab). See onClientRestore for details on when to restore any fixed content. |
Szintaxis
element dxCreateRenderTarget ( int width, int height [, bool withAlpha = false ] )
OOP Syntax Help! I don't understand this!
- Method: DxRenderTarget(...)
Kötelező paraméterek
- width : The width of the texture in pixels.
- height : The height of the texture in pixels.
- withAlpha: The render target will be created with an alpha channel. 'false' will turn images' alpha channels to black color
Visszatérési érték
Returns a texture element if successful, false if the system is unable to create a render target.
You should always check to see if this function has returned false.
Magyarázat
What is a rendertarget? A rendertarget is like a big, white paper(or if you set alpha to true, it will be a transparent paper) that you can draw on, after you drawn on it, you can draw it as many times as you like, without impacting performance. It could be used for dashboard, where a few hundred dxDraw* functions are called, so, instead of calling these every frame, you can just draw it on a render target, and draw the render target, instead of every information one by one.
Példa
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 ) -- Start drawing on myRenderTarget dxDrawText ( "Hello", 10, 20 ) -- Draw a message dxSetRenderTarget() -- Stop drawing on myRenderTarget dxDrawImage( 50, 50, 100, 100, myRenderTarget ) -- Now use myRenderTarget as a material and draw it lots of times dxDrawImage( 150, 350, 150, 100, myRenderTarget ) dxDrawImage( 250, 250, 100, 150, myRenderTarget ) dxDrawImage( 350, 30, 150, 150, myRenderTarget ) end end ) local myRenderTarget = dxCreateRenderTarget(500, 500, true) -- -- Function to draw text to our render target with '''modulate_add''' blend mode 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 )
Lásd még
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsSize
- dxGetPixelsFormat
- dxGetStatus
- dxGetTextSize
- dxGetTextWidth
- dxGetTexturePixels
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderValue
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource