Fist Posted April 24, 2017 Share Posted April 24, 2017 so as the title says how can i use dxSetRenderTarget properly? Because it uses memory to store. But what if player's computer is very :~ and memory is already full then how i will be able to create that render target in order to show it? Also is there other way to clip area what you dont want to show without using dxSetRenderTarget (like a window where things will only be showed if its in that window area)? Link to comment
3aGl3 Posted April 24, 2017 Share Posted April 24, 2017 If the memory is full it's full, not much you can do. You could delete unused things. If the render target wasn't set successfully the function returns false, if the render target wasn't even created successfully dxCreateRenderTarget will return false too. If you want to clip of parts of a texture then yes, dxDrawImageSection is there. Otherwise you could probably work with some smart scripting. Link to comment
Fist Posted April 24, 2017 Author Share Posted April 24, 2017 4 minutes ago, 3aGl3 said: If the memory is full it's full, not much you can do. You could delete unused things. If the render target wasn't set successfully the function returns false, if the render target wasn't even created successfully dxCreateRenderTarget will return false too. If you want to clip of parts of a texture then yes, dxDrawImageSection is there. Otherwise you could probably work with some smart scripting. and what you mean by that smart scripting, huh? And really, there is no other way making dx panes ? That sucks. Link to comment
3aGl3 Posted April 24, 2017 Share Posted April 24, 2017 Well, it really depends on what you want to do. Let's just assume you want to make a dxGUI with scroll areas, I'd go about it something like this: function createDxScrollPane( x, y, parent ) local pane -- create an element, a table or whatever -- save x, y, apply parent bla bla bla -- try to create a render target for smooth scrolling local render_target = dxCreateRenderTarget( x, y, true ) if render_target then -- save the render target end return pane end -- for render event function drawDxScrollPane() local scroll_x, scroll_y = getScrollPos( pane ) if render_target then -- draw to the render target else -- we scroll line by line and char by char local line_h = 15 local pos_y = line_h * scroll_y * y for k, v in ipairs(children) -- draw only text that is below pos_y -- draw only parts of images that are visible below pos_y -- etc. end end end Note that I made all that up on the fly but it should get the point accross. Link to comment
Fist Posted April 24, 2017 Author Share Posted April 24, 2017 38 minutes ago, 3aGl3 said: Well, it really depends on what you want to do. Let's just assume you want to make a dxGUI with scroll areas, I'd go about it something like this: function createDxScrollPane( x, y, parent ) local pane -- create an element, a table or whatever -- save x, y, apply parent bla bla bla -- try to create a render target for smooth scrolling local render_target = dxCreateRenderTarget( x, y, true ) if render_target then -- save the render target end return pane end -- for render event function drawDxScrollPane() local scroll_x, scroll_y = getScrollPos( pane ) if render_target then -- draw to the render target else -- we scroll line by line and char by char local line_h = 15 local pos_y = line_h * scroll_y * y for k, v in ipairs(children) -- draw only text that is below pos_y -- draw only parts of images that are visible below pos_y -- etc. end end end Note that I made all that up on the fly but it should get the point accross. yeah that's kinda what i wanted to write but thought about those renderTarget problems about memory. It actually sucks that there is no better function which doesn't require any memory usage. 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