Jump to content

dxCreateRenderTarget


Karuzo

Recommended Posts

Sup Community,

i have a question 'bout dxCreate/dxSet - RenderTarget ,

i don't understand how this actually works.

A friend of mine explained it to me, but i just don't get it.

I think it's like a box or smth like that, so the dx Creations won't go outside of it.

Or is it like a parent but just for the DirectX Creations ?

But i don't really know if that's true, and i would be so happy if someone could explain that to me. :-)

Regards,

KRZO.

Link to comment

Render targets are like textures (images) that you can draw on, think of it like layers in photoshop.

You can draw on it using dx functions like dxDrawText/dxDrawImage, and anything that is draw outside the area of the render target will get "cut off".

Simple example:

-- true as third argument creates the render target with transparent background 
local renderTarget = dxCreateRenderTarget(640, 480, true) 
-- Using true as second argument will clear/erase the content of the render target, making it fully transparent 
dxSetRenderTarget(renderTarget, true) 
-- Position starts from top left of the render target! 
dxDrawText("test", 0, 0) 
-- Calling dxSetRenderTarget with no arguments will set the render target on which dx content will be drawn on to the screen, so we can draw the render target on the screen now 
dxSetRenderTarget() 
  
addEventHandler("onClientRender", root, 
function() 
    -- You can treat the render target like a texture 
    dxDrawImage(300, 300, 640, 480, renderTarget) 
end) 

Render targets can be used if you want to increase performance by only a lot of drawing dx stuff once, and display it many times, or if you want to "draw" using lua to a texture, or if you want to rotate text in 3d together with shader.

Render targets can also be used if you want to scale an image and still have good quality, as using render targets somehow scale better visually. Also you make sure to play with dxSetBlendMode to get best visual result, otherwise it can look weird.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...