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

    enough-lawyer-1858

    05/27/2023, 10:57 PM
    like, from some lil pseudocode, this would be perfect?
    Copy code
    haxe
    var bitmapData = new BitmapData(10, 2, 0);
    var byteArray = new ByteArray(bitmapData.width * bitmapData.height);
    // and then do some loop that sets the colors to transparent and then calculate the position depending on which pixel is it, like if (5, 1), then position = 10
  • e

    enough-lawyer-1858

    05/27/2023, 10:58 PM
    something like that right?
  • h

    hallowed-ocean-84954

    05/27/2023, 10:59 PM
    yeah but the critical bit is how you loop over the rows and columns
  • h

    hallowed-ocean-84954

    05/27/2023, 11:00 PM
    Copy code
    for i 0...btimaptData.height {
         for j 0...bitmapData.width {
             set byte value for the pixel 
         }
      }
  • e

    enough-lawyer-1858

    05/27/2023, 11:00 PM
    Hm
  • h

    hallowed-ocean-84954

    05/27/2023, 11:00 PM
    the location in the array would be i*width + j
  • e

    enough-lawyer-1858

    05/27/2023, 11:01 PM
    wait, why i * width + j?
  • e

    enough-lawyer-1858

    05/27/2023, 11:01 PM
    oh
  • e

    enough-lawyer-1858

    05/27/2023, 11:01 PM
    I got it lmao
  • e

    enough-lawyer-1858

    05/27/2023, 11:02 PM
    but yeah, Thx! pretty helpful to play around
  • a

    able-printer-41379

    05/28/2023, 5:17 PM
    how can i grab the openfl_TextureCoord outside of a shader?
  • a

    able-printer-41379

    05/28/2023, 5:17 PM
    is there a property for it
  • h

    hallowed-ocean-84954

    05/28/2023, 5:32 PM
    Not that I know of - You might be able to get hold of the input attribute data from the ShaderParameters but then you should just be able to figure it out from the position and w/h of the sprite.
  • a

    able-printer-41379

    05/28/2023, 6:55 PM
    i tried __textureCoord.value but its always null
  • h

    hallowed-ocean-84954

    05/28/2023, 6:58 PM
    I have to ask, why do you need to read the value from Haxe though ? At best it just give you the sprite position which you should already know
  • a

    able-printer-41379

    05/28/2023, 7:46 PM
    so textureCoord is just sprite.x & sprite.y?
  • a

    able-printer-41379

    05/28/2023, 7:47 PM
    it got me confused since its a float that is smaller than 1
  • h

    hallowed-ocean-84954

    05/28/2023, 7:48 PM
    oh I'm sorry - I was thinking pos. No, texturecoord is a value between 0.0 and 1.0.
  • h

    hallowed-ocean-84954

    05/28/2023, 7:49 PM
    And that's true regardless of the sprite texture in use.
  • h

    hallowed-ocean-84954

    05/28/2023, 7:49 PM
    0.0, 0.0 being the bottom left and 1.0, 1.0 being the top right.
  • a

    able-printer-41379

    05/28/2023, 7:50 PM
    ah
  • a

    able-printer-41379

    05/28/2023, 8:10 PM
    so is openflTextureCoord based on every pixel in the texture?
  • h

    hallowed-ocean-84954

    05/28/2023, 8:22 PM
    Well not exactly based on pixels but it extends from 0 through 1 and yeah it covers the whole of the texture.
  • a

    able-printer-41379

    05/28/2023, 8:25 PM
    is there a way to replicate that or a variable that shows the current coordinates
  • a

    able-printer-41379

    05/28/2023, 8:25 PM
    im using flixel by the way, i have no idea if there are variables that do so
  • h

    hallowed-ocean-84954

    05/28/2023, 8:30 PM
    I'm a little lost - the fragment shaders will be given an interpolated value in the openfl_TextureCoordv varying. And the x,y value in that vec2 is used to look up the texel in the texture, via the flixel_texture2D() function. That will return the color value to render at the pixel. Flixel doesn't really need to know this. You just use it in the fragment shader.
  • a

    able-printer-41379

    05/28/2023, 8:35 PM
    oh my, so there is no way to get it
  • a

    able-action-74275

    05/28/2023, 9:10 PM
    no, it's used in the shader - why do you want it?
  • a

    able-printer-41379

    05/28/2023, 10:19 PM
    im challenging myself into making an interactive shader class where you can manipulate shaders through haxe itself
  • h

    hallowed-ocean-84954

    05/28/2023, 10:26 PM
    that's fine - but you can only really manipulate normal inputs, vertex array, attributes on those vertexes, and uniforms. You can change them on each update() cycle but it's basically one way - well until you get to buffers, and compute shaders which are not supported in the contexts and versions available.