Use ImGui's DisplaySize so display size for layer positioning etc can be set the same way for vulkan and OpenGL

pull/93/head
jackun 4 years ago
parent 3d46ccafe1
commit 6ad6bffade
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -166,8 +166,8 @@ void imgui_render()
ImGui::NewFrame();
{
std::lock_guard<std::mutex> lk(notifier.mutex);
position_layer(params, window_size, vp[2], vp[3]);
render_imgui(sw_stats, params, window_size, vp[2], vp[3], false);
position_layer(params, window_size);
render_imgui(sw_stats, params, window_size, false);
}
ImGui::PopStyleVar(3);

@ -1010,8 +1010,10 @@ static float get_time_stat(void *_data, int _idx)
return data->frames_stats[idx].stats[data->stat_selector] / data->time_dividor;
}
void position_layer(struct overlay_params& params, ImVec2 window_size, unsigned width, unsigned height)
void position_layer(struct overlay_params& params, ImVec2 window_size)
{
unsigned width = ImGui::GetIO().DisplaySize.x;
unsigned height = ImGui::GetIO().DisplaySize.y;
float margin = 10.0f;
if (params.offset_x > 0 || params.offset_y > 0)
margin = 0.0f;
@ -1057,10 +1059,12 @@ static void right_aligned_text(float off_x, const char *fmt, ...)
ImGui::Text("%s", buffer);
}
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, unsigned width, unsigned height, bool is_vulkan)
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan)
{
static float char_width = ImGui::CalcTextSize("A").x;
window_size = ImVec2(params.width, params.height);
unsigned width = ImGui::GetIO().DisplaySize.x;
unsigned height = ImGui::GetIO().DisplaySize.y;
if (!params.no_display){
ImGui::Begin("Main", &open, ImGuiWindowFlags_NoDecoration);
@ -1316,8 +1320,8 @@ static void compute_swapchain_display(struct swapchain_data *data)
ImGui::NewFrame();
{
scoped_lock lk(instance_data->notifier.mutex);
position_layer(instance_data->params, data->window_size, data->width, data->height);
render_imgui(data->sw_stats, instance_data->params, data->window_size, data->width, data->height, true);
position_layer(instance_data->params, data->window_size);
render_imgui(data->sw_stats, instance_data->params, data->window_size, true);
}
ImGui::PopStyleVar(3);

@ -45,8 +45,8 @@ struct fps_limit {
extern struct fps_limit fps_limit_stats;
void position_layer(struct overlay_params& params, ImVec2 window_size, unsigned width, unsigned height);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, unsigned width, unsigned height, bool is_vulkan);
void position_layer(struct overlay_params& params, ImVec2 window_size);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);
void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID);
void init_gpu_stats(uint32_t& vendorID, overlay_params& params);
void init_cpu_stats(overlay_params& params);

Loading…
Cancel
Save