Commit 9cf4035b authored by Dave's avatar Dave 🚴
Browse files

Minor modifications

parent d3d4339e
......@@ -44,6 +44,8 @@ private:
Viewport *v;
float frametime;
bool ShouldClose;
public:
......
......@@ -10,10 +10,10 @@ in vec3 pos;
void main(){
vec3 lightColor = vec3(1.0, 1.0, 1.0);
vec3 objectColor = vec3(0.9);
vec3 objectColor = vec3(1.0);
// ambient
float ambientStrength = 0.2;
float ambientStrength = 0.1;
vec3 ambient = ambientStrength * lightColor;
// diffuse
......@@ -23,13 +23,10 @@ void main(){
vec3 diffuse = diff * lightColor;
// specular
float specularStrength = 0.7;
float specularStrength = 0.5;
vec3 viewDir = normalize(cameraPos - pos);
vec3 reflectDir = reflect(-lightDir, norm);
vec3 reflectDir = reflect(-lightDir, norm);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32);
vec3 specular = specularStrength * spec * lightColor;
vec3 result = diffuse * objectColor;
//result = vec3(normal.x, normal.y, normal.z);
outColor = vec4(result, 1.0);
vec3 specular = specularStrength * spec * lightColor;
outColor = vec4((ambient + diffuse + specular) * objectColor, 1.0);
}
\ No newline at end of file
......@@ -181,7 +181,7 @@ void App::MoveCamera()
}
if (mouseScrollEvent)
{
c.zoom(mouseScrollOffset.y * 0.2, normalizedmouse[0], normalizedmouse[1]);
c.zoom(mouseScrollOffset.y * 0.8, normalizedmouse[0], normalizedmouse[1]);
mouseScrollEvent = false;
}
}
......@@ -191,18 +191,19 @@ void App::MoveCamera()
void App::Render()
{
// std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
GetInput();
MoveCamera();
v->SetCameraTransform(c.transform());
v->Render();
RenderUI(v->GetTexture());
// std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
// std::this_thread::sleep_for(std::chrono::microseconds(17 * 1000) - std::chrono::microseconds(std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count()));
glfwSwapBuffers(window);
glfwPollEvents();
if (/*glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS || */ glfwWindowShouldClose(window))
ShouldClose = true;
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
frametime = std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count();
std::this_thread::sleep_for(std::chrono::microseconds(17 * 1000) - std::chrono::microseconds(std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count()));
}
void App::RenderUI(unsigned int FBOtexture)
......@@ -215,7 +216,7 @@ void App::RenderUI(unsigned int FBOtexture)
ImGui::NewFrame();
ImGui::DockSpaceOverViewport();
//ImGui::ShowDemoWindow();
// ImGui::ShowDemoWindow();
{
static int counter = 0;
......@@ -243,7 +244,7 @@ void App::RenderUI(unsigned int FBOtexture)
v->SetLightPos(lightPos);
ImGui::Text("Ctrl + click on the sliders for text input");
ImGui::Text("Grid unit: %fmm", scale);
ImGui::Text("Grid unit: %.2fmm", scale);
ImGui::SliderFloat("Scale", &scale, 0.0f, 10.0f);
ImGui::SliderFloat("Model x", &x, -10.0f, 10.0f);
ImGui::SliderFloat("Model y", &y, -10.0f, 10.0f);
......@@ -259,21 +260,15 @@ void App::RenderUI(unsigned int FBOtexture)
if (ImGui::Button("Toggle wireframe mode"))
v->ToggleWireframe();
}
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::Text("Application average %.3f ms/frame", frametime / 1000.0f);
ImGui::End();
}
{
ImGui::Begin("Viewport");
mouseIsOverViewport = ImGui::IsWindowHovered();
v->SetSize(ImGui::GetWindowSize());
v->SetPos(ImGui::GetWindowPos());
v->SetSize({v->GetSize().x - 16, v->GetSize().y - (ImGui::GetFontSize() + 22)});
/*
22 = 3 * 2 Title bar FramePadding (+ font size to get title bar height) https://github.com/ocornut/imgui/issues/1539
+ 8 * 2 Top and bottom internal window padding
*/
v->SetSize(ImGui::GetContentRegionAvail());
ImGui::GetWindowDrawList()->AddImage(
(void *)(intptr_t)FBOtexture,
ImVec2(ImGui::GetCursorScreenPos()),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment