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

Author Topic: sf::RenderTexture::Create() produces black screen  (Read 1783 times)

0 Members and 1 Guest are viewing this topic.

Mira

  • Newbie
  • *
  • Posts: 3
    • View Profile
sf::RenderTexture::Create() produces black screen
« on: August 10, 2011, 11:36:30 pm »
Hello everyone.

I am using SFML 2.0 and I noticed that sf::RenderTexture behaves strangely in some situations.

In my game, I use RenderTexture to avoid redrawing all the tiles on the screen each frame. I draw the whole screen + some extra tiles to RenderTexture once, then I get sprite from this RenderTexture and draw it to the RenderWindow to show my level to the player as long as his/her character stays in the bounds of RenderTexture. If he crosses the bounds, I am just adding some tiles to the RenderTexture and displaying the new picture on the screen. Works like a charm.

Though not everywhere. I tested this on my desktop, which has nVidia GPU, and everything is displayed just like I expect. Recently, I tried launching my game on my laptop, and what I see there when I start the game is black screen only. Laptop has an integrated Intel video card.

I found a way to show minimal code pretty fast.
I took the entire code of pong example, and after this line:

Code: [Select]
sf::RenderWindow window(sf::VideoMode(800, 600, 32), "SFML Pong");

I just added
Code: [Select]
sf::RenderTexture texture;
texture.Create(800,600);


You may provide Create() with any arbitrary numbers.

I am not drawing this texture, not using it anywhere in this example, just using Create(), and this already shows the result. On my desktop, I can see the game, but on the laptop, only the "You lost!" text appears a few seconds after launching the game.

Also, I use RenderWindow::Create to switch video mode from my game's main menu. This works good on my desktop; on the laptop the game just silently quits on Create(), though this problem is not as critical as the previous one.

Is that expected? Or am I doing something wrong?
Both computers run Ubuntu 11.04. Thanks in advance.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::RenderTexture::Create() produces black screen
« Reply #1 on: August 11, 2011, 08:13:57 am »
Intel integrated and RenderTexture don't mix very well. I don't know if there's something I can do, or if it's just their drivers being too crappy.

I'll probably investigate this problem in a future minor release of SFML.
Laurent Gomila - SFML developer

Mira

  • Newbie
  • *
  • Posts: 3
    • View Profile
sf::RenderTexture::Create() produces black screen
« Reply #2 on: August 11, 2011, 08:55:47 am »
Thank you very much for your reply, now I at least know for sure that I should use some temporary solution to avoid this.

Then I guess RenderWindow::Create() fails to recreate window due to the same reason, for example crappy Intel drivers or whatever. If that helps, I can say that I only tested on Ubuntu machines, and so I don't know whether other platforms have the same problem. Maybe'll test later.

Thanks again :)