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

Pages: [1]
1
A bit late, but in case someone else will come by..
You could also use callbacks to swap between waitEvent and pollEvent, allowing you to use the same event handling loop:


sf::Window window;
//An array of callbacks, in which we store both functions:
bool (sf::Window::*windowEventCallbacks[])(sf::Event&) = {
        &sf::Window::pollEvent,
        &sf::Window::waitEvent
};
unsigned currentCallbackIndex = 0;

while (window.isOpen)
{
        sf::Event e;
        //use the right callback, using the current index:
        while (  (window.*windowEventCallbacks[currentCallbackIndex])(e)  )
        {
                switch (e.type)
                {
                case sf::Event::KeyPressed:
                        if (e.key.code == sf::Keyboard::Escape)
                        {
                                //pause game - swap callbacks, to use waitEvent:
                                currentCallbackIndex++;
                                currentCallbackIndex %= 2; //to loop back when it is greater than 1.
                        }
                        break;
                        /* ... handle events ... */
                }

        }
}

2
General discussions / sf::RenderWindow::getMouseCursorVisible() ?
« on: March 21, 2018, 07:47:46 pm »
Hi,
Is there any way in SFML to determine the current state of sf::RenderWindow's "settings"?
By "settings" I mean all the functions like setMouseCursorVisible(), setMouseCursorGrabbed(), setVerticalSyncEnabled() and so on.

I have a function that gets a sf::RenderWindow, and calls some of these functions, and I would like my function to be able to 'clean up' after itself, so that the window will return to it's original state after the function returns.

3
That is correct but actually not on point. And in typical windows software projects, one does not compile with static crt, redistributable packages of the vc++ runtime exist for a reason because they are meant to be shared between applications. Using static third party libs on windows is totally reasonable, that's why they are already provided by the official distribution.
As written in Crypto++'s wiki:
Quote
If you switch to dynamic linking, there's an increased attack surface because a DLL can be changed or redirected at loadtime. Both Windows and Linux suffer the DLL tricks; see, for example, Breaking the Links: Exploiting the Linker on Linux or search for Binary Planting on Windows.
So to my understanding static linking CRT is good, but not if security is something that is important for your program.

4
Graphics / Re: Off Screen Rendering Antialiasing
« on: October 14, 2017, 08:44:59 pm »
See and test this pull request.
Thanks :D
But it seems that a shader can do that anyway, so i'd rather not use a non 'public release' (if thats the term) build, if possible, as I am just getting to know SFML.
To be honest I just didn't think of using shaders for some reason.

Quote
...as you're not transferring image data between CPU and GPU.
I was not aware of the difference between sf::RenderTexture and sf::Image (as described on this post).

So to conclude, is using sf::RenderTexture for off screen rendering not bad, but rather just the data tranferring between sf::RenderTexture and sf::Image, despite binary1248's asnwer?

Anyways, thanks a lot, it really helps ;D
Elro

5
Graphics / Off Screen Rendering Antialiasing
« on: October 13, 2017, 04:13:37 pm »
I am working on a small Top-down perspective game, where there is a 'vision' system, with shadows hiding stuff the player souldn't be able to see (like behind walls, or behind his back).
I use a sf::RenderTexture as a canvas, where i manage all the shadows for a player's screen(ConvexShapes drawn to it, then i convert it to an sf::Image, to use the createMaskFromColor function, to eliminate the non-shadow background. It will matter mostly for multiplayer, where i want to create a 'shared' vision for the entire team).
My problem is that when i draw my RenderTexture to the game window (sf::RenderWindow) it's pixelated. I'm new to SFML, and quite new to graphics in general, so if what I'm looking for is not antialiasing please forgive me.
Also,
I looked around a little and checked on the forum for this, and I saw that binary1248 said that RenderTexture "wastes a considerable amount of GPU resources both in terms of processing time and memory usage." (on this post: https://en.sfml-dev.org/forums/index.php?topic=22147.0 )
So is it really that bad to use RenderTexture?
If so, what should i use for off-screen rendering? (I saw the potential use of views, but I still can't see a way of replacing the Image::createMaskFromColor)
Is there any other way to supposingly 'erase' something drawn? (right now i am redrawing white to the temporary canvas, and then i set the alpha of white to 0, as mentioned above, to erase shadows before i draw them)
And last, if RenderTexture is still what i need to use, how do I make the shadows drawn from the RenderTexture smoother?
Sorry for the long post  ;D

Pages: [1]