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

    able-action-74275

    01/25/2023, 7:21 PM
    you can just do e.g. (if you don't need async)
    Copy code
    hx
    var newGraphic = FlxGraphic.fromAssetKey(assetPath);
  • e

    elegant-cat-63914

    01/25/2023, 7:22 PM
    i need to load assets from a async location but force it to work sync in the code
  • e

    elegant-twilight-61392

    01/25/2023, 7:22 PM
    you must write async code if you are doing async things
  • h

    hallowed-ocean-84954

    01/26/2023, 3:23 AM
    did you get to the bottom of this ? Just looking at the code the array needs to have a size - GLSL doesn't like unbounded stuff or dynamically sizing things. As to the errors in this bit you need to get locate lines 65, 68 and 85 in your GLSL. The binding code (with the vertexAttrib calls) isn't going to bind to these. It's about vertex attrs not uniforms.
  • l

    late-australia-6304

    01/26/2023, 3:24 AM
    im deciding to use an array with a max size and just set the elements i need (then create a struct out of the array)
  • l

    late-australia-6304

    01/26/2023, 3:24 AM
    but rn openfl doesnt have uniform array setting
  • h

    hallowed-ocean-84954

    01/26/2023, 3:25 AM
    true
  • h

    hallowed-ocean-84954

    01/26/2023, 3:25 AM
    the way I deal with that is go via the lime GL render context
  • h

    hallowed-ocean-84954

    01/26/2023, 3:27 AM
    So for example I have this array of structs:
    Copy code
    struct PointLight {
        bool enabled;
    
        vec3 position;
    
        // Light colors
        vec3 ambient;
        vec3 diffuse;
        vec3 specular;
    
        // Attenuation values
        float constant;
        float linear;
        float quadratic;
    };
    #define NUM_POINT_LIGHTS 4
    uniform PointLight uPointLights[NUM_POINT_LIGHTS];
  • l

    late-australia-6304

    01/26/2023, 3:27 AM
    what does that look like?
  • h

    hallowed-ocean-84954

    01/26/2023, 3:27 AM
    and I can bind this way :
    Copy code
    for (i in 0...BasicsScene.NUM_POINT_LIGHTS)
            {
                _programPointLightEnabledUniform[i] = _gl.getUniformLocation(_glProgram, 'uPointLights[${i}].enabled');
                _programPointLightPositionUniform[i] = _gl.getUniformLocation(_glProgram, 'uPointLights[${i}].position');
                _programPointLightAmbientUniform[i] = _gl.getUniformLocation(_glProgram, 'uPointLights[${i}].ambient');
                _programPointLightDiffuseUniform[i] = _gl.getUniformLocation(_glProgram, 'uPointLights[${i}].diffuse');
                _programPointLightSpecularUniform[i] = _gl.getUniformLocation(_glProgram, 'uPointLights[${i}].specular');
                _programPointLightAttenuationKc[i] = _gl.getUniformLocation(_glProgram, 'uPointLights[${i}].constant');
                _programPointLightAttenuationKl[i] = _gl.getUniformLocation(_glProgram, 'uPointLights[${i}].linear');
                _programPointLightAttenuationKq[i] = _gl.getUniformLocation(_glProgram, 'uPointLights[${i}].quadratic');
            }
  • l

    late-australia-6304

    01/26/2023, 3:27 AM
    smart
  • l

    late-australia-6304

    01/26/2023, 3:28 AM
    i was looking through the gl api but i was just stuck on what a buffer is 😭
  • h

    hallowed-ocean-84954

    01/26/2023, 3:28 AM
    then the render method sets the values like :
    Copy code
    for (i in 0...BasicsScene.NUM_POINT_LIGHTS)
            {
                _gl.uniform1i(_programPointLightEnabledUniform[i], params.ui.pointLight(i).uiPointLightEnabled.selected ? 1 : 0);
                if (params.ui.pointLight(i).uiPointLightEnabled.selected)
                {
                    _gl.uniform3fv(_programPointLightPositionUniform[i], params.pointLights[i].position, 0);
    
                    // FIXME need array mapping of each ui pointlight element - how? * /
                    _gl.uniform3f(_programPointLightAmbientUniform[i], params.ui.pointLight(i).pointLightAmbientColor.r,
                        params.ui.pointLight(i).pointLightAmbientColor.g, params.ui.pointLight(i).pointLightAmbientColor.b);
                    _gl.uniform3f(_programPointLightDiffuseUniform[i], params.ui.pointLight(i).pointLightDiffuseColor.r,
                        params.ui.pointLight(i).pointLightDiffuseColor.g, params.ui.pointLight(i).pointLightDiffuseColor.b);
                    _gl.uniform3f(_programPointLightSpecularUniform[i], params.ui.pointLight(i).pointLightSpecularColor.r,
                        params.ui.pointLight(i).pointLightSpecularColor.g, params.ui.pointLight(i).pointLightSpecularColor.b);
                    _gl.uniform1f(_programPointLightAttenuationKc[i], params.ui.pointLight(i).pointLightKc);
                    _gl.uniform1f(_programPointLightAttenuationKl[i], params.ui.pointLight(i).pointLightKl);
                    _gl.uniform1f(_programPointLightAttenuationKq[i], params.ui.pointLight(i).pointLightKq);
                }
            }
  • l

    late-australia-6304

    01/26/2023, 3:28 AM
    whats
    _programPointLightEnabledUniform
  • h

    hallowed-ocean-84954

    01/26/2023, 3:29 AM
    that's the reference to the GLSL uniform in the Haxe program
  • h

    hallowed-ocean-84954

    01/26/2023, 3:29 AM
    It's defined like this
  • h

    hallowed-ocean-84954

    01/26/2023, 3:30 AM
    Copy code
    /* Point light variables */
        private var _programPointLightEnabledUniform:Array<GLUniformLocation>;
        private var _programPointLightPositionUniform:Array<GLUniformLocation>;
        private var _programPointLightAmbientUniform:Array<GLUniformLocation>;
        private var _programPointLightDiffuseUniform:Array<GLUniformLocation>;
        private var _programPointLightSpecularUniform:Array<GLUniformLocation>;
        private var _programPointLightAttenuationKc:Array<GLUniformLocation>;
        private var _programPointLightAttenuationKl:Array<GLUniformLocation>;
        private var _programPointLightAttenuationKq:Array<GLUniformLocation>;
  • l

    late-australia-6304

    01/26/2023, 3:30 AM
    im try this out sometime this week
  • l

    late-australia-6304

    01/26/2023, 3:30 AM
    thanks
  • h

    hallowed-ocean-84954

    01/26/2023, 3:38 AM
    sure - if you want to see the code complete it's in my virtual-rubiks-cube repo
  • l

    late-australia-6304

    01/26/2023, 4:20 AM
    i'll take a look, thanks!
  • b

    bitter-city-44714

    01/29/2023, 4:27 AM
    hi, how could pause a sound in haxe?
  • b

    boundless-australia-56579

    01/29/2023, 10:19 AM
    @bitter-city-44714 you need to stop the soundchannel, save the position of the soundchannel, and they play the sound from this position.
  • b

    bitter-city-44714

    01/30/2023, 11:03 AM
    do you know how I can find an example of how this is done?
  • b

    boundless-australia-56579

    01/30/2023, 2:07 PM
    soundchannel = sound.play()
    var position = soundchannel.position;
    soundchannel.stop();
    soundchannel = sound.play(position);
  • b

    boundless-australia-56579

    01/30/2023, 2:08 PM
    If I haven't made any mistake...^^
  • b

    boundless-australia-56579

    01/30/2023, 2:11 PM
    @bitter-city-44714 I see that you are asking this elsewhere, so please answer your own question on the openfl forum with the answer you got on discord 🙂
  • b

    boundless-australia-56579

    01/30/2023, 2:11 PM
    btw it's not specific to haxe, it's part of the action script 3 api
  • s

    square-angle-35096

    02/01/2023, 2:55 PM
    Copy code
    bat
    Error: AsyncErrorEvent.cpp
    ./src/openfl/events/AsyncErrorEvent.cpp(29): error C2039: 'error': is not a member of 'openfl::events::AsyncErrorEvent_obj'
    include\openfl/events/AsyncErrorEvent.h(21): note: see declaration of 'openfl::events::AsyncErrorEvent_obj'
1...383940...57Latest