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

Pages: [1]
1
Graphics / Re: Resolution independent rendering
« on: July 11, 2014, 02:52:15 pm »
Thanks guys! The question is closed.

2
Graphics / Re: Resolution independent rendering
« on: July 11, 2014, 08:53:54 am »
It's possible that this goal is born of the resolution changes that you see in games (usually 3D). You can reduce the number of pixels rendered to increase the speed of rendering.
That's exactly what I'm talking about. In 3D games it can increase performance if you are using small resolution. Is that statement applicable for 2D games or not?

3
Graphics / Re: Resolution independent rendering
« on: July 10, 2014, 09:40:31 am »
So, I've made a new example and I was surprised that the FPS is lower when it uses double buffer.
The purpose of my question is how to increase FPS by using small resolutions? Or it's impossible?

P.S. You can toggle the drawing mode by pressing "1" button:

#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
        // Settings
        Vector2f windowSize(800, 600);
        Vector2f resolution(100, 75);
        const char* imageFile = "pic.png";
        const char* fontFile = "arial.ttf";
        bool useDoubleBuffer = true;


        RenderWindow window;
        window.create(VideoMode(windowSize.x, windowSize.y, 32), "Double buffer test", Style::Default);

        RenderTexture buffer;
        buffer.create(resolution.x, resolution.y);

        Texture texture;
        texture.loadFromFile(imageFile);

        Sprite sprite(texture);

        Vector2u textureSize = texture.getSize();
        Vector2f textureScale(windowSize.x / textureSize.x, windowSize.y / textureSize.y);
        Vector2f scale(resolution.x / windowSize.x, resolution.y / windowSize.y);

        sprite.setScale(textureScale.x * scale.x, textureScale.y * scale.y);

        Font font;
        font.loadFromFile(fontFile);

        FloatRect area(0, 0, resolution.x, resolution.y);
        window.setView(View(area));

        String fps;
        float elapsedTime = 0.0f;
        Uint32 frameCounter = 0;

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

                        if (event.type == Event::KeyPressed)
                        {
                                if (event.key.code == Keyboard::Escape)
                                        window.close();

                                if (event.key.code == Keyboard::Num1)
                                        useDoubleBuffer = !useDoubleBuffer;
                        }
                }

                elapsedTime += clock.restart().asSeconds();
                frameCounter++;

                if (elapsedTime >= 1.0f)
                {
                        fps = std::to_string(frameCounter) + " FPS";
                        elapsedTime = 0.0f;
                        frameCounter = 0;
                }

                Text text(fps, font, 20);
                text.setPosition(0, 0);

                window.clear();

                if (useDoubleBuffer)
                {
                        buffer.clear();
                        buffer.draw(sprite);
                        buffer.display();

                        sf::Sprite bufferSprite(buffer.getTexture());
                        window.draw(bufferSprite);
                }
                else
                {
                        window.draw(sprite);
                }

                window.draw(text);
                window.display();
        }
        return 0;
}

4
Graphics / Re: Resolution independent rendering
« on: July 09, 2014, 01:52:51 pm »
Let me show you small example:

#include <SFML/Graphics.hpp>

using namespace sf;

int main()
{
        Vector2f windowSize(800, 600);
        Vector2f resolution(100, 75);

        RenderWindow window;
        window.create(VideoMode(windowSize.x, windowSize.y, 32), "test", Style::Default);

        Texture texture;
        texture.loadFromFile("pic.png");
       
        Vector2u textureSize = texture.getSize();
        Vector2f textureScale(windowSize.x / textureSize.x, windowSize.y / textureSize.y);

        Sprite sprite;
        sprite.setTexture(texture);
        sprite.setScale(textureScale.x * resolution.x / windowSize.x, textureScale.y * resolution.y / windowSize.y);

        FloatRect area(0, 0, resolution.x, resolution.y);
        window.setView(View(area));

        while (window.isOpen())
        {
                Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == Event::Closed) window.close();
                        if (event.type == Event::KeyPressed && event.key.code == Keyboard::Escape) window.close();
                }

                window.clear();
                window.draw(sprite);
                window.display();
        }
        return 0;
}

By changing the value of the variable "resolution" I expect that the result will be different. But it's always the same (test1.png)
I thought that it would be something like this (test2.png) for resolution 100x75.



5
Graphics / Resolution independent rendering
« on: July 09, 2014, 12:40:42 pm »
Is it possible to separate rendering resolution and the window size?
For example, I may only want to render at 400x300 resolution, but I want my window size to be 800x600.
If so, how is this done?

6
Network / Re: const qualifier in send() function
« on: May 14, 2014, 10:51:49 am »
Ok, it's not a big problem, my workaround works fine :)

void MySocket::send(const Address& address, const sf::Packet& packet)
{
        _socket.send(packet.getData(), packet.getDataSize(), address._ip, address._port);
}

7
Network / const qualifier in send() function
« on: May 14, 2014, 10:32:07 am »
Is it possible to make first argument type const Packet& in future releases?
It doesn't look like it can be modified.

Socket::Status UdpSocket::send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort)

Pages: [1]
anything