Snow-Man Posted October 22, 2022 Share Posted October 22, 2022 Hello, i have been trying to make scrollable text using dxSetRenderTarget but it doesnt work when i apply the render here is the part of the code everything works fine till i apply it then it doesnt show up posx = (sX/2)-(x1/2) posy = (sY/2)-(y1/2) max = string.len(core) local scrolling = (( scrollManager/max )*10) dxRectangle ( posx, posy-y2, x2, y2, color ) dxRectangle ( posx, posy, x1, y1, tocolor ( 0, 0, 0, 200 ) ) dxImage((x1+x2), posy+12, (z2/2)+7, z1+183, "file/scroll_b.png",false) dxImage((x1+x2), (posy+12)+max*scrolling, (z2/2)+7, z2+25, "file/scroll.png",false) local rtW, rtH = dxGetMaterialSize(texture) dxSetRenderTarget( texture, true) dxText ( core, posx+2, posy-max*scrolling, x1*1.997, y1*1.389, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) dxSetRenderTarget() dxDrawImage(posx+2, posy, rtW, rtH, texture,0, 0, 0, tocolor(255, 255, 255, 0), false) and there is no synchronization between the text and scroll icon Link to comment
Ash12kaddour Posted October 22, 2022 Share Posted October 22, 2022 hi what is your problem , this is vultaic MGM ? Link to comment
Snow-Man Posted October 22, 2022 Author Share Posted October 22, 2022 Thank you for the reply. whats vultaic MGM? i have 2 problems, the first that the text isnt showing on the texture that already applied im trying to make it scrollable text and second there is no sync between scrolling action and the text Link to comment
Addlibs Posted October 22, 2022 Share Posted October 22, 2022 Can you provide a screenshot/video of what your code currently produces, and an annotated screenshot of what you want to achieve? I tried running the code you provided to get an idea of what you're trying to do but the code is incomplete, lacks the definition of the render target (i.e. its size is missing), uses non-standard drawing functions, etc. I don't understand the use of string.len(core) here. String length = number of characters, which suggests horizontal scrolling but the positions scrolled indicate vertical scrolling. I also don't understand the variables used (please, name your variables, it makes helping so much easier): what are x2, y2, z1, z2? Link to comment
Snow-Man Posted October 22, 2022 Author Share Posted October 22, 2022 local sX,sY = guiGetScreenSize() local texture = dxCreateRenderTarget( 426, 449) function dxDrawAnimWindow(text,height,width,color,font,anim, core) btwidth = width btheight = height/20 local tick = getTickCount() local elapsedTime = tick - start local endTime = start + 1500 local duration = endTime - start local progress = elapsedTime / duration local x1, y1, z1 = interpolateBetween ( 0, 0, 0, width, height, 255, progress, anim) local x2, y2, z2 = interpolateBetween ( 0, 0, 0, btwidth, btheight, btheight/11, progress, anim) posx = (sX/2)-(x1/2) posy = (sY/2)-(y1/2) max = string.len(core) local scrolling = (( scrollManager/max )*10) dxRectangle ( posx, posy-y2, x2, y2, color ) dxRectangle ( posx, posy, x1, y1, tocolor ( 0, 0, 0, 200 ) ) dxImage((x1*1.7), posy+12, (z2/2)+7, z1+183, "file/scroll_b.png",false) dxImage((x1*1.7), (posy+12)+max*scrolling, (z2/2)+7, z2+25, "file/scroll.png",false) local rtW, rtH = dxGetMaterialSize(texture) dxSetRenderTarget( texture, true) dxText ( core, posx+2, posy-max*scrolling, rtW, rtH, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) dxSetRenderTarget() dxDrawImage(posx+2, posy, rtW, rtH, texture,0, 0, 0, tocolor(255, 255, 255, 0), false) dxText ( text, 0, -(y1)-y2, sX, sY, tocolor ( 255, 255, 255, 255 ), z2,font,"center","center") if isMouseInPosition(((x1+x2)-3)*0.855, (posy-y2)-5, 750, 170) then dxText("X", ((x1+x2)-3)*0.855, (posy-y2)-5, 750, 170, tocolor(255, 255, 255, 255), 1.2, "bankgothic", "left", "center", false, false, false, false, false) else dxText("X", ((x1+x2)-3)*0.855, (posy-y2)-5, 750, 170, tocolor(255, 255, 255, 255), 0.9, "bankgothic", "left", "center", false, false, false, false, false) end end Hello @Addlibs thank you for replying the variable of core is long text contains around 400 letters and the variable of scrollManager = 0 and it goes by 1 or -1 even trying to scroll down or up Link to comment
Moderators IIYAMA Posted October 22, 2022 Moderators Share Posted October 22, 2022 Keep in mind that the capture process starts at the left-top of the screen. posx = (sX/2)-(x1/2) dxText ( core, posx+2, posy-max*scrolling, rtW, rtH, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) It might not be captured. local rtW, rtH = dxGetMaterialSize(texture) You already know the size of the render target, no need to compute. Link to comment
Snow-Man Posted October 22, 2022 Author Share Posted October 22, 2022 14 minutes ago, IIYAMA said: Keep in mind that the capture process starts at the left-top of the screen. posx = (sX/2)-(x1/2) dxText ( core, posx+2, posy-max*scrolling, rtW, rtH, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) It might not be captured. local rtW, rtH = dxGetMaterialSize(texture) You already know the size of the render target, no need to compute. Yes, i changed that in the end when i wanted to make the text get the right size, I know it doesn't have the right positions but it's not the problem Link to comment
Snow-Man Posted October 24, 2022 Author Share Posted October 24, 2022 local sX, sY = guiGetScreenSize() local texture = dxCreateRenderTarget( 426, 449) function dxDrawAnimWindow(text,height,width,color,font,anim, core) btwidth = width btheight = height/20 local tick = getTickCount() local elapsedTime = tick - start local endTime = start + 1500 local duration = endTime - start local progress = elapsedTime / duration local x1, y1, z1 = interpolateBetween ( 0, 0, 0, width, height, 255, progress, anim) local x2, y2, z2 = interpolateBetween ( 0, 0, 0, btwidth, btheight, btheight/11, progress, anim) posx = (sX/2)-(x1/2) posy = (sY/2)-(y1/2) max = string.len(core) local scrolling = (( scrollManager/max )*10) dxRectangle ( posx, posy-y2, x2, y2, color ) dxRectangle ( posx, posy, x1, y1, tocolor ( 0, 0, 0, 200 ) ) dxRectangle((x1+x2),posy, 12, 449, tocolor(0, 0, 0, 200), false) dxRectangle((x1+x2)+2, (posy+2)+max*scrolling, 8, 35, tocolor(25, 25, 25, 150), false) dxSetRenderTarget( texture, true) dxText ( core, posx+2, posy-max*scrolling, 854, 624, tocolor ( 255, 255, 255, 255 ), z2*0.90,font,"left","top",true, true, false,false, true) dxSetRenderTarget() dxDrawImage(posx+2, posy, 426, 449, texture,0, 0, 0, tocolor(255, 255, 255, 100), false) dxText ( text, 0, -(y1)-y2, sX, sY, tocolor ( 255, 255, 255, 255 ), z2,font,"center","center") end i have edited it but still the same problem, i have even tried on independent script but doesn't work too Link to comment
Moderators IIYAMA Posted October 25, 2022 Moderators Share Posted October 25, 2022 22 hours ago, Snow-Man said: i have even tried on independent script Can you create a smaller version of your current resource, so that we can take a closer look at your problem? (small size is important because we can focus mainly on the problem) Just looking at your current code is a very inefficient method in finding a bug. Best to let the computer do the work for us. Link to comment
Snow-Man Posted October 25, 2022 Author Share Posted October 25, 2022 I have already did one like this dxSetRenderTarget(texture, true) dxDrawText(500, 500, 240, 250, .....) dxSetRenderTarget () dxDrawImage(500, 500, 120, 125, image...) But the same problems doesn't display, when i apply the texture the text just disappear Link to comment
Moderators IIYAMA Posted October 26, 2022 Moderators Share Posted October 26, 2022 20 hours ago, Snow-Man said: I have already did one like this dxSetRenderTarget(texture, true) dxDrawText(500, 500, 240, 250, .....) dxSetRenderTarget () dxDrawImage(500, 500, 120, 125, image...) But the same problems doesn't display, when i apply the texture the text just disappear Try this play ground of mine. Should be working, if not it might be a hardware or setting issue. do --[[ Capture content here ]] local renderTarget addEventHandler( "onClientResourceStart", resourceRoot, function() renderTarget = dxCreateRenderTarget( 500, 500, true ) end ) function captureContent( callBack ) if not renderTarget then return false end dxSetRenderTarget( renderTarget, true ) callBack() -- captureContent( >>> function() end <<< ) dxSetRenderTarget() return renderTarget end end do --[[ Cache renderTargets for static content ]] local cache = {} function cacheRenderTarget( key, renderTarget ) local pixels = dxGetTexturePixels( renderTarget ) if not pixels then return false end cache[key] = dxCreateTexture( pixels ) return true end function getTextureFromCache( key ) if cache[key] then iprint( 'from cache' ) end return cache[key] end end addEventHandler( "onClientRender", root, function() -- When updating content local dynamicTexture = captureContent( function() local size = getTickCount() % 501 dxDrawRectangle( 0, 0, size, size, tocolor( 0, 0, 100, 100 ) ) dxDrawText( "abcdefghi dynamic" .. getTickCount(), 10, 0, 500, 500, tocolor( 255, 255, 255 ), 1, "default", "left", "top", false, false, false, false, true ) dxDrawText( "abcdefghi dynamic" .. getTickCount(), 10, 20, 500, 500, tocolor( 255, 255, 255 ), 2, "default", "left", "top", false, false, false, false, true ) end ) if dynamicTexture then dxDrawImage( 0, 500, 500, 500, dynamicTexture ) end -- When just drawing static stuff local staticTexture = getTextureFromCache( 'static' ) if not staticTexture then staticTexture = captureContent( function() dxDrawRectangle( 0, 0, 500, 500, tocolor( 0, 0, 100, 100 ) ) dxDrawText( "abcdefghi static (not so sharp)", 10, 0, 500, 500, tocolor( 255, 255, 255 ), 1, "default", "left", "top", false, false, false, false, true ) dxDrawText( "abcdefghi static (not so sharp)", 10, 20, 500, 500, tocolor( 255, 255, 255 ), 2, "default", "left", "top", false, false, false, false, true ) end ) if staticTexture then cacheRenderTarget( 'static', staticTexture ) end end if staticTexture then dxDrawImage( 500, 500, 500, 500, staticTexture ) end end ) Link to comment
Dzsozi (h03) Posted October 27, 2022 Share Posted October 27, 2022 On 26/10/2022 at 00:42, Snow-Man said: I have already did one like this dxSetRenderTarget(texture, true) dxDrawText(500, 500, 240, 250, .....) dxSetRenderTarget () dxDrawImage(500, 500, 120, 125, image...) But the same problems doesn't display, when i apply the texture the text just disappear It is working and the text is drawn, the problem is that you are setting the text position outside of the render target canvas size. When you are drawing inside a render target, the positions start from 0 again. textureWidth, textureHeight = 100, 50 texture = dxCreateRenderTarget(textureWidth, textureHeight, true) dxSetRenderTarget(texture, true) dxDrawText("text", 5, 5, textureWidth, textureHeight) dxSetRenderTarget() dxDrawImage(posx, posy, textureWidth, textureHeight, texture) This will draw the render target as an image wherever you want, and inside of it will be the text on the top left corner, offset by 5 pixels. 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