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

Author Topic: Sizing RenderTexture resizes graphics  (Read 2968 times)

0 Members and 1 Guest are viewing this topic.

pighead10

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Hog Pog
Sizing RenderTexture resizes graphics
« on: October 29, 2012, 02:51:57 pm »
As I am using multiple views of the same screen I am drawing to a RenderTexture, which I then draw to the RenderWindow. At the beginning of my program the RenderTexture is created to twice the size of the window. I was expecting my rendering area to be increased (e.g. so the size of  the window was 600x600 but I could render to this texture at (800,800) ), but instead when I draw all my graphics were scaled up - so my 32x32 sprites became 64x64, and the positions were scaled - creating the RenderTexture double the size just stretched it.

Here is what I'm doing each rendering frame (in pseudocode):
rendertexture.clear()
window.clear()
rendertexture.setView(view)
rendertexture.draw(all)
rendertexture.display()
window.draw(rendertexture)
window.setView(minimap)
window.draw(rendertexture)
window.display()

I'm trying to have the minimap display the same screen as the main view except the area that is shows is double the size. If the RenderTexture didn't stretch I would be able to do this (SFML 2, but not the most up to date version).



« Last Edit: October 29, 2012, 03:21:47 pm by pighead10 »
Immortui - Zombie puzzle game: http://immortui.hogpog.co.uk

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Sizing RenderTexture resizes graphics
« Reply #1 on: October 29, 2012, 03:06:50 pm »
What's displayed in your render-window is defined by the view. If you make your render-texture larger but don't change the view, things will just get stretched. If you want to see a larger region of your scene, you must adjust the view too.

Quote
rendertexture.setView(minimap)
window.draw(rendertexture)
Changing the view without drawing anything will have no effect. It doesn't draw or resize anything, it just changes how the next entities will be drawn.
Laurent Gomila - SFML developer

pighead10

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Hog Pog
Re: Sizing RenderTexture resizes graphics
« Reply #2 on: October 29, 2012, 03:55:32 pm »
Quote
rendertexture.setView(minimap)
should be window.setView(minimap). Edited.

Quote
What's displayed in your render-window is defined by the view. If you make your render-texture larger but don't change the view, things will just get stretched.

Here is an image - hopefully this will explain what I mean:

Immortui - Zombie puzzle game: http://immortui.hogpog.co.uk

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Sizing RenderTexture resizes graphics
« Reply #3 on: October 29, 2012, 04:00:56 pm »
I had correctly understood your problem. Did you understand my answer?

It seems like you don't understand how view work (your second and third pictures are wrong), you should read the tutorial/doc/wiki (there's a good tutorial on the wiki).
Laurent Gomila - SFML developer

pighead10

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Hog Pog
Re: Sizing RenderTexture resizes graphics
« Reply #4 on: October 29, 2012, 04:11:30 pm »
I incorrectly understood your answer as not understanding my problem. :(

I have read the documentation and the wiki - I may understand something incorrectly. As I understand, in my scenario the view will display a portion of the rendertexture. The mental image I have of what's happening is the 3rd image, and you say it is wrong - what does actually happen?
Immortui - Zombie puzzle game: http://immortui.hogpog.co.uk

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Sizing RenderTexture resizes graphics
« Reply #5 on: October 29, 2012, 04:24:19 pm »
The view always covers the entier target, unless you play with the viewport (which doesn't seem to be the case). That's why your second and third pictures, where the view stays stuck at the old size, are wrong.

What I'm trying to explain is that the view always displays the same region of the scene if you don't change it. No matter how big is the target on which it is displayed. What you see on screen is what's inside the view, so if you want to see more stuff, you must make it bigger (zoom out).
Laurent Gomila - SFML developer

pighead10

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Hog Pog
Re: Sizing RenderTexture resizes graphics
« Reply #6 on: October 29, 2012, 04:48:55 pm »
I understand now!  ;D Thanks!
Immortui - Zombie puzzle game: http://immortui.hogpog.co.uk

 

anything