2

I am trying to write a ray tracer and want to render my image in real time in a GUI window. Basically, I have a buffer: Vec<u8> that is constantly updating. The question is how do I display it on the screen after completing each row. I was thinking about using iced or egui, but couldn't figure out how to output changing image without copying it each time. Solutions that are using other toolkits are also welcome.

egui asks for TextureId:

ui.image(my_texture_id, [640.0, 480.0]);

but doesn't say where to get it

Chandan
  • 11,465
  • 1
  • 6
  • 25
  • Hello, I have the same problem (and I also writing a ray tracer). I am using egui, how did you solve the issue? – edap Aug 06 '22 at 15:23

1 Answers1

0

For egui there's some example here and a note here if you want to go 3D (with an example too).

For iced there's a bunch of examples, and some of them are using image/image_viewer (e.g. pokedex).

A way to go would be to copy their code, make it compile/run, and then tweak it with your logic. If something goes wrong - you'd have more input for a more concrete SO question.

Also I don't think that there's anything wrong per se in copying the data for the purpose of buffering (see this).

kmdreko
  • 42,554
  • 6
  • 57
  • 106
battlmonstr
  • 5,841
  • 1
  • 23
  • 33
  • Please flesh out this answer with snippets of code relevant to the question. Links are nice but they can rot (and some did); the answer should be useful on its own. – kmdreko Sep 24 '22 at 01:53