Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problems with Resizing RenderWindow/RenderTexture  (Read 2183 times)

0 Members and 1 Guest are viewing this topic.

Outstream

  • Newbie
  • *
  • Posts: 4
    • View Profile
Problems with Resizing RenderWindow/RenderTexture
« on: October 06, 2016, 09:01:57 pm »
I am drawing to a RenderTexture which is then drawn to a RenderWindow. I am attempting to resize them both without scaling. When the window is resized, I create a new view and apply it to this window. This works great until I try to resize the RenderTexture as well.

This is the result if I don't resize the RenderTexture (the green is the RenderWindow)

But when I resize the RenderTexture (by calling create(width, height) again), I get weird results, UNLESS I recreate the window (which I would very much like to avoid).

 The result is either the texture doesn't appear, the texture flickers, or (this is odd) The texture's y value matches the height difference, and the green (window) doesn't render at all and is transparent.

The drawing is handled on a separate thread from the resizing, but the drawing thread is locked during the resize.
« Last Edit: October 06, 2016, 11:25:57 pm by Outstream »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Problems with Resizing RenderWindow/RenderTexture
« Reply #1 on: October 07, 2016, 09:46:11 am »
Don't use multi threading for rendering and updating, it's simply not worth the effort and will be the source of many issues.

I assume you do call clear, draw display on the render texture as well, right?

Without a complete and minimal example that reproduces the issue, we can't really help you further.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Outstream

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: AW: Problems with Resizing RenderWindow/RenderTexture
« Reply #2 on: October 07, 2016, 04:43:06 pm »
Don't use multi threading for rendering and updating, it's simply not worth the effort and will be the source of many issues.

I assume you do call clear, draw display on the render texture as well, right?

Without a complete and minimal example that reproduces the issue, we can't really help you further.

Yeah, I call clear and display on both. I'll try to reproduce an example. In the mean time, could you tell me if it is possible to resize a window without stretching and then use it normally?
« Last Edit: October 07, 2016, 05:11:55 pm by Outstream »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Problems with Resizing RenderWindow/RenderTexture
« Reply #3 on: October 07, 2016, 05:13:04 pm »
Not exactly sure what you mean by "resize a window without stretching"?

You can change the size of a window by calling setSize().
The view will then "stretch" with the window, which may lead to distortion and might not be what you want. The solution is shown in the official tutorial.

Maybe try to explain what your final goal is and we might be able to help you figure out what you need to do.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Outstream

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Problems with Resizing RenderWindow/RenderTexture
« Reply #4 on: October 07, 2016, 05:45:53 pm »

That is what I meant by not stretching, which I know is possible. What I was trying to ask is if that method will achieve the same effect as recreating the window.

I am trying to create a user friendly GUI library with SFML as the base. I would like it to be threaded as it would be more user-friendly if the library handled the framerate (when the draw function is called) so it only updates when needed.

As I'm typing this, I realize the user could call the draw function at their own framerate, and the library can decide if it actually needs an update.

I've believe I've thought of a few better options, but I will keep trying to recreate my problem on a small scale if you don't mind coming back to this post in the future

One more question though, theoretically is there any reason that this wouldn't work: if all of the SFML objects are created (and drawn on) on one thread (that isn't the main thread) and are then only modified through requests from another thread. Basically, can SFML work entirely on a secondary thread?

Thanks for the help, btw!
« Last Edit: October 07, 2016, 06:08:52 pm by Outstream »

Outstream

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Problems with Resizing RenderWindow/RenderTexture
« Reply #5 on: October 07, 2016, 06:15:00 pm »

That is what I meant by not stretching. What I was trying to ask is if that method will achieve the same effect as recreating the window.

I am trying to create a user friendly GUI library with SFML as the base. I would like it to be threaded as it would be more user-friendly if the library handled the framerate (when the draw function is called) so it only updates when needed.

As I'm typing this, I realize the user could call the draw function at their own framerate, and the library can decide if it actually needs an update.

I've believe I've thought of a few better options, but I will keep trying to recreate my problem on a small scale if you don't mind coming back to this post in the future

One more question though, theoretically is there any reason that this wouldn't work: if all of the SFML objects are created (and drawn on) on one thread (that isn't the main thread) and are then only modified through requests from another thread. Basically, can SFML work entirely on a secondary thread?

Thanks for the help, btw!

 

anything