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 - 6Peppered9

Pages: [1]
1
General / SFML Color bug for transparent windows with nvidia gpu
« on: May 14, 2021, 11:25:33 am »
Hello,
3 years ago i posted a question how to make the window background transparent.
link: https://en.sfml-dev.org/forums/index.php?topic=24697.msg165592#msg165592

The user "texus" hacked some code in the SFML source to work around.

This works fine on Intel GPUs, but on Nvidia GPUs it seems that everything (colors, textures, etc) is drawing with an alpha channel and looks semi transparent

Is there a way to fix this?
I'm not familiar with the xlib API but it i think it can be a problem in the nvidia driver.

My 2 question is how other libs like qt or gtk do this?
And why is there not the possibility to create transparent windows in SFML?

2
Graphics / Problem to set cursor image
« on: October 05, 2020, 10:44:41 pm »
Hello,
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;
        curimg.loadFromFile("cursor.png");
        sf::Cursor cur;
        cur.loadFromPixels(curimg.getPixelsPtr(), curimg.getSize(), sf::Vector2u(0,0));
        renderWindow.setMouseCursor(cur);

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

                renderWindow.clear(sf::Color::White);
                renderWindow.display();
        }

        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?

Thanks

3
Window / Re: application generates multiple key release event
« on: March 12, 2019, 08:05:28 am »
no, every object have another KeyRelease function.
I can assign a different function to each object via function pointer.

But I tried something and saved the objects in a fixed array, so I can access the objects via an index and it works.
no idea why it does not work by iterator

i had used this class for drawStack:
#include <stack>
#include <deque>

template<typename T, typename Container = std::deque<T>>
class IStack : public std::stack<T, Container>
{
    using std::stack<T, Container>::c;

        public:
        // expose just the iterators of the underlying container
        auto begin() {return std::begin(c);}
        auto end() {return std::end(c);}

        auto begin() const {return std::begin(c);}
        auto end() const {return std::end(c);}
};
 
https://stackoverflow.com/questions/525365/does-stdstack-expose-iterators

4
Window / application generates multiple key release event
« on: March 12, 2019, 04:39:30 am »
hello,

I'm dealing with the sfml events and have a problem that my application generates several KeyReleased events.

My pollEvent loop

while(rootWindow->pollEvent(event)) {
    for(auto it : drawStack) {
        if(it->eventable) {
            it->handleEvent(event);
        }
    }

 

drawStack is a stack of pointers of objects that I want to draw on the screen.
The polled event should be forwarded to the respective objects, which then decide what happens.

handleEvent

void handleEvent(sf:: Event) {
    switch(event.type) {
        case sf::Event::KeyReleased:
            cout << "obj 1 KeyReleased" << endl;
            break;
    }
}

 

everything works as long as there is only one object on the stack.
But with two objects on the stack I get such an output:
obj 1 KeyReleased
obj 2 KeyReleased
obj 2 KeyReleased
obj 2 KeyReleased
obj 2 KeyReleased
obj 2 KeyReleased
...
 

This is what i want:
obj 1 KeyReleased
obj 2 KeyReleased
 

is my procedure right?
Is there another way to do it?
Or did I not understand sf :: Event?

5
General / Need help to change the mouse cursor
« on: December 02, 2018, 01:33:30 pm »
Hello,
I want to change my mouse pointer in my SFML application. (using SFML 2.5.1 on Linux)

I have used the following steps from the documentation:
sf::Cursor cursor;
cursor.loadFromPixels(image.getPixelsPtr(), image.getSize(), {0, 0});
window.setMouseCursor(cursor);
 

The image I want to use as a mouse pointer is a red rectangle in PNG format


When I start the application, the mouse pointer is rendered strange.



Instead of the white lines, the mouse pointer should normally be displayed.

Do I lose any data when loading the image, so I get such an output?

6
General discussions / Change mouse cursor image
« on: November 29, 2018, 01:10:33 am »
Hello, i want to change my mouse cursor in my sfml window.

Using C++ SFML 2.5.0 on Linux.

This is the image that i want to set as cursor:

(Red Rectangle)

cursor.loadFromPixels(image.getPixelsPtr(), image.getSize(), {0,0});
window.setMouseCursor(cursor);

but if i run the application it looks strange:


what i need to do to fix it?

Thanks

7
Window / Re: SFML: Transparent Window Background?
« on: October 31, 2018, 08:29:36 pm »
Yes, but with the method i posted, i change the opacity of the entire window including the topbar and everything  in the window (buttons, ...)

it looks like this:


but i want only to change the background opacity. The window frame (including title, close button, ...) should be displayed normally

8
Window / Re: SFML: Transparent Window Background?
« on: October 31, 2018, 04:20:20 pm »
I want exactly this:


I want to set the background transparency of my window exactly like the transparency in the gnome terminal settings.

9
Window / SFML: Transparent Window Background?
« on: October 31, 2018, 01:02:32 am »
Hello,

I have a normal window with SFML (C ++) and I want to render the background of the window (not its content) transparent, e.g. can change the alpha channel.

Since the rendering of the window is the window manager's task and I do not have a direct way to change the window properties directly via SFML, I go back to X11 and tried the following:

https://github.com/texus/TransparentWindows/blob/master/Transparent.cpp

I'm not really familiar with the Xlib.

The problem is that I use the above method to make the entire window transparent (including the contents of the window).

Does anyone know a way to make only the background of the window transparent? I would be very happy about code examples. ?

Thank you.

Pages: [1]
anything