SFML community forums

General => General discussions => Topic started by: binary1248 on April 12, 2012, 09:55:57 pm

Title: Broken stuff
Post by: binary1248 on April 12, 2012, 09:55:57 pm
Code: [Select]
#include <SFML/Graphics.hpp>

int main() {
sf::RenderWindow app_window( sf::VideoMode( 400, 300 ), "Ghost Square" );

sf::RenderTexture render_texture;
render_texture.create( 400, 300 );

while ( app_window.isOpen() ) {
sf::Event event;

while ( app_window.pollEvent( event ) ) {
if ( event.type == sf::Event::Closed ) {
app_window.close();
}
}

render_texture.draw( sf::RectangleShape( sf::Vector2f( 200, 200 ) ) );
render_texture.display();
render_texture.clear();

// Just to be sure.
render_texture.display();

// The RenderTexture SHOULD BE cleared to black here right?

render_texture.draw( sf::RectangleShape( sf::Vector2f( 100, 100 ) ) );
render_texture.display();

app_window.clear();

sf::Sprite sprite;
sprite.setTexture( render_texture.getTexture() );
app_window.draw( sprite );

app_window.display();
}

return EXIT_SUCCESS;
}

Hopefully it is obvious what is broken.

And at the same time you can fix https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/RenderTextureImplFBO.cpp#L56, c&p error I guess ^^.
Title: Re: Broken stuff
Post by: Laurent on April 12, 2012, 10:08:56 pm
Sorry, but I don't know what's broken, and what must be fixed at line 56. Could you please explain?
Title: Re: Broken stuff
Post by: binary1248 on April 12, 2012, 10:26:28 pm
According to doc render_texture.clear(); should clear the color buffer to the color (black by default) set. Running render_texture.clear(); does not get rid of the white square. It is still there although I clear AFTER drawing the square.

And as for L56: glDeleteRenderbuffersEXT?
Title: Re: Broken stuff
Post by: Laurent on April 12, 2012, 10:44:14 pm
Quote
According to doc render_texture.clear(); should clear the color buffer to the color (black by default) set. Running render_texture.clear(); does not get rid of the white square. It is still there although I clear AFTER drawing the square.
No, you also draw a square after clearing.

Quote
And as for L56: glDeleteRenderbuffersEXT?
Ah, I guess you're right :)
Title: Re: Broken stuff
Post by: binary1248 on April 12, 2012, 10:54:09 pm
Quote
According to doc render_texture.clear(); should clear the color buffer to the color (black by default) set. Running render_texture.clear(); does not get rid of the white square. It is still there although I clear AFTER drawing the square.
No, you also draw a square after clearing.

Yeah a smaller square... on top of the bigger one. That SHOULD produce a clean white square on a black background, however it does not. If you comment that out you will notice the bigger one still lingering there by itself.
Title: Re: Broken stuff
Post by: Laurent on April 12, 2012, 11:03:08 pm
It works as expected on my machine. What graphics card / OS / drivers do you have?
Title: Re: Broken stuff
Post by: binary1248 on April 12, 2012, 11:09:32 pm
AMD Radeon HD 5850 with Catalyst 12.1 on Windows 7

(http://img696.imageshack.us/img696/2338/ghostb.png) (http://imageshack.us/photo/my-images/696/ghostb.png/)
Title: Re: Broken stuff
Post by: Laurent on April 12, 2012, 11:12:41 pm
Have you tested on other computers?

I'll try to test it this week-end with my AMD graphics card.

Quote
Windows 7
With a Windows 98 theme? :P
Title: Re: Broken stuff
Post by: binary1248 on April 12, 2012, 11:22:22 pm
Quote
Windows 7
With a Windows 98 theme? :P

You make it sound like it's something bad... I am a Linux user too btw. ^^ an ArchLinux user... on openbox.
Title: Re: Broken stuff
Post by: Laurent on April 13, 2012, 08:01:35 am
Quote
You make it sound like it's something bad...
It's just strange to decide to use a 14 year old window theme, instead of just keeping the default one which looks much better.

Quote
I am a Linux user too btw. ^^ an ArchLinux user... on openbox.
I don't know OpenBox but from what I've read that could explain your choice ;D
Title: Re: Broken stuff
Post by: Silvah on April 13, 2012, 06:52:23 pm
Quote
You make it sound like it's something bad...
It's just strange to decide to use a 14 year old window theme, instead of just keeping the default one which looks much better.
It's equally strange to decide to use a new window theme that happens to be the default, instead of changing it to an old and trustworthy one which looks much better :P

You know, de gustibus non est disputandum.
Title: Re: Broken stuff
Post by: binary1248 on May 11, 2012, 01:16:42 am
So.... after reviewing the commits from the last month I didn't notice glDeleteRenderbuffersEXT getting fixed.. and did you get around to test it on your AMD card?
Title: Re: Broken stuff
Post by: Rosme on May 11, 2012, 06:03:54 am
I get something similar with a convexshape(triangle). If I change the position of the triangle, I get two triangle. And if I move it again, I get three, etc. I found that if I draw something after with a direct call to a window.draw(), so no sf::RenderTexture, it fixed the problem for some reason.

My video card is an AMD Radeon HD 6850