Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem to set cursor image  (Read 1786 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 9
    • View Profile
Problem to set cursor image
« on: October 05, 2020, 10:44:41 pm »
i'm trying to change the cursor image using sf::Cursor loadFromPixels (...).

It compiles without problems, but the result shows strange white lines in the cursor.
Im using the latest Ubuntu version.

My Code:
#include "CPP.hpp"
#include "SFML.hpp"

int main(int argc, char const *argv[])
        sf::RenderWindow renderWindow(sf::VideoMode(900, 600, 32), "cur", sf::Style::None);

        sf::Image curimg;
        sf::Cursor cur;
        cur.loadFromPixels(curimg.getPixelsPtr(), curimg.getSize(), sf::Vector2u(0,0));

        while(renderWindow.isOpen()) {
                sf::Event event;
                        if(event.type == sf::Event::Closed)


        return 0;

In the attachment you can find the image that i used.

I think it remains to the warning in the documentation https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Cursor.php#ac24ecf82ac7d9ba6703389397f948b3a

On Unix, the pixels are mapped into a monochrome bitmap: pixels with an alpha channel to 0 are transparent, black if the RGB channel are close to zero, and white otherwise.

But i dont know how to fix this, or is there a workaround?



  • SFML Team
  • Hero Member
  • *****
  • Posts: 10930
    • View Profile
    • development blog
    • Email
Re: Problem to set cursor image
« Reply #1 on: October 06, 2020, 08:55:26 am »
We recently had some changes in that area for Linux, I'd suggest you grab the master branch and build SFML from source.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
Dev Blog: https://duerrenberger.dev/blog/