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

Author Topic: New Shader class in SFML 2 to replace PostFx  (Read 39499 times)

0 Members and 1 Guest are viewing this topic.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #30 on: November 14, 2009, 02:10:32 am »
Quote
Quote
Guess what? I just get a white screen. Why is this? When I replace the Window.Draw line with Window.Draw(BG); it works fine. When I use this code, it absolutely fails. What am I doing wrong? I'm drawing the BG to the RenderImage, Displaying the RenderImage, then drawing the RenderImage to the Screen, and I get White. :S

Your RenderImage instance gets destroyed after the call to Draw; but SFML delays the actual drawing until you call Window.Display(), and at this time the source image doesn't exist anymore.
Moved the sf::RenderImage's Declaration to outside the if statement, in the context of the Window.Display() code. Black screen. Moved it back inside and added a Window.Flush() to the end of the if statement. Black Screen.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #31 on: November 14, 2009, 12:41:49 pm »
Can you show a simple code sample that reproduces this problem?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #32 on: November 15, 2009, 02:55:39 am »
Code: [Select]
#include <SFML/Graphics.hpp>

int main(){
    sf::RenderWindow Window;
    Window.Create(sf::VideoMode(512, 512, 32), "Test");
    sf::Image Background;
    Background.LoadFromFile("Any512x512Image.png");
    sf::Sprite BG(Background);
    //sf::RenderImage Screen; // Uncomment this line and comment the definition ahead and Flush if you want to test both
    if (sf::Shader::IsAvailable()){
        sf::RenderImage Screen;
        Screen.Draw(BG);
        Screen.Display();
        Window.Draw(sf::Sprite(Screen.GetImage()));
        Window.Flush();
    }
    else
        Window.Draw(BG);
    Window.Display();
    sf::Event Event;
    while (Window.IsOpened()){
        while (Window.GetEvent(Event)){
            if (Event.Type == sf::Event::Closed)
                Window.Close();
            if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape)
                Window.Close();
        }
    }
    return EXIT_SUCCESS;
}

There's the code that does not work for me. It draws nothing.
I use the latest build of SFML2

l0calh05t

  • Full Member
  • ***
  • Posts: 200
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #33 on: November 15, 2009, 08:59:46 am »
You do know that you are only drawing once?

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #34 on: November 15, 2009, 07:22:32 pm »
Quote from: "l0calh05t"
You do know that you are only drawing once?
Yes. I don't change what the screen shows after I draw.
I use the latest build of SFML2

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #35 on: November 17, 2009, 03:41:13 am »
Got it to work by changing the RenderImage to an Image and CopyScreen() instead of the RenderImage functions.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #36 on: November 17, 2009, 07:36:32 am »
What does RenderImage::IsAvailable() return?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #37 on: November 17, 2009, 03:35:34 pm »
Quote from: "Laurent"
What does RenderImage::IsAvailable() return?
True.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #38 on: November 17, 2009, 03:55:21 pm »
Weird. Do you run in debug mode? Is there any message in the standard error output?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #39 on: November 18, 2009, 12:24:36 am »
Quote from: "Laurent"
Weird. Do you run in debug mode? Is there any message in the standard error output?
Nothing in stderr, I use Release.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #40 on: November 18, 2009, 12:45:11 am »
Can you try debug?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #41 on: November 18, 2009, 03:01:59 am »
Has the DEBUGBUILD=yes/no changed since SFML1.x? I can't seem to get it to compile debug.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #42 on: November 18, 2009, 08:14:14 am »
No, it's the same. What's wrong?
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
New Shader class in SFML 2 to replace PostFx
« Reply #43 on: November 18, 2009, 04:19:51 pm »
Quote from: "Laurent"
No, it's the same. What's wrong?
I run make sfml DEBUGBUILD=yes, and even try setting DEBUGBUILD=yes in the makefile manually, but only the release binaries are built.
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New Shader class in SFML 2 to replace PostFx
« Reply #44 on: November 18, 2009, 04:25:08 pm »
Are you sure? The debug binaries have the same name as the release ones (yes I know, this is bad, I'm currently working to make it cleaner).
Laurent Gomila - SFML developer

 

anything