https://linen.dev logo
Join Discord
Powered by
# openfl
  • g

    great-oyster-61535

    07/22/2022, 6:28 PM
    Try on PowerShell next time that happens
  • b

    bright-gpu-74537

    07/23/2022, 10:48 AM
    whats the best way to set the pixels of an openfl sprite? Like i have a RGBA array and, ideally, would like to just say "use this buffer" - is that possible? I cant see anything obvious in the Graphics class
  • b

    bright-gpu-74537

    07/23/2022, 10:50 AM
    there is a
    @:noCompletion private var __bitmap:BitmapData;
    there, which has a setPixels method... but is that safe to use?
  • p

    powerful-morning-89

    07/23/2022, 11:36 AM
    I'd load the array into a BitmapData and then use
    graphics.beginBitmapFill
    .
  • b

    bright-gpu-74537

    07/23/2022, 11:51 AM
    ive actually gone another route, ive basically created a Bitmap with BitmapData and then use setPixels on that... seems fast enough
  • b

    bright-gpu-74537

    07/23/2022, 11:52 AM
    although, and im not sure if im going completely mad here: im trying to convert RGBA -> ARGB (since setPixels expects ARGB):
  • b

    bright-gpu-74537

    07/23/2022, 11:52 AM
    Copy code
    haxe
            var newPixels = Bytes.alloc(pixels.length);
            for (y in 0..._bitmapData.height) {
                for (x in 0..._bitmapData.width) {
                    var i = y * (_bitmapData.width * 4) + x * 4;
                    var r = pixels.get(i + 0);
                    var g = pixels.get(i + 1);
                    var b = pixels.get(i + 2);
                    var a = pixels.get(i + 3);
                    
                    newPixels.set(i + 0, a);
                    newPixels.set(i + 1, r);
                    newPixels.set(i + 2, g);
                    newPixels.set(i + 3, b);
                }
            }
  • b

    bright-gpu-74537

    07/23/2022, 11:53 AM
    and the result is wrong
  • b

    bright-gpu-74537

    07/23/2022, 12:14 PM
    this seems to work:
  • b

    bright-gpu-74537

    07/23/2022, 12:14 PM
    Copy code
    haxe
            // convert RGBA -> ARGB (well, actually BGRA for some reason)
            var bytesData = pixels.getData();
            var length:Int = pixels.length;
            var i:Int = 0;
            while (i < length) {
                var r = Bytes.fastGet(bytesData, i + 0);
                var g = Bytes.fastGet(bytesData, i + 1);
                var b = Bytes.fastGet(bytesData, i + 2);
                var a = Bytes.fastGet(bytesData, i + 3);
                newPixels.set(i + 0, b);
                newPixels.set(i + 1, g);
                newPixels.set(i + 2, r);
                newPixels.set(i + 3, a);
                i += 4;
            }
  • b

    bright-gpu-74537

    07/23/2022, 12:14 PM
    ¯\_(ツ)_/¯
  • a

    able-printer-41379

    07/25/2022, 10:06 PM
    How do you get the current window's name
  • a

    able-printer-41379

    07/25/2022, 10:06 PM
    im trying to make the window transparent but the hx file im using requires a window name
  • a

    able-printer-41379

    07/25/2022, 10:09 PM
    i tried everything
  • h

    hallowed-ocean-84954

    07/25/2022, 10:40 PM
    Do you mean the window ID or the title perhaps ?
  • a

    able-printer-41379

    07/25/2022, 10:49 PM
    Id i guess
  • a

    able-printer-41379

    07/25/2022, 10:50 PM
    im using this i tried for HOURS Studying it and still didnt succeed
  • a

    able-printer-41379

    07/25/2022, 10:52 PM
    i also tried putting the title for winname and didnt work
  • a

    able-printer-41379

    07/25/2022, 10:52 PM
    always gave me this
  • h

    hallowed-ocean-84954

    07/25/2022, 10:57 PM
    I've been thinking something like this would be needed to set transparency in a lime window but I haven't gotten this far yet. I'll be interested if you get it going.
  • h

    hallowed-ocean-84954

    07/25/2022, 10:59 PM
    RE the errors have no French butit looks like it's not ballot with a constant and there seems to be a semi colon missing ?
  • h

    hallowed-ocean-84954

    07/25/2022, 11:01 PM
    Are you going directly to windows api rather than thru SDL ?
  • a

    able-printer-41379

    07/25/2022, 11:01 PM
    i got this from a friend both of us dont know the solution
  • a

    able-printer-41379

    07/25/2022, 11:02 PM
    i dont even know where he found it
  • h

    hallowed-ocean-84954

    07/25/2022, 11:05 PM
    I think it's the windows api. So I think the winname is what windows would call it. I was thinking to try the sdl setWindowOpacity function if I can get access to the sdl window object which I think lime should have somewhere
  • a

    able-printer-41379

    07/25/2022, 11:06 PM
    im so tired ive been looking for hours
  • h

    hallowed-ocean-84954

    07/25/2022, 11:09 PM
    https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-findwindowa
  • h

    hallowed-ocean-84954

    07/25/2022, 11:09 PM
    Looks like the name should be the title
  • m

    many-addition-78652

    07/25/2022, 11:31 PM
    So a lime window you can get from
    Lib.application.windows
    has a private variable called
    __backend
    which will give you a
    NativeWindow
    on native targets like desktop. The
    NativeWindow
    has a public variable called
    handle
    which is the sdl window but it is
    Dynamic
    . You will probably need to write some externs to set that opacity. I haven't done anything like that before, but that is where it is as far as I can tell.
  • h

    hallowed-ocean-84954

    07/25/2022, 11:32 PM
    Yes I think that's the route and I've not done anything like this before either but hey that's the fun of it !
12345...57Latest