Closed IrishBruse closed 3 years ago
Could you give some more details on what it is you want to do? From what it sounds like this would be more of a ImGui.NET question.
Im making an emulator and my window data is in a byte array ordered rgb and im trying to use the texture class you provide to pass the image data to the imgui window for displaying basically render the current frame to an imgui window.
This is what gets rendered a black box even though it should be noise.
Ah ok now I understand what it is that you are trying to do.
What is happening here is a combination of multiple things I believe.
First thing is that the internal format for textures using that ctor is either Srgb8Alpha8
or Rgba8
depending on the srgb
boolean flag. So either you need to provide alpha data or modify the Texture
class to be able to handle a Rgb8
format.
https://github.com/NogginBops/ImGui.NET_OpenTK_Sample/blob/master/Dear%20ImGui%20Sample/Texture.cs#L107
(it's worth noting that the GPU will probably store the data as Rgba8
anyways, so just adding the alpha component is probably the best solution)
Next is that because the method was originally meant for Bitmap
data pointers the format
is defined as Bgra
because that is how the endian-ness of modern machines works out. So if you have your data as bytes directly with the in memory byte order of Red-byte
, Green-byte
, Blue-byte
then you want to just specify the format as Rgb
https://github.com/NogginBops/ImGui.NET_OpenTK_Sample/blob/master/Dear%20ImGui%20Sample/Texture.cs#L113
(and once again note that you probably want to specify alpha too so it would be Rgba
)
(you can also use GL_UNSIGNED_INT_8_8_8_8
and GL_UNSIGNED_INT_8_8_8_8_REV
to achieve a similar thing)
Please try these modifications and tell me how it went 🙂
So I think this would be the changes needed to the ctor for it to work correctly.
I think its really strange as I would expect something to happen like the texture to be weird colors or an error.
I added the alpha component to the test array so I would expect to see random pixel transparent with the randomize but its all still black with no error.
Can you show the code you use for displaying the image using ImGui? Or if you could zip your project and send it to me so I can test it on my machine.
Also thats the imgui drawing
I figured out the issue you are having.
It's the same issue as #9 .
How I figured that out is by looking at the framebufferTexture.GLTexture
value in a debugger and noting that it's 0
.
The fix is to before calling any OpenTK/OpenGL functions to call MakeCurrent()
.
Adding a MakeCurrent()
here fixes the problem.
MakeCurrent();
framebufferTexture = new Texture("FrameBuffer", Constant.WindowWidth, Constant.WindowHeight, dataPRT);
This is a OpenTK 4-pre9.4 issue and calling MakeCurrent()
will likely not be necessary in future OpenTK versions.
Thank you very strange its in your Window class I saw but I didn't think I would need to use it. I guess thats what I get for using previews :/ Thanks again for the help its working perfectly now 😄
Great! Have fun. 🙂
I am having trouble making a texture for use with Imgui.image from a byte array with r g b im new to using opentk so any help would be appreciated thanks. also im using the latest 4.0 opentk