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

Pages: 1 ... 4 5 [6] 7 8 ... 31
76
General discussions / Multi Monitor Setup
« on: July 30, 2014, 12:49:42 am »
Hello there!
I think I already mentioned it in some other post, but I often have a setup, where I have a normal pc/laptop with a control window and a projector as a second screen with a fullsreen window, that displays the graphics.
There was a topic recently about multi monitor support and selecting the fullscreen monitor, but it hasn't gotten much attention. Since designing a clean and simple API for this seems tricky (things like fullscreen windows streching over multiple monitor or vertical setups have to be considered) and the process hasn't even started; I thought I'd make this suggestion.
Right now with SFML it is impossible to select the monitor for the fullscreen window. If a SFML window is created with the fullscreen flag it always goes into fullscreen on the first monitor. I think it would be way better to let the window go into fullscreen on the monitor it currently resides in. That would offer a nice way for some workarounds till a good design is found.
Right now I am using this on windows to get a window into fullscreen on the second monitor:
sf::RenderWindow window(sf::VideoMode::getFullscreenModes()[0], "Window", sf::Style::Fullscreen);

// width of first monitor is 1280, so move the window onto the second monitor
window.setPosition(sf::Vector2i(1300, 0));

MONITORINFO mi = { sizeof(mi) };

HWND hwnd = window.getSystemHandle();

// get the coordinates of the monitor the window is currently in
GetMonitorInfo(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &mi);

// move the window
SetWindowPos(hwnd, HWND_TOP,
             mi.rcMonitor.left, mi.rcMonitor.top,
             mi.rcMonitor.right - mi.rcMonitor.left,
             mi.rcMonitor.bottom - mi.rcMonitor.top,
             SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
 
Other people had similar setups/problems, so I think integrating something along those lines into the switchToFullscreen method would be a very nice addition.

77
SFML wiki / Re: Settings parser
« on: July 29, 2014, 01:35:02 pm »
Thanks for the link! Looks like an interesting library for projects that are a bit bigger. I will definitly check it out!

78
SFML wiki / Re: Settings parser
« on: July 28, 2014, 07:46:53 pm »
Ah that makes sense!
And indeed it fixed the problem. It seems like this was a part from the old code, that I forgot to refactor. Now that I look at it using !in.eof() makes no sense at all. I changed it to std::getline(...).
I wrote a little update for the class (fixed a complier warning and did some other stuff). It's on the wikipage :)

79
SFML wiki / Re: Settings parser
« on: July 28, 2014, 10:41:41 am »
I am glad you find it helpful! :)
I noticed that bug as well. I did a quick check and the write loop looks fine. There are no empty lines being written, but still one empty line appears in the file. It might be something releated to line endings, but sadly I don't really have time to investigate right now...
What system are you on?

80
Graphics / Re: Subtractiv Blend mode
« on: July 20, 2014, 09:44:07 pm »
Hmm I know this isn't the typical way of doing this, but it should still be possible, right?
I mean right now I am pretty much doing the same thing. I implemented this before SFML supported different render modes, so I am using a shader that subtracts a factor from the current pixels alpha and two render textures to make the effect persistent.
Shouldn't it be possible to do the exact same thing with the correct subtractive blend mode?

81
Graphics / Re: Subtractiv Blend mode
« on: July 20, 2014, 07:52:09 pm »
Sorry for not being percise. Ok here is what I am trying to acchive.
Think of it as if you are drawing with a pen on a paper. Every frame I draw a line from the mouse position of the previous frame to the mouse position of the current frame. The line is then drawn into a rendertexture. The rendertexture is drawn into the window. The rendertexture is never cleared to keep the picture.
Now if I want to let the lines slowly fade out based on how long they have been on the rendertexture I thought I could simply draw a black/transparent rect with a little alpha on top of it with a subtractive blend mode. And since I have problems understanding the blend mode equations I thought I'd ask :D

82
Graphics / Re: Subtractiv Blend mode
« on: July 20, 2014, 04:09:06 pm »
Yeah that is how I usually do it. But in this case that technique won't work, because I constantly draw to a rendertexture without clearing it. That's why I want to draw a semi-transparent rectangle over it, to make "older" stuff fade out.

83
Graphics / Re: Subtractiv Blend mode
« on: July 20, 2014, 12:03:23 pm »
Hmm good question. Now that I think about it I would say fading from color to transparent would be the best, because I use a renderTexture anyway then I have the option to chose a different background color when I draw to the window.

@fallahn: Awesome site! I am still overwhelmed by all the options, but I will play around a bit.

84
Graphics / Subtractiv Blend mode
« on: July 19, 2014, 12:30:27 pm »
Hello everybody!
I wanted to give the newly implemented blend modes a try and see if they can solve an issue cleaner than what I use right now (a shader). What I am trying to acchive is that a render texture fades out over time.
So my idea is to simply draw a black rect with very low alpha over the entire render texture each frame to make it slowly fade. When I use the default alpha blending mode I get weird visual artefacts. (it seems to be related to some value being very small and causing problems when multiplyed; seems to be a know problem) Thats why I wanted to try a subtractive blend mode.
I tryed to simply take the Alpha Mode and exchange the blend function from add to subtract, but that didn't work.
const sf::BlendMode BlendSubtractive(sf::BlendMode::SrcAlpha, sf::BlendMode::OneMinusSrcAlpha, sf::BlendMode::Subtract,
                                     sf::BlendMode::One, sf::BlendMode::OneMinusSrcAlpha, sf::BlendMode::Subtract);
I am a little confused to what option to choose. Could somebody with a better OpenGL knowledge explain the correct way to me?
Thanks in advance,
Foaly

85
Graphics / Re: Problem with sf::Shader after updating
« on: July 19, 2014, 01:16:14 am »
Ok nevermind. After some trying I was able to make a clean pull request. It can be found here.

edit: haha I did not understand that! sounds complicated. well I am glad this fixes it :D

86
Graphics / Re: Problem with sf::Shader after updating
« on: July 19, 2014, 12:51:09 am »
I fixed it! It's in a branch in my repo. In this commit.
Unfortunatelly I messed something up when I pulled from orgin or upstream to my repo. Because when I try to send a pull request now, I have about 150 old SFML commit together with my commit... So is there any other way you can integrate this? Or tell me how to fix it. That would be awesome!

I have one question to why it was broken before. Isn't ensureGlContext() supposed to do exactly what is done now manually? Create a dummy context.

87
Graphics / Re: Problem with sf::Shader after updating
« on: July 18, 2014, 08:46:30 pm »
Awesome thanks! I have to go now, but I will try to write a fix later.

88
Graphics / Re: Problem with sf::Shader after updating
« on: July 18, 2014, 07:37:49 pm »
Ok so I noticed that the program compiles fine in release mode, so I looked at what is done different in debug and release builds. In debug mode I log some information about the host system. The method sf::Texture::getMaximumSize() seems to break the Shader code.
The following code does not work for me (ie. the Shader is not created, and there is OpenGL errors):
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

// Shader Bug Test
int main()
{
    // comment the following line and everything works as expected
    std::cout << "Maximale Texturgröße: " << sf::Texture::getMaximumSize() << std::endl;

     // create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
    window.setFramerateLimit(60);

    if(!sf::Shader::isAvailable()) {
        std::cout << "Shader not available!" << std::endl;
    }

    sf::Shader m_FadeShader;
    m_FadeShader.loadFromFile("FadeShader.frag", sf::Shader::Fragment);
    m_FadeShader.setParameter("fRate", 0.5f);

    sf::RectangleShape rect(sf::Vector2f(200, 200));
    rect.setPosition(300, 200);

    // run the program as long as the window is open
    while (window.isOpen())
    {
        // check all the window's events that were triggered since the last iteration of the loop
        sf::Event event;
        while (window.pollEvent(event))
        {
            // "close requested" event: we close the window
            if (event.type == sf::Event::Closed)
                window.close();


            // Escape key pressed, close window
            if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
                window.close();
        }
        // clear the window with black color
        window.clear(sf::Color::Black);

        // draw everything here...
        window.draw(rect, &m_FadeShader);

        // end the current frame
        window.display();
    }

    return 0;
}
 
Shader code:
uniform float fRate;

void main()
{
    vec4 color = vec4(1.0, 1.0, 1.0, 1.0);
    color.a -= fRate;
    gl_FragColor = color;
}

89
Graphics / Re: Problem with sf::Shader after updating
« on: July 18, 2014, 05:18:50 pm »
ok i wrote a minimal example and... it compiles just fine.
So something else must be wrong. There is also two render textures involved, so I though it might be related to the context management. (because in the commit a dummy context is created)

And indead, when I move my Shader loading code before my rendertexture creation code I get the following error:
An internal OpenGL call failed in RenderTextureImplFBO.cpp (117) : GL_INVALID_OP
ERATION, the specified operation is not allowed in the current state
Impossible to create render texture (failed to link the target texture to the fr
ame buffer)
An internal OpenGL call failed in Shader.cpp (115) : GL_INVALID_VALUE, a numeric
 argument is out of range


I tryed to replicate the error with two renderTextures in a minimal example, but I couldn't. I don't really know how to debug the context code (which one is active etc.). So where do I go from here?

90
Graphics / Re: Problem with sf::Shader after updating
« on: July 17, 2014, 11:48:11 pm »
Oh i forgot to include that.
I am running a windows 8 machine with MinGW gcc version 4.8.1 and a NVIDIA card with latest drivers (337.88).
I compiled the shader example in debug and release mode and it seems to work properly.
I checked the compile setting and in debug mode there is no optimization enabled. The compile command is:
mingw32-g++.exe -std=c++11 -Wall  -pg -g -DDEBUG    -I"F:\Librarys\official SFML\install\include"  -c "F:\Eigene Programme\Crazy Painter\main.cpp" -o obj\Debug\main.o
I will try to put a minimal example together tomorrow.

Pages: 1 ... 4 5 [6] 7 8 ... 31
anything