Jump to content

[Help] Render Target


.:HyPeX:.

Recommended Posts

Posted

Well, the rectangle is somehow being drawn outside the render target... is there a way to make anything outside the render target to be cut off?

  
local x,y = guiGetScreenSize() 
local screen = dxCreateRenderTarget(x*0.33,y*0.32,true) 
  
local start = getTickCount() 
addEventHandler('onClientRender',root,function() 
dxSetRenderTarget(screen) 
local ax,ay = x*0.33,y*0.32 
local fx,fy = x*0.373,y*0.36 
outputChatBox(ax*0.2 + fx.." "..fx) 
local now = getTickCount() 
if now - start > 3000 then 
start = getTickCount() 
end 
local elapsed = now - start 
local progress = elapsed / 3000 
local sx = interpolateBetween(-ax*0.2, 0,0,ax*0.2,0,0,progress,"Linear") 
dxDrawRectangle(sx+fx, ay*0.5+fy, ax*0.2,ay*0.05,tocolor(0,0,0,255),true) 
--dxDrawRectangle(0, 0, ax, ay,tocolor(100,100,100,255)) 
dxSetRenderTarget() 
dxDrawImage(x*0.373,y*0.36,x*0.33,y*0.32,screen,0,0,0,tocolor(255,255,255,255),true) 
dxDrawRectangle(x*0.373,y*0.33, x*0.33, y*0.029,tocolor(50,50,50,255)) 
end,true,"high+6")  

TrBfHNv.jpg

Posted

And another issue: I cant make by any means make the black rectangle be drawn on top..

  
local x,y = guiGetScreenSize() 
local screen = dxCreateRenderTarget(x*0.33,y*0.32,true) 
  
local start = getTickCount() 
addEventHandler('onClientRender',root,function() 
dxSetRenderTarget(screen) 
local ax,ay = x*0.33,y*0.32 
local fx,fy = x*0.373,y*0.36 
local now = getTickCount() 
if now - start > 3000 then 
start = getTickCount() 
end 
local elapsed = now - start 
local progress = elapsed / 3000 
local sx = interpolateBetween(0, 0,0,ax*0.2,0,0,progress,"Linear") 
dxDrawRectangle(0, 0, ax, ay,tocolor(100,100,100,180)) 
dxDrawRectangle(ax*0.2+fx, ay*0.5+fy, ax*0.2,ay*0.05,tocolor(0,0,0,255),true) 
  
  
dxSetRenderTarget() 
dxDrawImage(x*0.373,y*0.36,x*0.33,y*0.32,screen,0,0,0,tocolor(255,255,255,255),true) 
dxDrawRectangle(x*0.373,y*0.33, x*0.33, y*0.029,tocolor(50,50,50,255)) 
end,true,"high+6") 

XELJQRp.png

Posted

Put the code of the black rectangle down all script stull, like this

  
local x,y = guiGetScreenSize() 
local screen = dxCreateRenderTarget(x*0.33,y*0.32,true) 
  
local start = getTickCount() 
addEventHandler('onClientRender',root,function() 
dxSetRenderTarget(screen) 
local ax,ay = x*0.33,y*0.32 
local fx,fy = x*0.373,y*0.36 
local now = getTickCount() 
if now - start > 3000 then 
start = getTickCount() 
end 
local elapsed = now - start 
local progress = elapsed / 3000 
local sx = interpolateBetween(0, 0,0,ax*0.2,0,0,progress,"Linear") 
dxDrawRectangle(0, 0, ax, ay,tocolor(100,100,100,180)) 
  
  
dxSetRenderTarget() 
dxDrawImage(x*0.373,y*0.36,x*0.33,y*0.32,screen,0,0,0,tocolor(255,255,255,255),true) 
dxDrawRectangle(x*0.373,y*0.33, x*0.33, y*0.029,tocolor(50,50,50,255)) 
end,true,"high+6") 
dxDrawRectangle(ax*0.2+fx, ay*0.5+fy, ax*0.2,ay*0.05,tocolor(0,0,0,255),true) 
  

Posted

If you want to put the rectangle in the render target, put it before line 21 in your code (2nd message). If you want it ontop:

1. If it's inside the target: draw it after all other drawing parts

2. If it's outside of the target: draw it after you draw the render target

Posted
And another issue: I cant make by any means make the black rectangle be drawn on top..
  
local x,y = guiGetScreenSize() 
local screen = dxCreateRenderTarget(x*0.33,y*0.32,true) 
  
local start = getTickCount() 
addEventHandler('onClientRender',root,function() 
dxSetRenderTarget(screen) 
local ax,ay = x*0.33,y*0.32 
local fx,fy = x*0.373,y*0.36 
local now = getTickCount() 
if now - start > 3000 then 
start = getTickCount() 
end 
local elapsed = now - start 
local progress = elapsed / 3000 
local sx = interpolateBetween(0, 0,0,ax*0.2,0,0,progress,"Linear") 
dxDrawRectangle(0, 0, ax, ay,tocolor(100,100,100,180)) 
dxDrawRectangle(ax*0.2+fx, ay*0.5+fy, ax*0.2,ay*0.05,tocolor(0,0,0,255),true) 
  
  
dxSetRenderTarget() 
dxDrawImage(x*0.373,y*0.36,x*0.33,y*0.32,screen,0,0,0,tocolor(255,255,255,255),true) 
dxDrawRectangle(x*0.373,y*0.33, x*0.33, y*0.029,tocolor(50,50,50,255)) 
end,true,"high+6") 

XELJQRp.png

The fact is i'm already drawing it after the gray rectangle - thats why it makes my mad as it doesnt go on top

Posted

Now, my first question, how can i make the draw only draw the exact box made by the render taget?

  
dxSetRenderTarget(screen) 
local ax,ay = x*0.33,y*0.32 
local fx,fy = x*0.373,y*0.36 
local now = getTickCount() 
if now - start > 3000 then 
start = getTickCount() 
end 
local elapsed = now - start 
local progress = elapsed / 3000 
local sx = interpolateBetween(0, 0,0,ax*0.2,0,0,progress,"Linear") 
dxDrawRectangle(0, 0, ax, ay,tocolor(100,100,100,180)) 
dxDrawRectangle(-50+fx, ay*0.5+fy, ax*0.2,ay*0.05,tocolor(0,0,0,255),true) 
  
  
dxSetRenderTarget() 
dxDrawImage(x*0.373,y*0.36,x*0.33,y*0.32,screen,0,0,0,tocolor(255,255,255,255)) 
  

W7ujbAV.jpg

Posted
Ah i got it!, just move rectangle into render target .-. xD So simple!

Jeez, i'm not an idiot if i'm using already render targets, my fact is, i want the render target to cut anything outside itself. (i.e. the part of the rectangle wich is not inside).

  • Moderators
Posted

2 ways.

- Get the pixels of the render target and get only the pixels you want. (you better not render the whole process this every frame unless you have a powerful gpu)

https://wiki.multitheftauto.com/wiki/DxGetTexturePixels

https://wiki.multitheftauto.com/wiki/DxGetPixelColor

https://wiki.multitheftauto.com/wiki/DxCreateTexture

https://wiki.multitheftauto.com/wiki/DxSetPixelColor

https://wiki.multitheftauto.com/wiki/DxSetTexturePixels

- Or render it with: (so you can cut your image like you want)

https://wiki.multitheftauto.com/wiki/DxDrawImageSection

The benefit of the first way is that you will render at a lower resolution, which can keep up the performance.

The benefit of the second way is that you can update it every frame, but I still do not recommend full resolution.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...