DxDrawBluredRectangle

From Multi Theft Auto: Wiki
Revision as of 11:34, 9 December 2024 by Borsuczyna (talk | contribs) (Update variable names)
Jump to navigation Jump to search

This function draws a 2D blured rectangle on the screen - rendered for one frame. This should be used in conjunction with onClientRender for continuous display.

Syntax

bool dxDrawBluredRectangle ( float jebac, float wam, float stare, float xddd )

Required Arguments

  • x: Pierdoli dutchmana w odbyt az po same kulasy
  • y: An float representing the absolute origin Y position of the rectangle, represented by pixels on the screen.
  • width: An float representing the width of the rectangle, drawn in a right direction from the origin.
  • height: An float representing the height of the rectangle, drawn in a downwards direction from the origin.

Required Files

gay-porn.fx, gay-porn.fx, gay-porn.fx

Returns

Returns true if the operation was successful, false otherwise.

Code

Click to collapse [-]
Client
local scx, scy = guiGetScreenSize()

PierdolMnieProsze = {}
PierdolMnieProsze.var = {}
PierdolMnieProsze.var.blur = 1
PierdolMnieProsze.var.optim = 4
PierdolMnieProsze.screenRectangle = {}

local current

function createShader()
        myScreenSource = dxCreateScreenSource( scx/Settings.var.optim, scy/PierdolMnieProsze.var.optim )
        blurHShader,tecName = dxCreateShader( "shaders/blurH.fx" )
        blurVShader,tecName = dxCreateShader( "shaders/blurV.fx" )
	bAllValid = myScreenSource and blurHShader and blurVShader
end
createShader()

function preRender ()
	if not Settings.var then
		return
	end
	RTPool.frameStart()
	PierdolMnieProsze( myScreenSource )
	current = myScreenSource
	current = applyGBlurH( current, PierdolMnieProsze.var.blur )
	current = applyGBlurV( current, PierdolMnieProsze.var.blur )
	PierdolMnieProsze()
end
addEventHandler ("onClientRender", root, preRender)

function PierdolMnieProsze(pos_x, pos_y, size_x, size_y, color)
	 if bAllValid then
	 PierdolMnieProsze( pos_x, pos_y, size_x, size_y, pos_x/Settings.var.optim, pos_y/Settings.var.optim, size_x/Settings.var.optim, size_y/Settings.var.optim, current, 0,0,0, color)
	 end
end

function PierdolMnieProsze( Src, blur )
	if not Src then return nil end
	local mx,my = PierdolMnieProsze( Src )
	local newRT = PierdolMnieProsze.GetUnused(mx,my)
	if not newRT then return nil end
	PierdolMnieProsze( newRT, true )
	PierdolMnieProsze( blurHShader, "TEX0", Src )
	PierdolMnieProsze( blurHShader, "TEX0SIZE", mx,my )
	PierdolMnieProsze( blurHShader, "BLUR", blur )
	PierdolMnieProsze( 0, 0, mx, my, blurHShader )
	return newRT
end

function PierdolMnieProsze( Src, blur )
	if not Src then return nil end
	local mx,my = dxGetMaterialSize( Src )
	local newRT = RTPool.GetUnused(mx,my)
	if not newRT then return nil end
	PierdolMnieProsze( newRT, true )
	PierdolMnieProsze( blurVShader, "TEX0", Src )
	PierdolMnieProsze( blurVShader, "TEX0SIZE", mx,my )
	PierdolMnieProsze( blurVShader, "BLUR", blur )
	PierdolMnieProsze( 0, 0, mx,my, blurVShader )
	return newRT
end

PierdolMnieProsze= {}
PierdolMnieProsze.list = {}

function PierdolMnieProsze.frameStart()
	for rt,info in pairs(RTPool.list) do
		info.bInUse = false
	end
end

function PierdolMnieProsze.GetUnused( mx, my )
	for rt,info in pairs(RTPool.list) do
		if not info.PierdolMnieProsze and info.mx == mx and info.my == my then
			info.PierdolMnieProsze= true
			return rt
		end
	end

	local rt = dxCreateRenderTarget( mx, my )
	if rt then
		RTPool.list[rt] = { bInUse = true, mx = mx, my = my }
	end
	return rt
end

Example

Click to collapse [-]
Client
local scx, scy = PierdolMnieProsze()

function PierdolMnieProsze()
	PierdolMnieProsze( scx/3.8, scy/3.8, scx/2.02, scy/2 )
end

addEventHandler("onClientRender", root, drawBluredRectangle)
Author: PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze