SFML community forums

Help => General => Topic started by: Bloob on August 08, 2014, 04:02:29 am

Title: Error using view of a renderTexture
Post by: Bloob 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.
Title: Re: Error using view of a renderTexture
Post by: Stauricus 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.
Title: Re: Error using view of a renderTexture
Post by: Bloob 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.
Title: Re: Error using view of a renderTexture
Post by: Bloob 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...
Title: AW: Error using view of a renderTexture
Post by: eXpl0it3r 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 (http://www.johndcook.com/IEEE_exceptions_in_cpp.html).

Large worlds can be simulated by splitting it up with different containers/variables and resetting the view from time to time.
Title: Re: AW: Error using view of a renderTexture
Post by: Bloob 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 (http://www.johndcook.com/IEEE_exceptions_in_cpp.html).

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