PDA

View Full Version : How to set clan::Cursor from clan::Sprite frame



EgorTiunov
01-15-2016, 08:04 PM
Hi. I wish set cursor icon from sprite frame. It worked, but cursor pixels is mixed. Where is my bug?



clan::Texture2D texture = pointer.get_frame_texture(0).get_texture();
clan::PixelBuffer buffer = texture.get_pixeldata(canvas.get_gc());
buffer.lock(canvas.get_gc(), clan::BufferAccess::access_read_only);
clan::CursorDescription description;

description.add_frame(buffer);
clan::Cursor cursor = clan::Cursor(window, description);

window.set_cursor(cursor);

clan::Image created in this way is drawn correctly

rombust
01-18-2016, 10:30 AM
afaik, buffer.lock(canvas.get_gc(), clan::BufferAccess::access_read_only); isn't required (and your not calling unlock anywhere)

btw, you might find it easier to load the pixelbuffer via PixelBuffer(const std::string &fullname) or clan::PNGProvider::load()

Else it looks fine.

Possibly a bug in ClanLib.

Ensure your using https://github.com/sphair/ClanLib repo

EgorTiunov
01-19-2016, 06:39 PM
Yes, latest version. master branch
well, I will try to fix or set cursor to a different way

rombust
01-20-2016, 12:41 PM
maybe its a rgba8 vs abgr8 issue