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 - Contadotempo

Pages: [1] 2 3 ... 12
1
Graphics / Re: Motion Blur GLSL
« on: March 23, 2016, 01:32:37 am »
Thank you, I believe my lack of knowledge about GLSL got me stumped here.

I tried replacing the
mat4 proj_modelview_mat = projection_mat * modelview_mat;
with
mat4 proj_modelview_mat = gl_ModelViewProjectionMatrix;

And added accordingly:
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;

But didn't have much success.

What I was trying to accomplish was a trailing effect like the image bellow:


However I didn't know where to start. I thought learning per object motion blur with GLSL would be a good start, but not knowing the language is a barrier. Could anyone guide me on how to achieve this?

Also, some examples suggest acquiring the previous framebuffer or the previous view-projection matrix. How could I do this with or without SFML? I hope this isn't a stupid question...


2
Graphics / Motion Blur GLSL
« on: March 13, 2016, 05:57:37 pm »
Hello,

I'm trying to load a motion blur shader in GLSL using sf::Shader, however I'm having some trouble applying it to a sprite, as it seems to be completely hide it (i.e. the sprite isn't even drawn, maybe it's loosing its alpha value?) instead of blurring on movement. I've implemented a minimal snippet that reproduces this problem, but I'm inclined to say the problem relies with the GLSL shaders. I've also attached the shaders and resources to this post.

#include <cmath>
#include <iostream>
#include <SFML/Graphics.hpp>

const double PI = std::atan(1.0) * 4;

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Shader",
                sf::Style::Titlebar | sf::Style::Close);

        window.setFramerateLimit(60.f);

        sf::Texture m_texture;
        if (!m_texture.loadFromFile("eff08b.png"))
                return EXIT_FAILURE;

        sf::Sprite m_sprite;
        m_sprite.setTexture(m_texture);
        m_sprite.setOrigin(m_sprite.getGlobalBounds().width / 2.f, m_sprite.getGlobalBounds().height / 2.f);

        sf::Shader m_shader;
        if (!m_shader.loadFromFile("motionblur.vert", "motionblur.frag"))
                return EXIT_FAILURE;

        m_shader.setParameter("scene", sf::Shader::CurrentTexture);

        sf::Clock time;
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                float amplitude = 100.f;
                m_sprite.setPosition(amplitude * std::sin(PI * 0.5 * time.getElapsedTime().asSeconds()) + 400.f, 300.f);
                m_sprite.rotate(5.f);

                window.clear(sf::Color(255, 255, 255));
                window.draw(m_sprite, &m_shader);
                window.display();
        }

        return EXIT_SUCCESS;
}

Sadly I'm not too experienced in GLSL, so ended up using this implementation (slide 29): http://www.stevenlu.net/files/motion_blur_2d/Fragment_shader_dynamic_blur.pdf .

Am I missing something really simple?

Best regards

3
System / Re: Problem with sf::sleep (freeze)
« on: February 19, 2014, 12:31:31 pm »
I think your program runs as expected, but std::cout outputs nothing until you use std::endl or std::flush. The behaviour depends on the platform: some may buffer text forever, some others may output text after a while, etc.
Ah I see. I was confused because it did output the "here" string on windows but not on Linux. Probably didn't explain that too well. In that case I'm more relieved.

Thanks,
Best regards

4
System / Problem with sf::sleep (freeze)
« on: February 19, 2014, 11:39:05 am »
Hello,

For some reason using an sf::sleep with an std::cout and no std::endl makes my program freeze forever:

#include <iostream>
#include <SFML/System/Sleep.hpp>

int main(int argc, char ** argv)
{
    while(true)
    {
        std::cout << "here";
        sf::sleep(sf::seconds(0.5f));
    }

        return 0;
}
 

However if I remove sf::sleep or if I add std::cout << "here" << std::endl; it works just fine. In addition, this was compiled in Ubuntu 12.04 (64-bit) with g++ 4.6.3, but for some reason the problem doesn't seem to happen in Windows (compiled with mingw/g++ 4.8 ).

What could be the problem here?

Thanks in advance,
Best regards

EDIT: Adding a std::cin.ignore(std::numeric_limits<int>::max(),'\n'); also seems to fix the problem for a while. This leads me to believe it could be a buffer problem? But why does sf::sleep affect this?

EDIT: Adding an std::flush also seems to work.

5
Thank you, I also came to believing that dropping statics libs because of the need to explicitly link a few dependencies, is a bit silly, and it actually makes more sense after reading a bit further.







6
Ah, that makes sense. Thanks for the quick reply.

everyone using the source directly should be aware of "undocumented" changes. ;)
I usually am with SFML but since 2.1 came out I've slacked off a bit.  ;D

EDIT:
Ok, done. This is my dependency list for Visual Studio 2013:
Code: [Select]
sfml-audio-s.lib
sfml-graphics-s.lib
sfml-window-s.lib
sfml-system-s.lib
glew.lib
opengl32.lib
freetype.lib
jpeg.lib
ws2_32.lib
gdi32.lib
winmm.lib
Isn't this a bit overkill? And I'm missing openAL there since I'm not using sounds. Really considering using dynamic libs to be honest.

7
General / Visual Studio 2013 and MinGW, linker with unresolved externals
« on: November 12, 2013, 08:32:03 am »
Hey guys

I'm trying to compile an example project with the static SFML 2.1 libs using both compilers mentioned in the title.
For some reason both compilers give me the following unresolved externals for the example source code I'll post next:

Code: [Select]
error LNK2001: unresolved external symbol __imp__glBlendFunc@8
error LNK2001: unresolved external symbol __imp__glClear@4
error LNK2001: unresolved external symbol __imp__glClearColor@16
error LNK2001: unresolved external symbol __imp__glColorPointer@16
error LNK2001: unresolved external symbol __imp__glDisable@4
error LNK2001: unresolved external symbol __imp__glDrawArrays@12
error LNK2001: unresolved external symbol __imp__glEnable@4
error LNK2001: unresolved external symbol __imp__glEnable@4
error LNK2001: unresolved external symbol __imp__glEnableClientState@4
error LNK2001: unresolved external symbol __imp__glLoadMatrixf@4
error LNK2001: unresolved external symbol __imp__glLoadMatrixf@4
error LNK2001: unresolved external symbol __imp__glMatrixMode@4
error LNK2001: unresolved external symbol __imp__glMatrixMode@4

The source code is from the tutorial example:
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

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

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

I'm linking against: sfml-audio-s.lib, sfml-graphics-s.lib, sfml-window-s.lib, sfml-system-s.lib, on Release settings. SFML_STATIC is defined in the Preprocessor. I've recompiled SFML from source for each compiler, the linker errors are the same (or very similar).

I don't know what I could be missing here. They seem to be related to openGL, but I'm not using it directly anywhere, well maybe except for SFML itself. Any heads up?

Thank you for your time.

EDIT:
I think I should mention that I was previously using SFML 2 with windows 7, everything was working fine. Now I've reformatted to windows 8.1 and this started to happened. Graphics drivers are up to date as well.

8
Graphics / Re: Image Deformation in SFML
« on: October 21, 2012, 01:23:24 am »
There's this class on the wiki:
http://www.sfml-dev.org/wiki/en/sources/stroke

Although I haven't tested it myself it might give you what you're looking for (check the demonstration video). It was written by Spiddy, who is also working on a SHMUP I believe.

9
General / Re: Is there a way to initialize this struct at instantiation?
« on: October 12, 2012, 10:27:42 pm »
EDIT: Whoops, Laurent got it first.

You could make your own constructor. Something like:
MenuItem(int left, int top, int width, int height, eButtonAction myaction)
{
        rect.left = left;
        rect.top = top;
        rect.width = width;
        rect.height = height;
        action = myaction
}

Or more efficiently, with a constructor using an initialization list and a sf::Rect<int> as a parameter:
MenuItem(const sf::Rect<int>& myrect, eButtonAction myaction):
rect(myrect),
action(myaction)
{

}

Then you could create an object like this:
MenuItem playButton(110, 265, 200, 50, RT_PLAY)
or with the second constructor:
MenuItem playButton(sf::Rect<int>(110, 265, 200, 50), RT_PLAY)

10
General / Re: White screen
« on: October 07, 2012, 08:40:03 pm »
You forgot window.display() at the end.

11
General discussions / Re: SFML 2.0 RC
« on: September 29, 2012, 12:11:50 am »
Don't know, might have done something wrong cause it just didn't want to generate the needed files. Gave some error I don't remember but that didn't make sense.
Are you using the express edition by any chance? It seems there was a bug with Visual Studio express 2012 and cmake 2.8.9
Take a look at this, it was fixed on cmake 2.8.10:
http://public.kitware.com/Bug/view.php?id=13348

And this for an alternative fix:
http://stackoverflow.com/questions/12434696/visual-studio-express-2012-and-cmake

12
General / Re: Ways to raise FPS
« on: September 25, 2012, 08:02:47 pm »
Consider using std::vector's reserve() function. Reserve the maximum number of bullets you're intending to use (5000 for example). It should solve your slowdown problems at the beginning of the program.

Think about using vertexarrays, also. You could easily reach 10000 bullets with some work.

13
Graphics / Re: SFML 1.6 Colour Issue?
« on: September 01, 2012, 08:35:14 pm »
Argh! I am sorry Laurent... SetColor... Why do I never notice these things?!
He means that you must post all the relevant source code (while being minimal) that produces this glitch, like the short example shown here: http://www.sfml-dev.org/documentation/2.0/

14
Audio / Re: Odd sound quality
« on: August 24, 2012, 12:34:56 am »
EDIT: The problem came back today when I first turned on the computer. So once again I deleted all openAL components (the ones supplied with the sound card's driver) and manually installed the openAL32.dll supplied by the SFML commit. Now it works again... I don't get it...

__________

Sorry for the double post but I guess you were right. It was a conflicting openAL DLL somewhere, just not sure where.

Uninstalled everything related to Creative and used driversweeper to delete any driver leftovers.
Installed everything again but the problem persisted.
Went to system32 and deleted the openAL32.dll that the Creative installer put there automatically.
Then I went to the Creative's install folder which is in X:\Program Files (x86)\Creative and manually installed an openAL file that I found in this folder.
Now surprisingly any sound plays correctly now.

I don't really understand especially because this openAL's version that I installed manually is also 6.14.357.24. Well at least it's working.

Also, I have to admit I thought this was SFML's fault at the start because I've never had a problem of this sort before, so I'm sorry for assuming...

Best regards.

15
Audio / Re: Odd sound quality
« on: August 23, 2012, 11:26:35 pm »
Quote
Are you really sure that your program is not using another OpenAL DLL
Yeah seems clean. Only using a single openAL dll file.
Also, I  kind of went with an extreme solution and changed the sound card, and now it works just fine.

I was using a Creative Sound Blaster Audigy SE and changed it to the default onboard sound card that comes with the motherboard (VIA VT1708S). If I change it back to the Creative sound card again, the problem comes back.

I've never had this sort of problem before and I've been using this Creative card for years so this makes me a bit sceptical. The driver is up to date, all Creative enhancements and extras are disabled.

Odd but I'll try to investigate and see if I can find a solution. First I'll try to remove the drivers completely and reinstall them I guess.

Thanks.


Pages: [1] 2 3 ... 12