diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-08-06 15:52:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-06 15:52:38 -0700 |
| commit | 73ff6907d723003d30e400f661876e7960de574f (patch) | |
| tree | 76fb87e0d7cdf6310c4a62753556dbf061842d7b /examples | |
| parent | 68d705f6c805c9b4d31b386e065762e6db13ad18 (diff) | |
Add basic support for "Dear IMGUI" (#625)
This isn't being made visible just yet, but it will allow us to have a simple UI for loading models into the model-viewer example.
In order to support rendering with IMGUI I had to add the following to the `Renderer` layer:
* viewports
* scissor rects
* blend support
These are really only fully implemented for D3D11, but adding them to the other back-ends should be a reasonably small task.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/model-viewer/main.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/examples/model-viewer/main.cpp b/examples/model-viewer/main.cpp index cd6b404ee..b32d4166c 100644 --- a/examples/model-viewer/main.cpp +++ b/examples/model-viewer/main.cpp @@ -21,6 +21,7 @@ #include "gfx/render-d3d11.h" #include "gfx/vector-math.h" #include "gfx/window.h" +#include "gfx/gui.h" using namespace gfx; // We will use a few utilities from the C++ standard library, @@ -1273,6 +1274,7 @@ RefPtr<ParameterBlockLayout> gPerViewParameterBlockLayout; RefPtr<ParameterBlockLayout> gPerModelParameterBlockLayout; RefPtr<ShaderCache> shaderCache; +RefPtr<GUI> gui; // Most of the application state is stored in the list of loaded models. // @@ -1421,7 +1423,11 @@ Result initialize() // Support for loading more interesting/complex models will be added // to this example over time (although model loading is *not* the focus). // - loadAndAddModel("cube.obj"); + loadAndAddModel("cube.obj", ModelLoader::LoadFlag::FlipWinding); + + // We will do some GUI rendering in this app, using "Dear, IMGUI", + // so we need to do the appropriate initialization work here. + gui = new GUI(gWindow, gRenderer); showWindow(gWindow); @@ -1434,6 +1440,8 @@ Result initialize() // void renderFrame() { + gui->beginFrame(); + // In order to see that things are rendering properly we need some // kind of animation, so we will compute a crude delta-time value here. // @@ -1454,7 +1462,10 @@ void renderFrame() 1000.0f); glm::mat4x4 view = identity; - view = translate(view, glm::vec3(0, 0, -5)); + view = glm::lookAt( + glm::vec3(4, 5, -5), + glm::vec3(0), + glm::vec3(0, 1, 0)); glm::mat4x4 viewProjection = projection * view; @@ -1584,6 +1595,18 @@ void renderFrame() } } +#if 0 + ImGui::Begin("Model Viewer"); + ImGui::Text("Average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); + if (ImGui::Button("Load Model")) + { + // need to do a file open box, and then try to open the resulting file + + } + ImGui::End(); +#endif + + gui->endFrame(); gRenderer->presentFrame(); } |
