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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cire

Pages: 1 ... 4 5 [6] 7 8 ... 10
76
General / Re: SFML 2.0 Shader Masking
« on: December 04, 2012, 09:27:54 am »
Yes! This is EXACTLY what I was going for!

Well, if it's EXACTLY what you're going for, I applied a little gaussian blur to your light.png to soften the rays up in the image

77
General / Re: SFML 2.0 Shader Masking
« on: December 04, 2012, 03:43:41 am »
I don't know if this is what you're going for, but...

#include <SFML\Graphics.hpp>
#include <SFML\System.hpp>
#include <SFML\Window.hpp>
#include <iostream>

void main()
{
    sf::RenderWindow _window(sf::VideoMode(800, 480, 32), "Lighting Test");
    _window.setFramerateLimit(60) ;

    sf::RenderTexture plainScene ;
    plainScene.create(_window.getSize().x, _window.getSize().y);

    sf::RenderTexture shadedScene;
    shadedScene.create(_window.getSize().x, _window.getSize().y) ;

    sf::Texture texture;
    texture.loadFromFile("image.png");
    sf::Sprite sprite = sf::Sprite(texture);
    sf::Sprite sprite2 = sf::Sprite(texture);
    //sprite.setTexture(texture);
    sf::Texture backgroundTexture;
    backgroundTexture.loadFromFile("light2.png");
    sf::Sprite background = sf::Sprite(backgroundTexture);
    //background.setTexture(backgroundTexture);

    sf::Shader lightingShader ;
    lightingShader.loadFromFile("lightingShader.frag", sf::Shader::Type::Fragment);
    lightingShader.setParameter("exposure", 0.008f);
    lightingShader.setParameter("decay", 0.97f);
    lightingShader.setParameter("density", 0.97f);
    lightingShader.setParameter("weight", 5.5f);
    lightingShader.setParameter("lightPositionOnScreen", sf::Vector2f(0.5f, 0.5f));

    sf::RenderStates renderState(&lightingShader) ;
 

    while (_window.isOpen())
    {
        int x = sf::Mouse::getPosition(_window).x;
        int y = sf::Mouse::getPosition(_window).y;

        sf::Event sfEvent;

        while(_window.pollEvent(sfEvent))
        {
            switch(sfEvent.type)
            {
                case sf::Event::Closed: _window.close();
                    break;
                case sf::Event::KeyPressed:
                    if(sfEvent.key.code==sf::Keyboard::Q) _window.close();
                    break;
                default: break;
            }
        }

        sf::RenderStates blendState(sf::BlendAlpha) ;

        sprite.setPosition(x - 504, y - 360);

        plainScene.clear() ;
        shadedScene.clear() ;
        _window.clear() ;

        plainScene.draw(background) ;
        plainScene.draw(sprite) ;
        plainScene.display() ;

        shadedScene.draw(sf::Sprite(plainScene.getTexture()), renderState) ;
        shadedScene.display();
         
        _window.draw(sf::Sprite(plainScene.getTexture())) ;
        _window.draw(sf::Sprite(shadedScene.getTexture()), sf::RenderStates(sf::BlendAdd));    
        _window.display();
    }
}



78
SFML projects / Re: Survive and Thrive
« on: December 03, 2012, 08:08:11 am »

79
Graphics / Re: SFML 2.0 equivalent of SFML 1 Image::LoadFromPixels?
« on: December 03, 2012, 03:11:26 am »
Is it really that hard to visit the documentation for sf::Image?

80
General / Re: Having lots of trouble with sf::Clock and sf::Time
« on: December 02, 2012, 06:49:51 am »
recoil is resetting the time elapsed every time you call it.  That's probably not the behavior you want.


81
Window / Re: "Windowed Fullscreen" mode?
« on: December 01, 2012, 12:33:04 am »
If you're holding the ALT key down while you're tabbing and another window has the focus, Windows will show you a snapshot of the screen you're previewing.  That doesn't mean your program has stopped or is experiencing a delay.  It means Windows is showing you a snapshot.

82
Graphics / Re: sf::Texture out of scope?
« on: November 28, 2012, 06:16:03 am »
Quote
I am trying my best to follow the guidelines ... minimal and complete.

Minimal - smallest amount of code that reproduces the problem.
Complete - You can toss it into the compiler and have it work.

Guess which one you're short on?  =)

There would be no need to reload the texture every time you create a new "Unit" and it doesn't look like there should be a need for you to use setTexture on the sprite every time you draw it either.  But, there's not much to go on here.

83
Graphics / Re: sf::Texture out of scope?
« on: November 28, 2012, 04:06:24 am »
Quote
Personally, I disagree with this.  If Tacostomp is just trying to learn SFML, building a use-able resource manager (even a super simple one) is solving a problem that isn't getting him to his goal.  If using a global eases his pain and doesn't get in his way, then it's a good solution.

While I agree with the sentiment, initialization order of global objects can be problematic with SFML, so I would keep away from them for that reason.

84
Graphics / Re: sf::Sprite vector reference to sf::Texture vector
« on: November 27, 2012, 04:15:58 pm »
If a push_back to tileSheets results in a tileSheets needing to expand, all the references to textures in sprTiles will be invalidated.

You might try using a std::deque for tileSheets.

85
General / Re: SFML 2.0 Shader Masking
« on: November 27, 2012, 06:12:46 am »
The shader effect only works if I pass it through as a parameter with a RenderTexture being drawn with it. Passing the shader through as a parameter with a sprite being drawn applies the shader effect incorrectly, as the crepuscular rays do not change dynamically if I move the sprite around with my mouse.


When you draw a sprite, you don't expect it to affect an area other than where the sprite is drawn.  Only affecting the sprite, which is what you're seeing, is the correct behavior.  I think the bottom line is you can't expect to take a shader from somewhere and expect to plug it in and work exactly the way you want in your program.  To get the effect you want, you're going to have to do more work. I would guess that's going to require another texture object and some blending code.

You might want to check around 13.5.1 at the following link:
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html

86

Quote
What is needed is a magical way to force people to read the documentation.

If you say so.  Personally, I thought I did pore over the documentation, but I'm guessing I didn't because otherwise why would you tell me I didn't?  Far be it for me to tell you what I did.

In fact, you told us what you did:

Quote
You know, I was going to complain about that link, I *have* been reading those documents.  But then I realized the sprite page did describe the issue I was running into.  I read it the first time I read over the page, but on subsequent visits I didn't hit the 'more' link and so missed it (and had forgotten the warning about keeping the texture alive, although I did remember that they were kept separate which caused unnecessary fears on my part).

You read and didn't retain.  Then you went back and failed to reread (the magical 'more' link just scrolls the page down.)  This doesn't indicate a deficiency in the documentation.  I'm not sure why you want to take my comments as a personal attack.  You say the evidence is obvious, but don't present any. Presenting some would be the logical response.


Quote
I'm complaining about the expectation that reading the documentation is enough when the documentation is incomplete.  I had to read the source.  And that's fine, I'm a developer, not a big deal, but I don't like being told to read documentation when it's obviously incomplete.

It's quite possible there are areas of the documentation that are lacking, and I'm sure if you were to bring them to Laurent's attention he would be happy to fix them, but this particular case isn't one of them.

I don't see this conversation going anywhere constructive, so I'll be taking my leave.  Good luck to you.

87
And your documentation isn't enough.  The evidence for that is clear, but I'm going to shut my mouth about it.  It's apparent you would rather spend your time answering the same question every day than to admit that the documentation should probably be improved.  It's your time to spend.
I'm actually not seeing any evidence at all.

 
That's not enough or we wouldn't be seeing even more posts about this exact issue.


I did a little searching.  The issue actually seems to be pretty rare on the forums, as far as I could determine using google to search the site.  I found 3 subjects that were obviously related to your assumption in skimming the first 70 or so hits.

http://en.sfml-dev.org/forums/index.php?topic=8586.0
http://en.sfml-dev.org/forums/index.php?topic=8112.0
http://en.sfml-dev.org/forums/index.php?topic=7930.0

The question apparently doesn't come up all that often.  All of them could've been resolved by reading the documentation.  Your assumption could've been resolved by reading the documentation.   What is needed is a magical way to force people to read the documentation.

88
Graphics / Re: Sprite not displaying when used in a class
« on: November 23, 2012, 07:58:13 am »
In the constructor:
     float x = Width / 2;
     float y = Height / 2;

These local variables go out of scope so later, when you do:

void Ball::Update(float DeltaTime)
{
         sprite.setPosition (x , y);
}

The x and y in the class have not been set to anything meaningful.

89
Graphics / Re: sf::View, Viewports and scaling - Default behavior
« on: November 22, 2012, 07:58:16 am »
Gyscos.. you rock.  I don't know how long I was fussing around with that.

Thanks!

eXpl0it3r, I understood them well enough.  It seems I just made a simple mistake specifying the viewport.   :(


[edit:  Now that I think back on it, that's what I had originally, but I was experiencing a problem with a tiled texture displaying correctly and I must've accidentally changed it at some point -- live and learn.  All working correct now! :)]

90
Graphics / Re: sf::Texture out of scope?
« on: November 22, 2012, 07:06:15 am »
I think it's a pretty common solution for people to use some sort of resource manager.

You may look to http://en.sfml-dev.org/forums/index.php?topic=9670.0  for inspiration.  I wouldn't be surprised if there were other similar code posted around here.  There's an interesting resource manager implementation on the wiki, although I believe it uses v1.6 of SFML so it may require some adjustments -- still a good source for ideas.

Pages: 1 ... 4 5 [6] 7 8 ... 10