Added a simple visibility toggle command, fixed some bugs on linux
This commit is contained in:
parent
b2de337c43
commit
dc8e5a5483
@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMAKE_CXX_FLAGS "-D_DEBUG")
|
set(CMAKE_CXX_FLAGS "-D_DEBUG")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "-D_DEBUG -Wall")
|
set(CMAKE_CXX_FLAGS "-D_DEBUG -Wall -O3")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(Pleascach)
|
project(Pleascach)
|
||||||
|
|||||||
@ -70,15 +70,17 @@ struct Renderer {
|
|||||||
|
|
||||||
Camera cam{ .pos = glm::vec3(0.0, 5.0, 0.0), };
|
Camera cam{ .pos = glm::vec3(0.0, 5.0, 0.0), };
|
||||||
|
|
||||||
|
|
||||||
|
float fps;
|
||||||
bool capture_mouse = false;
|
bool capture_mouse = false;
|
||||||
bool flycam = false;
|
bool flycam = false;
|
||||||
/* time speed */
|
/* time speed */
|
||||||
float time = 0.0;
|
float time = 0.0;
|
||||||
float speed = 1.0;
|
float speed = 1.0;
|
||||||
bool paused = false;
|
bool paused = false;
|
||||||
|
bool visibility_testing = false;
|
||||||
|
|
||||||
size_t n_indices;
|
size_t n_indices;
|
||||||
bool visibility_testing;
|
|
||||||
|
|
||||||
float near_plane = 2.0f;
|
float near_plane = 2.0f;
|
||||||
float far_plane = 10000.0f;
|
float far_plane = 10000.0f;
|
||||||
|
|||||||
38
UI/UI.cpp
38
UI/UI.cpp
@ -21,18 +21,12 @@ static csys::ItemLog& operator<<(csys::ItemLog& log, ImVector<float>& vec) {
|
|||||||
return log << vec[vec.size() - 1] << " }";
|
return log << vec[vec.size() - 1] << " }";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vec_setter(ImVector<float>& v, std::vector<float> in) {
|
/*static void vec_setter(ImVector<float>& v, std::vector<float> in) {
|
||||||
v.reserve(in.size());
|
v.reserve(in.size());
|
||||||
std::memcpy(v.Data, in.data(), sizeof(float) * in.size());
|
std::memcpy(v.Data, in.data(), sizeof(float) * in.size());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
UI::UI(Renderer* ren) :
|
UI::UI(Renderer* ren) : ren(ren), dev(ren->dev) {
|
||||||
info {
|
|
||||||
.flycam = ren->flycam, .visibility_testing = ren->visibility_testing,
|
|
||||||
.time = ren->time, .cam = ren->cam, .tess_factor = ren->tess_factor,
|
|
||||||
.tess_edge_size = ren->tess_edge_size, .n_indices = ren->n_indices,
|
|
||||||
.near_plane = ren->near_plane, .far_plane = ren->far_plane, .paused = ren->paused
|
|
||||||
}, dev(ren->dev) {
|
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
@ -107,8 +101,13 @@ UI::UI(Renderer* ren) :
|
|||||||
|
|
||||||
console = std::make_unique<ImGuiConsole>("developer console");
|
console = std::make_unique<ImGuiConsole>("developer console");
|
||||||
console->System().RegisterCommand("pause", "Pauses or unpauses the engine", [this]() {
|
console->System().RegisterCommand("pause", "Pauses or unpauses the engine", [this]() {
|
||||||
this->info.paused = !this->info.paused;
|
this->ren->paused = !this->ren->paused;
|
||||||
console->System().Log(csys::ItemType::INFO) << "Paused: " << (this->info.paused? "True" : "False") << csys::endl;
|
console->System().Log(csys::ItemType::INFO) << "Paused: " << (this->ren->paused? "True" : "False") << csys::endl;
|
||||||
|
});
|
||||||
|
|
||||||
|
console->System().RegisterCommand("toggle-visibility-testing", "Toggles visibility testings (using clusters and frustum culling)", [this]() {
|
||||||
|
this->ren->visibility_testing = !this->ren->visibility_testing;
|
||||||
|
console->System().Log(csys::ItemType::INFO) << "Visibility Testing: " << (this->ren->visibility_testing? "Enabled" : "Disabled") << csys::endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
console->System().Log(csys::ItemType::INFO) << "Welcome to Pleascach!" << csys::endl;
|
console->System().Log(csys::ItemType::INFO) << "Welcome to Pleascach!" << csys::endl;
|
||||||
@ -122,15 +121,14 @@ void UI::newFrame() {
|
|||||||
ImGui::SetNextWindowBgAlpha(0.5f);
|
ImGui::SetNextWindowBgAlpha(0.5f);
|
||||||
ImGui::Begin("Rendering Info", nullptr);
|
ImGui::Begin("Rendering Info", nullptr);
|
||||||
|
|
||||||
ImGui::Text("# of Indices: %zu", info.n_indices);
|
ImGui::Text("# of Indices: %zu", ren->n_indices);
|
||||||
ImGui::Text("FPS: %f", info.fps);
|
ImGui::Text("FPS: %f", ren->fps);
|
||||||
ImGui::Text("Time: %f", info.time);
|
ImGui::Text("Time: %f", ren->time);
|
||||||
ImGui::Checkbox("Fly Camera", &info.flycam);
|
ImGui::Checkbox("Fly Camera", &ren->flycam);
|
||||||
ImGui::Checkbox("Visibility Testing", &info.visibility_testing);
|
ImGui::SliderFloat("Near Plane", &ren->near_plane, 0.00, 0.20);
|
||||||
ImGui::SliderFloat("Near Plane", &info.near_plane, 0.00, 0.20);
|
ImGui::SliderFloat("Far Plane", &ren->far_plane, 1000.0, 10000.0);
|
||||||
ImGui::SliderFloat("Far Plane", &info.far_plane, 1000.0, 10000.0);
|
ImGui::SliderFloat("Tessellation Factor", &ren->tess_factor, 0.1, 10.0);
|
||||||
ImGui::SliderFloat("Tessellation Factor", &info.tess_factor, 0.1, 10.0);
|
ImGui::SliderFloat("Edge Size", &ren->tess_edge_size, 0.0, 40.0);
|
||||||
ImGui::SliderFloat("Edge Size", &info.tess_edge_size, 0.0, 40.0);
|
|
||||||
|
|
||||||
console->Draw();
|
console->Draw();
|
||||||
|
|
||||||
|
|||||||
18
UI/UI.hpp
18
UI/UI.hpp
@ -13,23 +13,7 @@ struct Renderer;
|
|||||||
struct Camera;
|
struct Camera;
|
||||||
|
|
||||||
struct UI {
|
struct UI {
|
||||||
struct UI_Info {
|
Renderer* ren;
|
||||||
float fps = 0.0;
|
|
||||||
bool& flycam;
|
|
||||||
bool& visibility_testing;
|
|
||||||
float& time;
|
|
||||||
/* camera stuff */
|
|
||||||
Camera& cam;
|
|
||||||
float& tess_factor;
|
|
||||||
float& tess_edge_size;
|
|
||||||
const size_t& n_indices;
|
|
||||||
float& near_plane;
|
|
||||||
float& far_plane;
|
|
||||||
bool& paused;
|
|
||||||
} info;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vk::Device dev;
|
vk::Device dev;
|
||||||
vk::DescriptorPool desc_pool;
|
vk::DescriptorPool desc_pool;
|
||||||
|
|
||||||
|
|||||||
@ -69,8 +69,6 @@ int main(int argc, char* argv[]) {
|
|||||||
ren.speed *= 10.0;
|
ren.speed *= 10.0;
|
||||||
} else if (event.key.key == GLFW_KEY_Y && event.key.state == GLFW_PRESS) {
|
} else if (event.key.key == GLFW_KEY_Y && event.key.state == GLFW_PRESS) {
|
||||||
ren.speed /= 10.0;
|
ren.speed /= 10.0;
|
||||||
} else if (event.key.key == GLFW_KEY_V && event.key.state == GLFW_PRESS) {
|
|
||||||
ren.visibility_testing = !ren.visibility_testing;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -79,7 +77,7 @@ int main(int argc, char* argv[]) {
|
|||||||
ren.draw();
|
ren.draw();
|
||||||
ren.present();
|
ren.present();
|
||||||
const auto t = frame_timer.read();
|
const auto t = frame_timer.read();
|
||||||
ren.ui->info.fps = 1000.0f / t;
|
ren.fps = 1000.0f / t;
|
||||||
|
|
||||||
while (frame_timer.read() < 16.60)
|
while (frame_timer.read() < 16.60)
|
||||||
;
|
;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user