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

Author Topic: Diagonal views  (Read 2487 times)

0 Members and 1 Guest are viewing this topic.

Doodlemeat

  • Guest
Diagonal views
« on: March 07, 2014, 11:14:37 pm »
Hello SFML users;

I have a question about views;
As far as I can see, SFML only supports AABB views(rectuanglar views);

But I want to have a viewport with a diagonal segment. Exactly like this image:


Is this possible in SFML?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Diagonal views
« Reply #1 on: March 08, 2014, 12:06:43 am »
Everything is possible somehow, but it sure is not possible with the standard SFML view port. ;)

One way would be to render the full rectangle image to a render texture and the blend over with a transparent layer and then render them to the window.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mutoh

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Diagonal views
« Reply #2 on: March 10, 2014, 12:57:59 am »
This is what I thought at first glance (no code):

* Have two RenderTextures, two Views and two Sprites for each player.
* Both Views, which you will use to follow the players, should have the same rotation.
* The Sprites should have their textures' set to the RenderTextures' textures.
* Place one of the Sprites right below the other (sprite2.setPosition(0, sprite1.getGlobalBounds().height))

* Have a third RenderTexture (or draw straight to your window) and a third View.
* This third View should have the same rotation of the previous Views.
* Position the third View to the middle of the two sprites (view3.setCenter(sprite1.getGlobalBounds().width / 2.f, sprite2.getPosition().y))
* Don't forget to set our third RenderTexture's view to this third View.

* Then you have renderTexture1 draw player 1, renderTexture2 draw player 2, and renderTexture3 draw renderTexture1 and 2 through sprite1 and sprite2.

 ;)
« Last Edit: March 10, 2014, 01:06:29 am by Mutoh »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Diagonal views
« Reply #3 on: March 13, 2014, 07:08:13 pm »
Have you seen this post? ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything