Gallardo9944 Posted September 29, 2013 Share Posted September 29, 2013 Hello. I've been searching for a while and still can't understand the way of drawing a text with an ability to rotate it left or right. Basically, the only thing I've found is that I have to use a shader for that. Unfortunately, I dunno anything particular about drawing stuff with shaders. Is there an ability to draw a text with an .fx shader? I've also read that I could use "DxDrawMaterialLine3D" for that, so if that's also possible, I'd really appriciate an example of drawing rotated texts with that. Thanks in advance. Link to comment
arezu Posted September 29, 2013 Share Posted September 29, 2013 (edited) -- The client script. Add in meta local text = "This text is going to rotate..." local fontScale, font = 2.0, "default-bold" local renderTarget = dxCreateRenderTarget(dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), fontScale, font), dxGetFontHeight(fontScale, font), true) local shader = dxCreateShader("textureReplace.fx") function updateRenderTarget() dxSetRenderTarget(renderTarget, true) dxDrawText(text, 0, 0, 0, 0, tocolor(255, 255, 255, 255), fontScale, font) dxSetRenderTarget() dxSetShaderValue(shader, "tex", renderTarget) end updateRenderTarget() addEventHandler("onClientRestore", root, function() updateRenderTarget() end) addEventHandler("onClientRender", root, function() dxSetShaderTransform(shader, 45, 0, 0) -- This is where the shader is rotated local width, height = dxGetMaterialSize(renderTarget) dxDrawImage(200, 200, width, height, shader) end) //textureReplace.fx shader file. Add this in meta as <file src="textureReplace.fx" /> texture tex; technique tech { pass p0 { Texture[0] = tex; } } Code not tested. If the quality looks bad, you can take a look at dxSetBlendMode Edited May 1, 2014 by Guest 1 Link to comment
Gallardo9944 Posted September 29, 2013 Author Share Posted September 29, 2013 Great thanks, Arezu. The code worked just perfectly, but you also needed to add "updateRenderTarget()" to make it actually draw the text, not a white rectangle. Link to comment
arezu Posted September 29, 2013 Share Posted September 29, 2013 Yeah, I forgot that ^^. Updated the code in case somebody else needs it. 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