Tonyx97 Posted February 24, 2015 Posted February 24, 2015 Hi guys, I need a solution for this problem, I'll show you a image where you can see the issue explained better than If I text it. http://gyazo.com/6f5ee8b58f530b252a685c9957ecf8f6 Thanks for read.
Callum Posted February 24, 2015 Posted February 24, 2015 I don't think that's possible, at least by exclusively using the dxDraw functions.
Tonyx97 Posted February 24, 2015 Author Posted February 24, 2015 Yes, it's I saw it in a script but I want to re-script it to my way, I don't find exactly the part of the code...
Addlibs Posted February 24, 2015 Posted February 24, 2015 (edited) You could use dxDrawImageSection with dxCreateScreenSource and dxUpdateScreenSource Edited February 24, 2015 by Guest
JR10 Posted February 24, 2015 Posted February 24, 2015 You could use dxDrawImageSection with dxCreateScreenSource and dxUpdateScreenSource Shouldn't that be render target? Since he wants to draw a section of a dx text, not a section of the screen.
Addlibs Posted February 24, 2015 Posted February 24, 2015 Can be done with a render target (by drawing a bit outside it) or overlapped by a screen source.. No idea which one is more efficient
JR10 Posted February 24, 2015 Posted February 24, 2015 You don't need a screen source at all. A render target will do just fine. Create the target once (not on render), set it as the target on render, draw the text to it, reset the target and then draw the render target with dxDrawImageSection.
Tonyx97 Posted February 24, 2015 Author Posted February 24, 2015 I tried your steps JR but I didn't get it... in this image http://gyazo.com/13bf30d452c051438817a2919bbf94c2 I put the box over the text like I want, when I change the dxCreateRenderTarget alpha to true the text is still shown. Here the little code: target = dxCreateRenderTarget ( 100, 100, false ) function onClientRendere () dxSetRenderTarget (target, true) dxDrawText ( "TEEEEEEEEEEEEEST", 500, 550, 500, 500, tocolor(255,255,255,255), 2, "sans", "left", "center", false, false, true, false ) dxSetRenderTarget() dxSetBlendMode("modulate_add") dxDrawImageSection(650, 500, 50, 50, 0, 0, 50, 50, target, 0, 0, 0, tocolor(255,255,255,255), true) dxSetBlendMode("blend") end addEventHandler ("onClientRender", getRootElement(), onClientRendere)
Et-win Posted February 24, 2015 Posted February 24, 2015 Use dxDrawImage instead of dxDrawImageSection
JR10 Posted February 24, 2015 Posted February 24, 2015 You're using the full width and height in dxDrawImageSection that's why it's drawing the full text, try this: target = dxCreateRenderTarget ( 100, 100, false ) function onClientRendere () dxSetRenderTarget (target, true) dxSetBlendMode("modulate_add") dxDrawText ( "TEEEEEEEEEEEEEST", 500, 550, 500, 500, tocolor(255,255,255,255), 2, "sans", "left", "center", false, false, true, false ) dxSetRenderTarget() dxSetBlendMode("add") dxDrawImageSection(650, 500, 50, 50, 0, 0, 50, 25, target, 0, 0, 0, tocolor(255,255,255,255), true) dxSetBlendMode("blend") end addEventHandler ("onClientRender", getRootElement(), onClientRendere)
Tonyx97 Posted February 24, 2015 Author Posted February 24, 2015 I still can see the full text when I put alpha if render target on true. I don't know anything about this dx mechanic, so I don't have any conclusions about this issue...
JR10 Posted February 25, 2015 Posted February 25, 2015 After experimenting with it, I figured it out. For some reason, the postGUI parameter in dxDrawText causes the text to be drawn to the screen and not the render target. I also tweaked dxDrawImageSection to achieve the effect you want. Here's the code: target = dxCreateRenderTarget ( 500, 500, true ) function onClientRendere () if (target) then dxSetRenderTarget (target, true) dxSetBlendMode("modulate_add") dxDrawText ( "TEEEEEEEEEEEEEST", 0, 0, 500, 100, tocolor(255,255,255,255), 2, "sans", "left", "top", false, false, false, false ) dxSetRenderTarget() dxSetBlendMode("add") dxDrawImage(500, 200, 500, 500, target); --Draw the full render target to check the diff, you can remove this after testing dxDrawImageSection(500, 100, 500, 15, 0, 0, 500, 15, target, 0, 0, 0, tocolor(255,255,255,255), true) dxSetBlendMode("blend") end end addEventHandler ("onClientRender", getRootElement(), onClientRendere) Here's an image:
Et-win Posted February 25, 2015 Posted February 25, 2015 This is how I do it: sWidth, sHeight = guiGetScreenSize() --Get the screen sizes X and Y X, Y = 150, 16 --Create a variable presenting the X and Y sizes cTarget = dxCreateRenderTarget(X, Y, true) --Create a render target (box) where the text should be drawn in function testFunction() if (cTarget ~= false) and (cTarget ~= nil) then dxSetRenderTarget(cTarget, true) --Set the render target to cTarget so we are going to draw in that box dxSetBlendMode("modulate_add") --Set the blend mode to "modulate_add" dxDrawText("This is a test message", 0, -20, X, Y, tocolor(0, 255, 0, 255), 1, "sans", "center", "center", true, false, false) --Create a text in the render target. Lets cut the text in half by setting the position to -20 dxSetBlendMode("blend") --Set the blend mode to "blend" dxSetRenderTarget() --Stop drawing in the render target dxSetBlendMode("add") --Set the blend mode to "add" dxDrawImage((sWidth/2)-(X/2), ((sHeight/2)-(Y/2))+20, X, Y, cTarget, 0, 0, 0, tocolor(255, 255, 255, 255), true) --Now lets draw an image of our made render target. Lets put the text in the middle of the screen (Add +20 because we removed -20 by the text's position to cut it in half) dxSetBlendMode("blend") --Set the blend mode to "blend" end end addEventHandler("onClientRender", root, testFunction) EDIT: You were just earlier than me JR10
JR10 Posted February 25, 2015 Posted February 25, 2015 @Et-win Why do you reset the blend mode twice? Also, this doesn't really address his issue, nor what caused the bug, he wants dxDrawImageSection not to draw the full image.
Et-win Posted February 25, 2015 Posted February 25, 2015 @Et-win Why do you reset the blend mode twice? Also, this doesn't really address his issue, nor what caused the bug, he wants dxDrawImageSection not to draw the full image. Ripped it out of my other script, I did draw other stuff between the first reset so that will explain why. Anyway, this would give the same effect as your script.
JR10 Posted February 25, 2015 Posted February 25, 2015 Are you sure? I mean, you're using dxDrawImage which will just draw the full image. He wants to draw a section of the image.
Et-win Posted February 25, 2015 Posted February 25, 2015 I set the position of the text like that so it will be partially not visible, just like your code. So yes, it does. Test it
JR10 Posted February 25, 2015 Posted February 25, 2015 No need, I just didn't notice the positioning arguments.
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