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

Pages: [1]
1
General / Lags in recorded video
« on: August 13, 2020, 08:59:16 am »
Hello! In the recorded video (with Bandicam), lags occur at least once every 20 seconds, although everything worked smoothly while I was recording. I've have tried several screen recording programs. The result is same everywhere. In other games this does not happen, only in SFML programs. What could be the problem?

Recorded video of my game:
https://youtu.be/DlolLs5iU0s

2
Guys please help. I still have no idea how to solve this problem :(

3
Clear the render-texture with transparent, and draw to it with blending disabled (sf::Blend::None). This will keep the alpha channel unchanged on the render-texture, and interpret it only when you draw the render-texture to the window.
Like this?
renderTexture.draw(sprite, sf::RenderStates(sf::BlendNone)):
 
I fot this result:


it would help if the textures did not overlap each other. Here is edited example code in case if did somethig wrong
#include <SFML/Graphics.hpp>

using namespace sf;
int main()
{
        sf::RenderWindow window(sf::VideoMode(360, 200), "SFML works!", Style::Default);
        window.setFramerateLimit(60);

        sf::IntRect redNoteTextureBounds{ 0, 0, 184, 100 };
        sf::IntRect blueNoteTextureBounds{ 184, 0, 184, 100 }; 
        sf::IntRect longNotesTextureBounds{ 0, 100, 184, 100 };

        Texture t; t.loadFromFile("Texture.png");
        Sprite s1(t);
        s1.setTextureRect(blueNoteTextureBounds);

        RenderTexture rt;
        Sprite s2(t);
        rt.create(184, 175);
        rt.clear(Color::Transparent);

        s2.setTextureRect(blueNoteTextureBounds);
        s2.setPosition(0, 0);
        rt.draw(s2, RenderStates(sf::BlendNone));
       
        s2.setPosition(0,80);
        rt.draw(s2, RenderStates(sf::BlendNone));

        s2.setTextureRect(longNotesTextureBounds);
        s2.setPosition(0, 40);
        rt.draw(s2, RenderStates(sf::BlendNone));

        rt.display();
        s2.setTexture(rt.getTexture(), true);  
        s2.setPosition(130, 0);


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

                window.clear();
                window.draw(s1);
                window.draw(s2);
                window.display();
        }

        return 0;
}
 

4
Hello! I'm trying to get transparent texture like this (made with Photoshop)

by combining it from separate textures on transparent RenderTexture

If draw them in default blend mode and RenderTexture cleared as transparent, they loose glowing effects like in first image below. The result I want to ahcieve is like on right image, but it was cleared as black and it's not transparent


I tried all blending modes and tried unsuccessfully to write custom ones. What can I do? I think I could solve it with shaders but I didn't try yet. There's more elegant way for sure.
Here is a minimal code
#include <SFML/Graphics.hpp>

using namespace sf;
int main()
{
        sf::RenderWindow window(sf::VideoMode(360, 200), "SFML works!", Style::Default);
        window.setFramerateLimit(60);

        sf::IntRect redNoteTextureBounds{ 0, 0, 184, 100 };
        sf::IntRect blueNoteTextureBounds{ 184, 0, 184, 100 }; 
        sf::IntRect longNotesTextureBounds{ 0, 100, 184, 100 };

        Texture t; t.loadFromFile("Texture.png");
        Sprite s1(t);
        s1.setTextureRect(blueNoteTextureBounds);

        RenderTexture rt;
        Sprite s2(t);
        rt.create(184, 175);
        rt.clear(Color::Transparent);

        s2.setTextureRect(blueNoteTextureBounds);
        s2.setPosition(0, 0);
        rt.draw(s2, RenderStates());
       
        s2.setPosition(0,80);
        rt.draw(s2, RenderStates());

        s2.setTextureRect(longNotesTextureBounds);
        s2.setPosition(0, 40);
        rt.draw(s2, RenderStates());

        rt.display();
        s2.setTexture(rt.getTexture(), true);  
        s2.setPosition(130, 0);

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

                window.clear();
                window.draw(s1);
                window.draw(s2);
                window.display();
        }

        return 0;
}
 

5
Thank you!

OMG! A year ago, I tried a lot of different driver versions for Intel HD graphics 4000 and did not succeed. This time I was sure that the matter was not in the driver and did not touch it. When I saw your reply, I decided to check and update if there are new versions. Problem solved! The new driver was 6 months older. Thanks for the quick response!

But why in other applications I did not notice problems with the full screen mode? After all, at a lower level, it all comes down to using the same piece of code (commands for full-screen mode in our case)?

And why it's working so slow on AMD discrete graphics card? The simple example above runs at about 40-50 FPS whith a long lags and uses 30% of my laptops i3-3120M CPU. Yes it is very old, but when it's running on integrated Intel GPU it uses almost 0%. I'll try to update AMD driver too, just in case =)

6
Hello! I've finally released my EasyPianoGame on Steam: https://store.steampowered.com/app/1126220/EasyPianoGame/

I knew a problem about crashing in fullscreen style for a long time. I could not solve it at that moment and just used
sf::VideoMode::getFullscreenModes();
sf::RenderWindow window (FSModes[0], "", sf::Style::None);
 
and forgot afbout it.

After launch, some players started complaining about resolution problems and I decided to add resolution change feature.
So what is going on: When I create fullscreen window like this
sf::RenderWindow window(sf::VideoMode::getFullscreenModes()[0], "", sf::Style::Fullscreen);
 
it crashes. Not necessarily every time but often enough. And also some times the program crashes when the window closes. It happens when I run program on Intel GPU. In AMD GPU it works fine, but super slow and heavily loads the CPU, this is another problem.

Here is example code:
#include <SFML/Graphics.hpp>

int main()
{
        auto FSModes = sf::VideoMode::getFullscreenModes();

        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        window.setFramerateLimit(60);

        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();

                        if (event.type == sf::Event::KeyPressed)
                                switch (event.key.code)
                                {
                                case sf::Keyboard::Escape:
                                        window.close();
                                        break;
                                case sf::Keyboard::Num1:
                                        window.create(FSModes[3], "", sf::Style::None);
                                        break;
                                case sf::Keyboard::Num2:
                                        window.create(FSModes[3], "", sf::Style::Default);
                                        break;
                                case sf::Keyboard::Num3:
                                        window.create(FSModes[3], "", sf::Style::Fullscreen);
                                        break;
                                case sf::Keyboard::Num4:
                                        window.create(FSModes[0], "", sf::Style::None);
                                        break;
                                case sf::Keyboard::Num5:
                                        window.create(FSModes[0], "", sf::Style::Fullscreen);
                                        break;
                                }

                        if (event.type == sf::Event::MouseButtonPressed)
                        {
                                auto pos = sf::Mouse::getPosition();
                                shape.setPosition(pos.x - shape.getRadius(), pos.y - shape.getRadius());
                        }
                }

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

        return 0;
}
 

Non full-screen window style switches work fine, but when you switch to full-screen style, with a probability of 50% it will crash. Debugger shows unhandled exception in ig7icd32.dll

Pages: [1]