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.


Topics - JAKUBW

Pages: [1]
1
General / sf::Text destruction causes segfault
« on: March 22, 2018, 07:09:44 pm »
Hey everyone, I have got a question. Why does this code cause segfault?
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
        {
                std::cout << 1 << std::endl;
                sf::Text text;
                std::cout << 2 << std::endl;
                text.setString("Hello world");
                std::cout << 3 << std::endl;
        }
        std::cout << 4 << std::endl;
}
 
After successfully compilation (and run) with this command:

g++-7 -std=c++17 -c main.cpp&&g++-7 main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system&&./sfml-app
It prints me:

Quote
1
2
3
Naruszenie ochrony pamięci
Naruszenie ochrony pamięci is Segmentation fault in polish

I use Linux Mint 64bit

2
Hey

I try to create sf::RenderTexture object in std::thread method and it causes stack overflow.
My code:
#include <SFML/Graphics.hpp>
#include <thread>

int main()
{
        sf::RenderTexture texture;
        std::thread thread([]() {
                sf::RenderTexture t;
        });

        thread.join();
        return 0;
}
 
Without creating first texture it happens too.
#include <SFML/Graphics.hpp>
#include <thread>

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "WINDOW");

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                        if (event.type == sf::Event::MouseButtonPressed)//crash when button is pressed
                        {
                                std::thread thread([]() {
                                        sf::RenderTexture t;
                                });
                        }
                }
                window.clear(sf::Color(50, 50, 50));
                window.display();
        }
        return 0;
}
 
but it doesn't crash with this code:
#include <SFML/Graphics.hpp>
#include <thread>

int main()
{
        std::thread thread([]() {
                sf::RenderTexture t;
        });
        thread.join();
        return 0;
}

How to solve this problem?

SFML 2.4.2
Microsoft Visual Studio Community 2015, Version 14

3
Graphics / Getting better performance by checking what to draw.
« on: April 25, 2017, 08:14:06 pm »
Hi everyone!
I'm creating a game, not very advanced one, but there will be a lot of drawing object (Sprites etc.). Most of them are going to be out of the player's sight. I will use ordinary function - just window.draw(mySprite) and my question sounds:
Does it takes GPU when I draw sprites (or some other drawable object) which are not visible for player(out of current window's view)?
If yes:
Does SFML (or OpenGL) checks if the sprite can be visible by the player or I should take care of them and check it manually using current window's view and getGlobalBounds method?
And Does it takes GPU when I draw an fully transparent sprite (with color's alpha set to 0)?

4
Network / FTP does not work in release mode.
« on: July 26, 2016, 02:40:39 pm »
Hey all,
I am creating game and i need download additional music file from internet. I tried do it and... I did.
But there is a problem. Program works only in debug mode. When i switch to release and i try download or upload file it crashes. Code:

#include <SFML/Network.hpp>
#include <iostream>

using namespace sf;
using namespace std;

// Normally there are good texts
string login = "";
string password= "";
string adres = "";
int main()
{
    Ftp ftp;
    Ftp::Response odp = ftp.connect(sf::IpAddress(adres.c_str()),21,sf::seconds(3));
    if(odp.isOk())
        cout<<"Connected!"<<endl;
    else
    {
        cout<<"Connecting error!"<<endl;
        getchar();
        return 1;
    }
    odp = ftp.login(login,password);
    if(odp.isOk())
        cout<<"Login succes!"<<endl;
    else
    {
        cout<<"Bad login or password"<<endl;
        cin.get();
        return 1;
    }
    cout<<"Downloading..."<<endl;
    odp = ftp.download("VexentoGlow.ogg","",sf::Ftp::Binary);
    if(odp.isOk())
        cout<<"Download complete!"<<endl;
    else
        cout<<"Error!"<<endl;
    getchar();
    ftp.disconnect();
    return 0;
}
 

It crashes in:
ftp.download("VexentoGlow.ogg","",sf::Ftp::Binary);

In debug mode it works good. It is SFML bug I suppose. :)
Please help!

Pages: [1]