AllenDang / giu

Cross platform rapid GUI framework for golang based on Dear ImGui.
MIT License
2.11k stars 127 forks source link

Using texture filtering with ImageWidget #755

Open tomwmth opened 5 months ago

tomwmth commented 5 months ago

Related problem

I have an application where I render a simple UI like so:

    SetupStyle()
    scaledWindowWidth := scale(float32(WindowWidth))
    giu.SingleWindow().Layout(
        giu.Align(giu.AlignCenter).To(
            giu.Image(logo).Size(LogoSize, LogoSize),
            giu.ProgressBar(float32(Progress)/13).Size(scaledWindowWidth*0.75, scale(5)),
        ),
    )
    PopStyle()

The ImageWidget containing the logo looks extremely bad due to not utilizing mipmaps when it is being scaled down. After investigating the source I saw that these mipmaps are being generated by the library however they aren't being used due to the texture filtering setting. Further investigation revealed that using giu.Context.GetRenderer() I am able to access functions for changing the texture filtering. Despite this, I cannot see how I can use these to affect only my ImageWidget and not the entire application. Letting it apply to the entire application breaks the background and the ProgressBar. By the time it is being rendered the widget is out of my control to influence as changing the texture filtering while the widget is being built (not rendered) is useless.

Unless I am missing something (entirely possible) I do not see how I could achieve the desired behaviour.

Your request

A way to set the texture filtering that is used for ImageWidgets on an individual basis.

Alternative solution

No response

Additional context

No response

gucio321 commented 5 months ago

There is a TextureFiltering example, but it is disabled at the moment because of cimgui-go migration, however it should work on v0.7.0

gucio321 commented 5 months ago

hmm its a bit deeply hidden in current rendering mechanism... Idk if we'll be able to fix this soon :cry: Maybe it'd be beter for you to scale down your imige and then create a new texture from it?

gucio321 commented 4 months ago

also, ref: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glTexParameter.xhtml