.:HyPeX:. Posted January 6, 2015 Share Posted January 6, 2015 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") Link to comment
.:HyPeX:. Posted January 6, 2015 Author Share Posted January 6, 2015 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") Link to comment
MisterQuestions Posted January 6, 2015 Share Posted January 6, 2015 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) Link to comment
Gallardo9944 Posted January 6, 2015 Share Posted January 6, 2015 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 Link to comment
MisterQuestions Posted January 6, 2015 Share Posted January 6, 2015 I'll already changed rectangle code, it reads the code up to down, so, if you want something on the front, just put it on last lines . Link to comment
.:HyPeX:. Posted January 6, 2015 Author Share Posted January 6, 2015 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") The fact is i'm already drawing it after the gray rectangle - thats why it makes my mad as it doesnt go on top Link to comment
Gallardo9944 Posted January 6, 2015 Share Posted January 6, 2015 That happens because your dxDrawImage of render target has postGUI argument set to true Link to comment
MisterQuestions Posted January 6, 2015 Share Posted January 6, 2015 ust use code what i gave u?? Link to comment
.:HyPeX:. Posted January 6, 2015 Author Share Posted January 6, 2015 That happens because your dxDrawImage of render target has postGUI argument set to true Oh Lol. Thanks! worked. Link to comment
.:HyPeX:. Posted January 6, 2015 Author Share Posted January 6, 2015 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)) Link to comment
MisterQuestions Posted January 6, 2015 Share Posted January 6, 2015 Ah i got it!, just move rectangle into render target .-. So simple! Link to comment
.:HyPeX:. Posted January 7, 2015 Author Share Posted January 7, 2015 Ah i got it!, just move rectangle into render target .-. 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). Link to comment
Dealman Posted January 7, 2015 Share Posted January 7, 2015 dxSetRenderTarget Read the optional arguments carefully. Link to comment
Et-win Posted January 7, 2015 Share Posted January 7, 2015 https://forum.multitheftauto.com/viewtopic.php?f=91&t=77804 Here an explanation about how this stuff works. Link to comment
Moderators IIYAMA Posted January 7, 2015 Moderators Share Posted January 7, 2015 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now