.:HyPeX:. Posted January 6, 2015 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") My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
.:HyPeX:. Posted January 6, 2015 Author 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") My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
MisterQuestions Posted January 6, 2015 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) "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
Gallardo9944 Posted January 6, 2015 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 Code Debugger - Minimalistic MTA debug line replacement
MisterQuestions Posted January 6, 2015 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 . "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
.:HyPeX:. Posted January 6, 2015 Author 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 My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Gallardo9944 Posted January 6, 2015 Posted January 6, 2015 That happens because your dxDrawImage of render target has postGUI argument set to true Code Debugger - Minimalistic MTA debug line replacement
MisterQuestions Posted January 6, 2015 Posted January 6, 2015 ust use code what i gave u?? "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
.:HyPeX:. Posted January 6, 2015 Author Posted January 6, 2015 That happens because your dxDrawImage of render target has postGUI argument set to true Oh Lol. Thanks! worked. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
.:HyPeX:. Posted January 6, 2015 Author 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)) My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
MisterQuestions Posted January 6, 2015 Posted January 6, 2015 Ah i got it!, just move rectangle into render target .-. So simple! "El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más". Att: -|TG|-Mister[Q]<.
.:HyPeX:. Posted January 7, 2015 Author 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). My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Dealman Posted January 7, 2015 Posted January 7, 2015 dxSetRenderTarget Read the optional arguments carefully. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Et-win Posted January 7, 2015 Posted January 7, 2015 https://forum.multitheftauto.com/viewtopic.php?f=91&t=77804 Here an explanation about how this stuff works. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Moderators IIYAMA Posted January 7, 2015 Moderators 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. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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