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

Author Topic: Error using view of a renderTexture  (Read 2357 times)

0 Members and 1 Guest are viewing this topic.

Bloob

  • Newbie
  • *
  • Posts: 13
    • View Profile
Error using view of a renderTexture
« on: August 08, 2014, 04:02:29 am »
Basically my game has a world in space and the ship should be able to move around in all direction (like asteroids), to keep the view focused on the player i set the center of the view being used on the renderTexture to the position of the player. after the center gets moved a certain distance lets say (-14000, 5000) or (300, 9000) the screen goes black and when i print out the coordinates of view.getCenter() it prints out (-1.#IND, -1.#IND)

In my finished product i would probably be limiting the distance the player could travel anyways, But i wanted to know if I'm using view.setCenter(); in a way that was not meant to be. 

Keep in mind drawing all my sprites to a renderTexture then drawing that to the window.

Please tell me if my description in not clear.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Error using view of a renderTexture
« Reply #1 on: August 08, 2014, 03:02:15 pm »
i don't know if i get it correctly, but you set the view on a renderTexture, right?
does it happens if you draw directly to a renderWindow instead?
what is the size of your renderTexture? this could be caused by your view going off the renderTexture limits.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Bloob

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error using view of a renderTexture
« Reply #2 on: August 08, 2014, 03:50:35 pm »
i don't know if i get it correctly, but you set the view on a renderTexture, right?
does it happens if you draw directly to a renderWindow instead?
what is the size of your renderTexture? this could be caused by your view going off the renderTexture limits.

yes the view of the renderTexture that will be draw to the actual window.

I just noticed it happened after i switched to using a renderTexture before when i drew dirctly to the window i never noticed this problem. I am drawing to a renderTexture because i was planing on doing some shader effects to the screen. 

The renderTexture is the same size as my window (1280, 720) but the screen usually goes blank when its about 20000 pixels away from the center of the texture.
« Last Edit: August 08, 2014, 04:19:44 pm by Bloob »

Bloob

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Error using view of a renderTexture
« Reply #3 on: August 08, 2014, 08:38:41 pm »
Hmm I've been looking at google for what -1.#IND means. At first i thought it just meant infinity or undefined but absolutely nothing comes up on google about it so I think it may be something specific to SFML? I'm really confused. How am i supposed to simulate a large empty space? I'll continue to look at my code for a bug i may have created somewhere...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
AW: Error using view of a renderTexture
« Reply #4 on: August 10, 2014, 10:02:25 pm »
Are the values you provided correct, because -14000 should still be in the floating range.
If it's more something like +-32000 then it's just a limit of floats, see here.

Large worlds can be simulated by splitting it up with different containers/variables and resetting the view from time to time.
« Last Edit: August 10, 2014, 10:15:25 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Bloob

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: AW: Error using view of a renderTexture
« Reply #5 on: August 11, 2014, 01:50:29 am »
Are the values you provided correct, because -14000 should still be in the floating range.
If it's more something like +-32000 then it's just a limit of floats, see here.

Large worlds can be simulated by splitting it up with different containers/variables and resetting the view from time to time.

Thanks! the link is very useful and ill be looking into resetting the view periodically. I just did a few tests and get very weird results. (-70000, -20000) (-40000, 20000) but usually around 30k the floats go out of range not exactly at 32k. and they both go out of range at the same time. But i think the problem is solved for now :D