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

Author Topic: [SOLVED] Multiple independant views into the same window  (Read 1368 times)

0 Members and 1 Guest are viewing this topic.

ekryyn

  • Newbie
  • *
  • Posts: 9
    • View Profile
[SOLVED] Multiple independant views into the same window
« on: March 29, 2012, 02:54:28 pm »
Hello,
First, sorry for my english skills...
I'm trying to get many areas in one window. I want each area to display independant stuff, like many renderTargets displayed side by side would do, but inside the same window.
I tried to investigate a way of doing such a thing, but I didn't find.
What is the best way to do this ? Perhaps by rendering each area into differents RenderTextures, and display each textures side by side into my main RenderWindow ? But I don't know if this is the right way to do.
Please, someone can guide me ?
Thanks
« Last Edit: March 30, 2012, 09:31:09 am by ekryyn »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Multiple independant views into the same window
« Reply #1 on: March 29, 2012, 03:40:23 pm »
You can use different views, each with its own viewport that defines where it is displayed in the window.
Laurent Gomila - SFML developer

ekryyn

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Multiple independant views into the same window
« Reply #2 on: March 29, 2012, 04:03:32 pm »
Thanks for the answer,
but I'm not sure to understand. I thought that a view was just a "part" of the scene, meaning that all objects drawn in the scene was potentially displayed in each view that focus on that particular "place" in the scene. I may be wrong, it sounds like i'd better read the documentation again.
Do you mind if I precise my problem in french on this forum ? It's hard for me to ask the good question in english :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Multiple independant views into the same window
« Reply #3 on: March 29, 2012, 04:10:14 pm »
Quote
I thought that a view was just a "part" of the scene, meaning that all objects drawn in the scene was potentially displayed in each view that focus on that particular "place" in the scene. I may be wrong, it sounds like i'd better read the documentation again.
You're right, but there's also the viewport property, that defines where the contents of the view must be displayed in the window.

Quote
Do you mind if I precise my problem in french on this forum ? It's hard for me to ask the good question in english
This forum is english only, but there's a french forum.
Laurent Gomila - SFML developer

ekryyn

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Multiple independant views into the same window
« Reply #4 on: March 29, 2012, 04:13:49 pm »
Thank you, i'm going there to re-ask my question, because it's not completely clear to me ;)
Thanks again for your answers

ekryyn

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Multiple independant views into the same window
« Reply #5 on: March 29, 2012, 04:30:06 pm »
Oh I just understood.
I think that's all right now :
One renderTarget (my window),
Many scenes with their own views : each view defines a viewport in order to define where it is displayed on the single window
Each scene are rendered sequentially, with these steps :
 - assign current view to the render target,
 - clear the render target (hopefully, this will only clear the part of the render target defined by the viewport, because we assigned the view)
 - draw the objects
and so on for next views.

Am I good ? That's what you replied to me in your first post... But I'm a bit silly so I didn't get that !
I was thinking wrong...
Thanks a lot ! (hoping i'm right...)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Multiple independant views into the same window
« Reply #6 on: March 29, 2012, 05:22:06 pm »
Yep, you got it.

I'm just not sure about that:
Quote
hopefully, this will only clear the part of the render target defined by the viewport

Let me know after you test it :)
Laurent Gomila - SFML developer

ekryyn

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Multiple independant views into the same window
« Reply #7 on: March 29, 2012, 05:44:05 pm »
Ok i'm going to try it. But I realize that viewports are not available before SFML-2.0 , so i'm trying to port my code for working with that last version.
For now, I'm just not able to draw simple colored lines, since it's not available as a shape like it was before.

ekryyn

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: [SOLVED] Multiple independant views into the same window
« Reply #8 on: March 30, 2012, 09:33:59 am »
Quote
Let me know after you test it

target->clear() clears the entire render target, not only the viewport of the assigned view.
But it doesn't matter, I just clear the screen before any view rendering, then each view draws its own area.

So, my problem is solved ! Thanks
« Last Edit: March 30, 2012, 09:36:18 am by ekryyn »

 

anything