https://linen.dev logo
Join Discord
Powered by
# lime
  • imgui
    t

    tall-teacher-57409

    05/21/2023, 2:44 PM
    https://github.com/nspitko/hlimgui/blob/84eae09bbe6f2017b30d3336ac97193d235bef69/imgui/ImGuiDrawable.hx#L111 @able-action-74275 essentially that and the draw function which afaik correspond to this in the native cpp https://github.com/ocornut/imgui/blob/df8667b18b5281205e15fa0254dce9f3e87dd6b2/backends/imgui_impl_opengl3.cpp#L461
    a
    w
    b
    • 4
    • 96
  • t

    tall-teacher-57409

    05/23/2023, 1:39 PM
    how do I access
    Application.current.window
    from a class that's not
    Main
    (I need to find the width and height)
  • t

    tall-teacher-57409

    05/23/2023, 1:40 PM
    because attempting to results in
    Copy code
    HelloWorld.js:21480 Uncaught TypeError: Cannot read properties of undefined (reading '__window')
        at HelloWorld.js:21480:45
        at $hx_script (HelloWorld.js:22843:3)
        at $hx_exports.lime.embed (HelloWorld.js:22852:2)
        at (index):39:8
  • t

    tall-teacher-57409

    05/23/2023, 1:48 PM
    Nvm, I fixed it by setting them in some static init function I have to call at the beginning.
  • t

    tall-teacher-57409

    05/23/2023, 2:05 PM
    stupid Clyde

    https://cdn.discordapp.com/attachments/769686258049351722/1110569202550575234/image.png▾

  • t

    tall-teacher-57409

    05/23/2023, 2:06 PM
    wtf..? it won't let me send my question
  • t

    tall-teacher-57409

    05/23/2023, 2:07 PM
    I'm having problems with camera movement, basically I decided to make my code more modular instead of stacking everything in a single Main.hx file, but I obviously broke something. (will send code snippets in the next message)
  • t

    tall-teacher-57409

    05/23/2023, 2:08 PM
    So in Camera.hx:
    Copy code
    hx
    public static function moveCamera(delta:Float):Void {
            dt = delta;
            var camSpeed = speed * dt;
            if (moveForward) {
                var tgt = front.clone();
                tgt.normalize();
                tgt.scaleBy(camSpeed);
                pos = pos.add(tgt);
            }
            if (moveBackward) {
                var tgt = pos.clone();
                tgt.normalize();
                tgt.scaleBy(camSpeed);
                pos = pos.subtract(tgt);
            }
            if (moveLeft) {
                var m = pos.crossProduct(up);
                m.normalize();
                m.scaleBy(camSpeed);
                pos = pos.subtract(m);
            }
            if (moveRight) {
                var m = front.crossProduct(up);
                m.normalize();
                m.scaleBy(camSpeed);
                pos = pos.add(m);
            }
        }
    In Main.hx:
    Copy code
    hx
    public override function update(deltaTime:Int):Void {
            this.deltaTime = deltaTime * 1.0 / 1000.0;
            if (Camera.moveLeft || Camera.moveRight || Camera.moveForward || Camera.moveBackward) {
                Camera.moveCamera(deltaTime);
            }
        }
    
        public override function onKeyDown(key:KeyCode, modifier:KeyModifier):Void {
            switch (key) {
                case LEFT:
                    Camera.moveLeft = true;
                case RIGHT:
                    Camera.moveRight = true;
                case UP:
                    Camera.moveForward = true;
                case DOWN:
                    Camera.moveBackward = true;
                default:
            }
        }
    
        public override function onKeyUp(key:KeyCode, modifier:KeyModifier):Void {
            switch (key) {
                case LEFT:
                    Camera.moveLeft = false;
                case RIGHT:
                    Camera.moveRight = false;
                case UP:
                    Camera.moveForward = false;
                case DOWN:
                    Camera.moveBackward = false;
                default:
            };
        }
  • t

    tall-teacher-57409

    05/23/2023, 2:10 PM
    And in the render loop, I'm updating the view matrix with
    Copy code
    hx
    view = 
    MatrixUtils.createLookAtMatrix(Camera.pos, Camera.pos.add(Camera.front), Camera.up);
  • t

    tall-teacher-57409

    05/23/2023, 2:14 PM
    pressing the arrow keys does nothing, but I double checked if it works or not by a trace
  • t

    tall-teacher-57409

    05/23/2023, 2:18 PM
    And yeah I also made sure I'm updating the uniforms each frame
  • t

    tall-teacher-57409

    05/23/2023, 2:43 PM
    Ok. I fixed it
  • t

    tall-teacher-57409

    05/23/2023, 2:43 PM
    it was something with the getters of the matrices
  • h

    hallowed-ocean-84954

    05/23/2023, 3:13 PM
    Nothing like refactoring to break stuff 🙂
  • t

    tall-teacher-57409

    05/23/2023, 3:37 PM
    true
  • p

    powerful-morning-89

    05/23/2023, 8:05 PM
    @aloof-sundown-95280 Re. that console window when using HL. These are your options: 1. call
    hl.UI.closeConsole()
    (but the console window will still up for a few moments) 2. change the subsystem of hl.exe from console to window. (See also ) 3. use hxcpp +
    -release
  • a

    aloof-sundown-95280

    05/23/2023, 8:48 PM
    why'd you strike out option 3? 👀
  • a

    aloof-sundown-95280

    05/23/2023, 8:52 PM
    option 1 worked thnx
  • e

    elegant-twilight-61392

    05/23/2023, 9:05 PM
    likely because while it would work, its probably not the option your looking for
  • e

    elegant-twilight-61392

    05/23/2023, 9:05 PM
    "use hxcpp" implies "dont use hashlink"
  • a

    aloof-sundown-95280

    05/23/2023, 9:06 PM
    I see, is that just a single command I can use or does it take setup/manual steps?
  • e

    elegant-twilight-61392

    05/23/2023, 9:06 PM
    its a different lime target
  • e

    elegant-twilight-61392

    05/23/2023, 9:07 PM
    lime [build|test|run] [windows|mac|linux]
  • a

    aloof-sundown-95280

    05/23/2023, 9:09 PM
    oh that, it didn't work for me so I guess option 3 is a no-go
  • a

    aloof-sundown-95280

    05/23/2023, 10:24 PM
    errors test/build for html5 with that, any way to check if hl?
  • h

    hallowed-ocean-84954

    05/23/2023, 10:33 PM
    I think `#if hl`works doesn't it ?
  • a

    aloof-sundown-95280

    05/23/2023, 10:33 PM
    where
  • h

    hallowed-ocean-84954

    05/23/2023, 10:34 PM
    In your hx file where you use this code
  • a

    ambitious-knife-25690

    05/23/2023, 10:35 PM
    oh well that was bad lol
  • a

    aloof-sundown-95280

    05/23/2023, 10:36 PM
    I see, thnx
1...133134135...138Latest