Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RenderTarget Usage

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    RenderTarget Usage

    As far as I understand, there's two types of RenderTarget being used in a script, one being " SharpDX.Direct2D1.WindowRenderTarget", another being "SharpDX.Direct2D1.WicRenderTarget" as the following link claimed:

    My Questions:
    1. Is RenderTarget​ only available at OnRender() and OnRenderTargetChange() ?
    2. Should I explicitly write different logic ​for different types of RenderTarget ​under OnRender() and OnRenderTargetChange()​? If so, how to separate them?
    Last edited by Curerious; 04-15-2025, 06:30 PM.

    #2
    Hello Curerious,

    Thank you for your post.

    RenderTarget is not only available from those two methods, it is available from other methods after it is created. However it often gets disposed, and a new object is created which updates with OnRenderTargetChanged().

    Render objects should be instantiated in OnRenderTargetChanged when a new RenderTarget object is generated. This is noted in the Help Guide:

    "Since there are multiple RenderTargets, you MUST ensure the resource being used belongs to the destination target. In practice, all you need to understand is if you are using a device resource (e.g., custom SharpDX Brush) throughout different event methods, you should recreate these resource during OnRenderTargetChanged() which ensures the device resource is updated correctly as the devices context changes.​"



    Note that the actual logic to draw/render should be in OnRender(), which runs when rendering the chart.

    These examples might help to clarify how this works:



    This is a conversion of the Realtime Level II/Tick Volume. Please contact the original author for any questions or comments. Update Aug 27th, 2018: Since OnRenderTargetChanged can be called before State.DataLoaded, setting the dxmBrushes["backColor"].MediaBrush here wasn't working out and was sometimes null. Changed this to now get the chart background color (and text color) from […]

    Comment


      #3
      Hey Gaby

      Thanks for replying, I saw the script you mentioned but it still uses the RenderTarget only within the OnRender method and OnRenderTargetChanged method, Do you happen to have an example of it being used outside of those two methods?

      In addition, I see the script also use the RenderTarget interchangeably, Could you also provide me an example of it being used separately into SharpDX.Direct2D1.WindowRenderTarget and SharpDX.Direct2D1.WicRenderTarget ?

      Thank you!

      Comment


        #4
        Hello Curerious,

        Thank you for your response.

        It's not necessarily that RenderTarget is literally being used in an outside method, for example in Jtrealstats you can see that a PathGeometry SharpDX object is created from the CreateGeometry() method. The PathGeometry object would be the RenderTarget in this instance. It can and will get disposed of, and then updated, which is what drives OnRenderTarget changed.

        Could you also provide me an example of it being used separately into SharpDX.Direct2D1.WindowRenderTarget and SharpDX.Direct2D1.WicRenderTarget ?​
        We do not have an example of this. Please see the note about multiple render targets:

        "Since there are multiple RenderTargets, you MUST ensure the resource being used belongs to the destination target. In practice, all you need to understand is if you are using a device resource (e.g., custom SharpDX Brush) throughout different event methods, you should recreate these resource during OnRenderTargetChanged() which ensures the device resource is updated correctly as the devices context changes.​"​

        Comment


          #5
          Got you, thanks Gaby!

          Comment


            #6
            No problem, please let me know if you need further guidance / clarification.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X