• coloredgrayscale@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    One way to get the data is to render to a (hidden) surface/canvas. It’s just bytes to the computer, so just dump the result data in the display buffer. Then you take a “screenshot” and interpret the RGBA values as data.

    • graphicsguy@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Graphics Programmer here.

      More likely you would just write data to a buffer (basically an array of whatever element type you want) rather than a render target and then read it back to the cpu. Dx, vulkan, etc. all have APIs to upload / download to / from the GPU quite easily, and CUDA makes it even easier, so a simple compute shader or CUDA kernel that writes to a buffer would make the most sense for general purpose computation like an advent of code problem.