Compare commits
No commits in common. "4c848990840d7c339656579d731b0d5658d95c35" and "002bbcd097604ceaa234cd7da45cb634214ff3f0" have entirely different histories.
4c84899084
...
002bbcd097
104
src/main.cpp
104
src/main.cpp
@ -55,10 +55,7 @@ static M4x4 inverse_view_matrix = inverse_view(V3_(0.0f, 0.0f, 0.0f), radians(45
|
|||||||
static M4x4 projection_matrix = projection (radians(45.0f), 16.0f / 9.0f, NEAR_PLANE);
|
static M4x4 projection_matrix = projection (radians(45.0f), 16.0f / 9.0f, NEAR_PLANE);
|
||||||
static M4x4 inverse_projection_matrix = inverse_projection(radians(45.0f), 16.0f / 9.0f, NEAR_PLANE);
|
static M4x4 inverse_projection_matrix = inverse_projection(radians(45.0f), 16.0f / 9.0f, NEAR_PLANE);
|
||||||
|
|
||||||
static SDL_Time time;
|
static SDL_DateTime time_offset = {};
|
||||||
|
|
||||||
static bool use_actual_time = true;
|
|
||||||
static SDL_DateTime calendar_time;
|
|
||||||
|
|
||||||
static int time_tints_times[4][3] = {
|
static int time_tints_times[4][3] = {
|
||||||
{ 4, 0, 0 },
|
{ 4, 0, 0 },
|
||||||
@ -1151,7 +1148,7 @@ int main(int argc, char **argv) {
|
|||||||
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
||||||
.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
||||||
|
|
||||||
.max_anisotropy = 16.0f,
|
.max_anisotropy = 4.0f,
|
||||||
.enable_anisotropy = true,
|
.enable_anisotropy = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1215,7 +1212,7 @@ int main(int argc, char **argv) {
|
|||||||
bool first_frame = true;
|
bool first_frame = true;
|
||||||
bool show_demo_window = false;
|
bool show_demo_window = false;
|
||||||
bool show_tile_picker = false;
|
bool show_tile_picker = false;
|
||||||
bool show_settings = false;
|
|
||||||
|
|
||||||
SDL_GetWindowSizeInPixels(window, &window_width, &window_height);
|
SDL_GetWindowSizeInPixels(window, &window_width, &window_height);
|
||||||
|
|
||||||
@ -1226,13 +1223,18 @@ int main(int argc, char **argv) {
|
|||||||
ImGui_ImplSDL3_NewFrame();
|
ImGui_ImplSDL3_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
SDL_Time time;
|
||||||
SDL_GetCurrentTime(&time);
|
SDL_GetCurrentTime(&time);
|
||||||
|
|
||||||
if (use_actual_time)
|
SDL_DateTime calendar_time;
|
||||||
SDL_TimeToDateTime(time, &calendar_time, true);
|
SDL_TimeToDateTime(time, &calendar_time, true);
|
||||||
|
|
||||||
calendar_time.minute += calendar_time.second >= 0 ? calendar_time.second / 60 : calendar_time.second / 60 - 1;
|
calendar_time.second += time_offset.second;
|
||||||
calendar_time.hour += calendar_time.minute >= 0 ? calendar_time.minute / 60 : calendar_time.minute / 60 - 1;
|
calendar_time.minute += time_offset.minute;
|
||||||
|
calendar_time.hour += time_offset.hour;
|
||||||
|
|
||||||
|
calendar_time.minute += calendar_time.second / 60;
|
||||||
|
calendar_time.hour += calendar_time.minute / 60;
|
||||||
|
|
||||||
calendar_time.second = real_mod(calendar_time.second, 60);
|
calendar_time.second = real_mod(calendar_time.second, 60);
|
||||||
calendar_time.minute = real_mod(calendar_time.minute, 60);
|
calendar_time.minute = real_mod(calendar_time.minute, 60);
|
||||||
@ -1240,12 +1242,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (ImGui::BeginMainMenuBar()) {
|
if (ImGui::BeginMainMenuBar()) {
|
||||||
if (ImGui::BeginMenu("File")) {
|
if (ImGui::BeginMenu("File")) {
|
||||||
ImGui::MenuItem("Settings", NULL, &show_settings);
|
|
||||||
ImGui::MenuItem("Demo Window", NULL, &show_demo_window);
|
ImGui::MenuItem("Demo Window", NULL, &show_demo_window);
|
||||||
ImGui::Separator();
|
|
||||||
if (ImGui::MenuItem("Exit")) {
|
|
||||||
Running = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
@ -1270,50 +1267,6 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
ImGui::DockSpaceOverViewport(main_viewport_dock, ImGui::GetMainViewport(), ImGuiDockNodeFlags_AutoHideTabBar | ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_NoDockingOverCentralNode);
|
ImGui::DockSpaceOverViewport(main_viewport_dock, ImGui::GetMainViewport(), ImGuiDockNodeFlags_AutoHideTabBar | ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_NoDockingOverCentralNode);
|
||||||
|
|
||||||
if (show_settings) {
|
|
||||||
ImGui::SetNextWindowSize(ImVec2(400, 0), ImGuiCond_FirstUseEver);
|
|
||||||
if (ImGui::Begin("Settings", &show_settings)) {
|
|
||||||
ImGui::DragFloat("fovy", &per_frame.fovy_degrees);
|
|
||||||
ImGui::DragFloat("camera_distance", &per_frame.camera_distance, 0.25f, 1.0f, INFINITY);
|
|
||||||
ImGui::DragFloat("camera_tilt", &per_frame.camera_tilt, 0.25f, 0.0f, 89.0f);
|
|
||||||
|
|
||||||
if (ImGui::Checkbox("MSAA", &enable_msaa)) {
|
|
||||||
recreate_graphics_pipelines();
|
|
||||||
if (msaa_texture) {
|
|
||||||
SDL_ReleaseGPUTexture(device, msaa_texture);
|
|
||||||
msaa_texture = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
|
||||||
ImGui::BeginDisabled(use_actual_time);
|
|
||||||
ImGui::DragScalarN("Time", ImGuiDataType_S32, &calendar_time.hour, 3);
|
|
||||||
ImGui::EndDisabled();
|
|
||||||
ImGui::Checkbox("use actual time", &use_actual_time);
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
|
||||||
imgui_time_picker("time0", time_tints_times[0]);
|
|
||||||
imgui_time_picker("time1", time_tints_times[1]);
|
|
||||||
imgui_time_picker("time2", time_tints_times[2]);
|
|
||||||
imgui_time_picker("time3", time_tints_times[3]);
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
|
||||||
ImGui::ColorEdit3("time0_color", time_tints[0].E);
|
|
||||||
ImGui::ColorEdit3("time1_color", time_tints[1].E);
|
|
||||||
ImGui::ColorEdit3("time2_color", time_tints[2].E);
|
|
||||||
ImGui::ColorEdit3("time3_color", time_tints[3].E);
|
|
||||||
|
|
||||||
if (selected_tile != -1 && ImGui::IsWindowFocused() && ImGui::IsKeyPressed(ImGuiKey_R, false)) {
|
|
||||||
if (ImGui::IsKeyDown(ImGuiKey_LeftShift)) {
|
|
||||||
selected_rotation = (selected_rotation - 1) & 3;
|
|
||||||
} else {
|
|
||||||
selected_rotation = (selected_rotation + 1) & 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (show_tile_picker) {
|
if (show_tile_picker) {
|
||||||
if (ImGui::Begin("Tile Picker", &show_tile_picker, ImGuiWindowFlags_NoFocusOnAppearing)) {
|
if (ImGui::Begin("Tile Picker", &show_tile_picker, ImGuiWindowFlags_NoFocusOnAppearing)) {
|
||||||
if (SelectableTile("##tile", selected_tile == -1, NULL, 0, ImVec2(32, 32))) {
|
if (SelectableTile("##tile", selected_tile == -1, NULL, 0, ImVec2(32, 32))) {
|
||||||
@ -1366,6 +1319,41 @@ int main(int argc, char **argv) {
|
|||||||
if (ImGui::Selectable("Random", selected_rotation == -1))
|
if (ImGui::Selectable("Random", selected_rotation == -1))
|
||||||
selected_rotation = -1;
|
selected_rotation = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::DragFloat("fovy", &per_frame.fovy_degrees);
|
||||||
|
ImGui::DragFloat("camera_distance", &per_frame.camera_distance, 0.25f, 1.0f, INFINITY);
|
||||||
|
ImGui::DragFloat("camera_tilt", &per_frame.camera_tilt, 0.25f, 0.0f, 89.0f);
|
||||||
|
|
||||||
|
if (ImGui::Checkbox("MSAA", &enable_msaa)) {
|
||||||
|
recreate_graphics_pipelines();
|
||||||
|
if (msaa_texture) {
|
||||||
|
SDL_ReleaseGPUTexture(device, msaa_texture);
|
||||||
|
msaa_texture = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::DragScalarN("calendar_time", ImGuiDataType_S32, &calendar_time.hour, 3);
|
||||||
|
imgui_time_picker("time_offset", &time_offset.hour);
|
||||||
|
|
||||||
|
ImGui::NewLine();
|
||||||
|
imgui_time_picker("time0", time_tints_times[0]);
|
||||||
|
imgui_time_picker("time1", time_tints_times[1]);
|
||||||
|
imgui_time_picker("time2", time_tints_times[2]);
|
||||||
|
imgui_time_picker("time3", time_tints_times[3]);
|
||||||
|
|
||||||
|
ImGui::NewLine();
|
||||||
|
ImGui::ColorEdit3("time0_color", time_tints[0].E);
|
||||||
|
ImGui::ColorEdit3("time1_color", time_tints[1].E);
|
||||||
|
ImGui::ColorEdit3("time2_color", time_tints[2].E);
|
||||||
|
ImGui::ColorEdit3("time3_color", time_tints[3].E);
|
||||||
|
|
||||||
|
if (selected_tile != -1 && ImGui::IsWindowFocused() && ImGui::IsKeyPressed(ImGuiKey_R, false)) {
|
||||||
|
if (ImGui::IsKeyDown(ImGuiKey_LeftShift)) {
|
||||||
|
selected_rotation = (selected_rotation - 1) & 3;
|
||||||
|
} else {
|
||||||
|
selected_rotation = (selected_rotation + 1) & 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user