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

Author Topic: Render Texture with a View  (Read 1338 times)

0 Members and 1 Guest are viewing this topic.

bszandras

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Render Texture with a View
« on: July 30, 2020, 03:51:12 pm »
I can not really figure this out on my own so please help me guys.
In my little "game" i draw stuff to my render window, and if I move the view, it just works like it is supposed to.
But if i draw things to a RenderTexture (clear, draw, display), then load the texture into the sprite then draw the sprite on the window, the RenderTexture stays in place like every other object.
Is there a way I can make the RenderTexture to allways cover my view?

thanks in advance

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Render Texture with a View
« Reply #1 on: July 30, 2020, 06:09:13 pm »
it's hard to tell without any code, but my guess is that you are drawing this sprite to the same coordinates in the window view everytime.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

bszandras

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Render Texture with a View
« Reply #2 on: July 30, 2020, 06:23:11 pm »
Yes I am drawing it to the same position everytime, however that is not the problem.

My goal is to "cut" through a black RenderTexture with shapes, for lighting, and currently it works great on the first frame. But when i move my view the RenderTexture does not seem to "move" with it, because it still shows the "cut" on the first fram, even tough i clear redraw and display every frame. So I think my Problem is that the render texture is assigned to the RenderWindow and not my current view. (I set the View)

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Render Texture with a View
« Reply #3 on: July 30, 2020, 10:37:18 pm »
can't you post some image of the problem and code? its hard to guess whats happening.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

bszandras

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Render Texture with a View
« Reply #4 on: July 31, 2020, 09:19:15 am »
I did not post code originally cause I am working with Box2D as a physics engine, and even the code that isn't part of that is pretty much a whole spaghetti
What I m doing is first constructing a convex shape, and on its points i am drawing Quads.
First i draw on the screen a completely brown RenderTexture (that works perfectly fine) then i draw the convex shape onto another RenderTexture, and then everything with the Quads i draw on the RenderWindow.
It is supposed to look like a cave.
My problem is, as it is on the image (i hope i attached it perfectly), that after i move the RenderTextures stay in place. Moving the sprites with the view works for the brown background, but not for the darker background of the cave (image 2 and 3).

What I think my problem is:
The RenderTexture does not move with the view and so the relative position of the convex shape is allways the same

I may missunderstand how RT-s work, but what I think my goal is and how it is supposed to work, that it fills the view, and moves with it.

I hope I could explain it, english is not my first language, sorry if I am not really clear.

 

anything