Inplemented ImGui
This commit is contained in:
parent
d534be6ee1
commit
9bca8907aa
|
@ -19,16 +19,38 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="imgui\backends\imgui_impl_glfw.cpp" />
|
||||
<ClCompile Include="imgui\backends\imgui_impl_opengl3.cpp" />
|
||||
<ClCompile Include="imgui\imgui.cpp" />
|
||||
<ClCompile Include="imgui\imgui_demo.cpp" />
|
||||
<ClCompile Include="imgui\imgui_draw.cpp" />
|
||||
<ClCompile Include="imgui\imgui_tables.cpp" />
|
||||
<ClCompile Include="imgui\imgui_widgets.cpp" />
|
||||
<ClCompile Include="src\Application.cpp" />
|
||||
<ClCompile Include="src\Camera.cpp" />
|
||||
<ClCompile Include="src\imgui_demo.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="imgui\.editorconfig" />
|
||||
<None Include="imgui\.gitattributes" />
|
||||
<None Include="imgui\.gitignore" />
|
||||
<None Include="shaders\parade_fs.glsl" />
|
||||
<None Include="shaders\parade_vs.glsl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imgui\backends\imgui_impl_glfw.h" />
|
||||
<ClInclude Include="imgui\backends\imgui_impl_opengl3.h" />
|
||||
<ClInclude Include="imgui\imconfig.h" />
|
||||
<ClInclude Include="imgui\imgui.h" />
|
||||
<ClInclude Include="imgui\imgui_internal.h" />
|
||||
<ClInclude Include="imgui\imstb_rectpack.h" />
|
||||
<ClInclude Include="imgui\imstb_textedit.h" />
|
||||
<ClInclude Include="imgui\imstb_truetype.h" />
|
||||
<ClInclude Include="include\Camera.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="imgui\LICENSE.txt" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
|
@ -99,15 +121,15 @@
|
|||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\$(Platform)$(Configuration)</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)$(Configuration)</IntDir>
|
||||
<IncludePath>$(SolutionDir)\imgui-master;$(SolutionDir)\include;$(SolutionDir)\imgui_master;$(IncludePath)</IncludePath>
|
||||
<IncludePath>C:\Users\Jack\parade\imgui;C:\Users\Jack\parade\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(SolutionDir)lib</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\$(Platform)$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)$(Configuration)\</IntDir>
|
||||
<LibraryPath>$(SolutionDir)\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)\imgui-master;$(SolutionDir)\include;$(SolutionDir)\imgui_master;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)\lib\;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
|
||||
<IncludePath>$(CoreLibraryDependencies);$(SolutionDir)include\;$(SolutionDir)imgui\;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
<Filter Include="Shaders">
|
||||
<UniqueIdentifier>{de7b03ae-538e-4924-978f-dbbf7fd055af}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="imgui">
|
||||
<UniqueIdentifier>{82ea4ca8-7738-4f20-8641-5716a9a1dc9d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Application.cpp">
|
||||
|
@ -24,6 +27,30 @@
|
|||
<ClCompile Include="src\Camera.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imgui\imgui.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imgui\imgui_demo.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imgui\imgui_draw.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imgui\imgui_tables.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imgui\imgui_widgets.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\imgui_demo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imgui\backends\imgui_impl_glfw.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imgui\backends\imgui_impl_opengl3.cpp">
|
||||
<Filter>imgui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="shaders\parade_vs.glsl">
|
||||
|
@ -32,10 +59,48 @@
|
|||
<None Include="shaders\parade_fs.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
<None Include="imgui\.editorconfig">
|
||||
<Filter>imgui</Filter>
|
||||
</None>
|
||||
<None Include="imgui\.gitattributes">
|
||||
<Filter>imgui</Filter>
|
||||
</None>
|
||||
<None Include="imgui\.gitignore">
|
||||
<Filter>imgui</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\Camera.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\imconfig.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\imgui.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\imgui_internal.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\imstb_rectpack.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\imstb_textedit.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\imstb_truetype.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\backends\imgui_impl_glfw.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\backends\imgui_impl_opengl3.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="imgui\LICENSE.txt">
|
||||
<Filter>imgui</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 208b8242bc8dfc86c2cb0a22156eef4cb5977476
|
|
@ -0,0 +1,10 @@
|
|||
[Window][Debug##Default]
|
||||
Pos=60,60
|
||||
Size=400,400
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug Window]
|
||||
Pos=1,7
|
||||
Size=370,123
|
||||
Collapsed=0
|
||||
|
|
@ -14,6 +14,8 @@ uniform vec3 ka;
|
|||
uniform vec3 kd;
|
||||
uniform vec3 ks;
|
||||
|
||||
uniform float smoothing;
|
||||
|
||||
in vec3 v_pos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
@ -109,6 +111,7 @@ void main(void)
|
|||
int max_steps = 1000;
|
||||
vec3 light_pos = vec3(0.0, 1.0, 0.0);
|
||||
int spec_exponent = 40;
|
||||
float k = smoothing;
|
||||
|
||||
initTorus();
|
||||
initSphere();
|
||||
|
@ -125,7 +128,7 @@ void main(void)
|
|||
steps++;
|
||||
float distTorus = torusSDF(ray_pos.xyz, torus.R, torus.r);
|
||||
float distSphere = sphereSDF(ray_pos.xyz, sphere.center, sphere.r);
|
||||
float minDist = smoothMinSDF(distTorus, distSphere, 1.0);
|
||||
float minDist = smoothMinSDF(distTorus, distSphere, k);
|
||||
//bool isTorus = distTorus < distSphere;
|
||||
//float minDist = min(distTorus, distSphere);
|
||||
|
||||
|
@ -138,7 +141,7 @@ void main(void)
|
|||
|
||||
vec4 ambient = vec4(la, 1.0) * ambient_color;
|
||||
|
||||
normals = estimateSmoothNormals(ray_pos.xyz, 1.0);
|
||||
normals = estimateSmoothNormals(ray_pos.xyz, k);
|
||||
|
||||
//if (isTorus)
|
||||
// normals = estimateNormalsTorus(ray_pos.xyz);
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#include "imgui.h"
|
||||
#include "backends/imgui_impl_glfw.h"
|
||||
#include "backends/imgui_impl_opengl3.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
@ -53,6 +57,8 @@ namespace scene
|
|||
glm::vec3 kd = { 193.0 / 255.0, 41.0 / 255.0, 46.0 / 255.0 }; // Object diffuse color
|
||||
glm::vec3 ks = { 1.0f, 1.0f, 1.0f }; // Object specular color
|
||||
int specular_exponent = 10.f;
|
||||
|
||||
float smoothing = 0.001f;
|
||||
}
|
||||
|
||||
namespace mouse
|
||||
|
@ -147,6 +153,36 @@ void InitCanvas()
|
|||
|
||||
}
|
||||
|
||||
//Draw the ImGui user interface
|
||||
void draw_gui(GLFWwindow* window)
|
||||
{
|
||||
//Begin ImGui Frame
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
//Draw Gui
|
||||
ImGui::Begin("Debug Window");
|
||||
if (ImGui::Button("Quit"))
|
||||
{
|
||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||
}
|
||||
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||
ImGui::SliderFloat("Smoothing", &scene::smoothing, 0.001f, 1.0f);
|
||||
ImGui::End();
|
||||
|
||||
static bool show_test = false;
|
||||
if (show_test)
|
||||
{
|
||||
ImGui::ShowDemoWindow(&show_test);
|
||||
}
|
||||
|
||||
//End ImGui Frame
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
void idle()
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
@ -193,6 +229,11 @@ void display(GLFWwindow* window)
|
|||
{
|
||||
glUniform1i(window_height_loc, window::size[1]);
|
||||
}
|
||||
int smoothing_loc = glGetUniformLocation(scene::shader, "smoothing");
|
||||
if (smoothing_loc != -1)
|
||||
{
|
||||
glUniform1f(smoothing_loc, scene::smoothing);
|
||||
}
|
||||
|
||||
glUniform3fv(glGetUniformLocation(scene::shader, "light_pos"), 1, glm::value_ptr(scene::Lp));
|
||||
glUniform3fv(glGetUniformLocation(scene::shader, "la"), 1, glm::value_ptr(scene::La));
|
||||
|
@ -208,6 +249,8 @@ void display(GLFWwindow* window)
|
|||
glBindVertexArray(VAO);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, sizeof(vertices) / 3);
|
||||
|
||||
draw_gui(window);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
|
@ -245,8 +288,8 @@ void keyboard_callback(GLFWwindow* window, int key, int scancode, int action, in
|
|||
|
||||
void orbit_camera()
|
||||
{
|
||||
scene::yaw += mouse::xoffset;
|
||||
scene::pitch += mouse::yoffset;
|
||||
scene::yaw += (float)mouse::xoffset;
|
||||
scene::pitch += (float)mouse::yoffset;
|
||||
|
||||
scene::camera.orbit(scene::yaw, scene::pitch);
|
||||
}
|
||||
|
@ -346,6 +389,11 @@ int main()
|
|||
|
||||
init();
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||
ImGui_ImplOpenGL3_Init("#version 150");
|
||||
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
idle();
|
||||
|
@ -354,5 +402,9 @@ int main()
|
|||
glfwPollEvents();
|
||||
}
|
||||
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue