MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / renderUI

Method renderUI

Source/RenderPasses/ImageLoader/ImageLoader.cpp:127–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void ImageLoader::renderUI(Gui::Widgets& widget)
128{
129 // When output size requirements change, we'll trigger a graph recompile to update the render pass I/O sizes.
130 if (widget.dropdown("Output size", mOutputSizeSelection))
131 requestRecompile();
132 widget.tooltip(
133 "Specifies the pass output size.\n"
134 "'Default' means that the output is sized based on requirements of connected passes.\n"
135 "'Fixed' means the output is always at the image's native size.\n"
136 "If the output is of a different size than the native image resolution, the image will be rescaled bilinearly.",
137 true
138 );
139
140 widget.text("Image File: " + mImagePath.string());
141 bool reloadImage = false;
142 reloadImage |= widget.checkbox("Load As SRGB", mLoadSRGB);
143 reloadImage |= widget.checkbox("Generate Mipmaps", mGenerateMips);
144
145 if (widget.button("Load File"))
146 {
147 reloadImage |= openFileDialog({}, mImagePath);
148 }
149
150 if (mpTex)
151 {
152 if (mpTex->getMipCount() > 1)
153 widget.slider("Mip Level", mMipLevel, 0u, mpTex->getMipCount() - 1);
154 if (mpTex->getArraySize() > 1)
155 widget.slider("Array Slice", mArraySlice, 0u, mpTex->getArraySize() - 1);
156
157 widget.image(mImagePath.string().c_str(), mpTex.get(), {320, 320});
158 widget.text("Image format: " + to_string(mpTex->getFormat()));
159 widget.text("Image size: (" + std::to_string(mpTex->getWidth()) + ", " + std::to_string(mpTex->getHeight()) + ")");
160 widget.text("Output format: " + to_string(mOutputFormat));
161 widget.text("Output size: (" + std::to_string(mOutputSize.x) + ", " + std::to_string(mOutputSize.y) + ")");
162 }
163
164 if (reloadImage && !mImagePath.empty())
165 {
166 uint2 prevSize = {};
167 if (mpTex)
168 prevSize = {mpTex->getWidth(), mpTex->getHeight()};
169
170 if (!loadImage(mImagePath))
171 {
172 msgBox("Error", fmt::format("Failed to load image from '{}'", mImagePath), MsgBoxType::Ok, MsgBoxIcon::Warning);
173 }
174
175 // If output is set to native size and image dimensions have changed,
176 // we'll trigger a graph recompile to update the render pass I/O sizes.
177 if (mOutputSizeSelection == RenderPassHelpers::IOSize::Fixed && mpTex != nullptr &&
178 (mpTex->getWidth() != prevSize.x || mpTex->getHeight() != prevSize.y))
179 {
180 requestRecompile();
181 }
182 }
183}
184

Callers

nothing calls this directly

Calls 15

requestRecompileFunction · 0.85
dropdownMethod · 0.80
tooltipMethod · 0.80
textMethod · 0.80
checkboxMethod · 0.80
buttonMethod · 0.80
sliderMethod · 0.80
imageMethod · 0.80
getFormatMethod · 0.80
getWidthMethod · 0.80
getHeightMethod · 0.80
openFileDialogFunction · 0.50

Tested by

no test coverage detected