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

Author Topic: Flipping RenderTexture  (Read 3379 times)

0 Members and 1 Guest are viewing this topic.

Nekroze

  • Newbie
  • *
  • Posts: 30
    • View Profile
Flipping RenderTexture
« on: November 06, 2012, 09:36:44 pm »
Hello, a few forewords, i am very new to SFML, i am using CSFML2(although my problem doesnt seem to be with the C bindings at all) and not using any openGL directly.

I am working on a little system that takes a bunch of sprites that are tiles for a map and draws them to the screen in chunks of 32 by 32 tiles at a time.

Previously i had been storing a position for each chunk in screen coordinates and each frame looping over each tile and re positioning the sprite for that tile to the chunkPosition + (tilesize * chunkTilePosition) then drawing each tile.

I know not the most efficient way of doing it but it works fine on my main computer but there is a bit of slowing on my little laptop so i thought of a better, obvious but new to me, way to do it.

My idea was to use a RenderTexture and instead of drawing the sprites onto the screen each frame, just draw the sprites to the RenderTexture once and then just draw the RenderTexture to the screen with a sprite at the chunk position and you have your entire chunk generated into a static image once and drawn easily.

Now this works on its own and i am getting the tiles onto the screen some of the chunks, not all, seem to be flipped and i cannot figure out why.

I am using the exact same loop to draw the sprites as i did with the first method just removed adding the chunks position to the tile position and drawing onto the RenderTexture rather then the screen.

I cant for the life of me figure out why the chunk would be flipped at all, can anyone help me out with this or even have some tips?

Thanks in advance to anyone kind enough to lend assistance.

EDIT: haha, this was in the hopes to increase performance atleast on the only computer i have that isnt way to fast to do performance testing... the version that uses RenderTexture causes it to BSOD upon launch of the app. I guess RenderTexture has a problem with the intelGPU then, is that documented?

EDIT:
quick demonstration of problem, first picture is what i want and how it works when i render to the screen, the second is rendering to RenderTexture. Although the next chunk down doesnt appear to be flipped but the one to its left does, and as far as i can see, neither in any predictable direction but i may be wrong there as the tiles are generated proceduraly off of the same seed, i don't know them that intimately nor are they so unique to me to be able to instantly tell if they are all flipped in one direction or something.

« Last Edit: November 06, 2012, 10:05:06 pm by Nekroze »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Flipping RenderTexture
« Reply #1 on: November 06, 2012, 10:13:52 pm »
Do you call sfRenderTexture_display after drawing everything?

Have you tried the latest sources, to solve the Intel GPU bug?
Laurent Gomila - SFML developer

Nekroze

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Flipping RenderTexture
« Reply #2 on: November 06, 2012, 10:25:26 pm »
I compiled SFML+CSFML myself about 4 days ago so i believe i have the latest version.

About the display, you are right and i am sorry that does make it work, i had previously tried bind and unbind before drawing on the RenderTexture. I am working off of the generated CSFML docs 90% of the time so i am not aware the exact use of display... or even bind.

So apologies and thank you very much.

About the intel gpu issues other then using newer sources are there any other solutions, although i doubt it, would the new use of display perhaps stop these issues? or should i just refrain from testing on my main coding laptop.

EDIT: Unrelated question, if i enable vsync will that slow down my main render loop that updates and displays the screen. or will it draw superfluous frames to the screen that are never shown?
« Last Edit: November 06, 2012, 10:32:07 pm by Nekroze »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Flipping RenderTexture
« Reply #3 on: November 06, 2012, 10:33:38 pm »
The main problem of RenderTexture / Intel GPU / Linux is normally solved, but I can't be 100% sure that it was the only one, especially with the crappy drivers of Intel :)

You can open a new topic with a complete and minimal code that reproduces this problem, if you want.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Flipping RenderTexture
« Reply #4 on: November 06, 2012, 10:34:33 pm »
Quote
Unrelated question, if i enable vsync will that slow down my main render loop that updates and displays the screen. or will it draw superfluous frames to the screen that are never shown?
First one. It will sleep in sfRenderWindow_display.
Laurent Gomila - SFML developer

Nekroze

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: Flipping RenderTexture
« Reply #5 on: November 06, 2012, 10:38:51 pm »
I will later try and trace through the app till the BSOD occurs to locate the exact problem first before i proceed further with the Intel problem. Source code may be a little more difficult as i am not very good with c/c++ so i actually use D with derelict3, tho i believe it is close enough to C that i can still ask if i cannot find my own solution.

I will, so long as you think it is a good idea leave this thread around rather then delete it because even through the answer is simple enough to shame me a little i believe at least someone else may benefit from it.

Also thanks for SFML it is a grand system that i have accomplished more in over the last few days then a much longer period i have spent on many other game engines or graphics libraries so thank you.

Awesome, that is also what i was hoping it would do when displaying!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Flipping RenderTexture
« Reply #6 on: November 06, 2012, 10:47:43 pm »
If you're on Windows, you can try to upgrade your Intel drivers to the latest version. Someone reported that it solved RenderTexture problems .
Laurent Gomila - SFML developer

 

anything