DxSetAspectRatioAdjustmentEnabled: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(10 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
{{New feature/item|3.0140|1.3.3|5547| | {{New feature/item|3.0140|1.3.3|5547| | ||
This function | This function allows for the positioning of dxDraw calls to be automatically adjusted according to the client's aspect ratio setting. This lasts for a single execution of an event handler for one of the following events: [[onClientRender]], [[onClientPreRender]] and [[onClientHUDRender]]. So the function has to be called every frame, just like dxDraws. | ||
This is particularly useful for draws that must align with the GTA HUD, for which the sizing and positioning can vary for different aspect ratios. | |||
}} | }} | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool dxSetAspectRatioAdjustmentEnabled ( bool bEnabled [, float | bool dxSetAspectRatioAdjustmentEnabled ( bool bEnabled [, float sourceRatio = 4/3 ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 17: | Line 18: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
{{OptionalArg}} | {{OptionalArg}} | ||
* ''' | * '''sourceRatio :''' This should be set to the aspect ratio the dxDraws were originally designed in. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' when it was changed successfully, or ''false'' otherwise. | Returns ''true'' when it was changed successfully, or ''false'' otherwise. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
addEventHandler("onClientRender",root, | scx,scy = guiGetScreenSize() | ||
addEventHandler( "onClientRender", root, | |||
function() | function() | ||
dxDrawText("Hello", | dxDrawText( "Hello", 300, 300 ) -- Text will be drawn at 300,300 | ||
dxSetAspectRatioAdjustmentEnabled( true ) | dxSetAspectRatioAdjustmentEnabled( true ) | ||
dxDrawText("Goodbye", | dxDrawText( "Goodbye", 0.78*scx, 0.22*scy ) -- Text will be drawn just below HUD money, with any aspect ratio | ||
end | end | ||
) | ) | ||
Line 38: | Line 38: | ||
==See Also== | ==See Also== | ||
{{Drawing_functions}} | {{Drawing_functions}} | ||
[[hu:dxSetAspectRatioAdjustmentEnabled]] |
Latest revision as of 17:12, 7 November 2024
This function allows for the positioning of dxDraw calls to be automatically adjusted according to the client's aspect ratio setting. This lasts for a single execution of an event handler for one of the following events: onClientRender, onClientPreRender and onClientHUDRender. So the function has to be called every frame, just like dxDraws.
This is particularly useful for draws that must align with the GTA HUD, for which the sizing and positioning can vary for different aspect ratios.
Syntax
bool dxSetAspectRatioAdjustmentEnabled ( bool bEnabled [, float sourceRatio = 4/3 ] )
Required Arguments
- bEnabled: Should the adjustment be enabled or disabled.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- sourceRatio : This should be set to the aspect ratio the dxDraws were originally designed in.
Returns
Returns true when it was changed successfully, or false otherwise.
Example
scx,scy = guiGetScreenSize() addEventHandler( "onClientRender", root, function() dxDrawText( "Hello", 300, 300 ) -- Text will be drawn at 300,300 dxSetAspectRatioAdjustmentEnabled( true ) dxDrawText( "Goodbye", 0.78*scx, 0.22*scy ) -- Text will be drawn just below HUD money, with any aspect ratio end )
See Also
- 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