AirGuanZ / imgui-filebrowser

File browser implementation for dear-imgui. C++17 is required.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Which compiler should I use to compile this library?

CaptainHandyman opened this issue · comments

commented

Which compiler should I use to compile this library: Visual C++ or GCC?

Look at this code:

#include "headers/imfilebrowser.h"

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <imgui.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <bits/stdc++.h>
using namespace std;

GLFWwindow *window = NULL;

ImGui::FileBrowser fileBrowser;

int main(int argc, char **argv) {
	glfwInit();

	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

	window = glfwCreateWindow(800, 600, "File browser", NULL, NULL);

	glfwSetWindowPos(window, (1920 / 2) - 400, (1080 / 2) - 300);

	glfwSwapInterval(GLFW_TRUE);

	glfwMakeContextCurrent(window);

	gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);

	IMGUI_CHECKVERSION();
	ImGui::CreateContext();
	ImGuiIO &io = ImGui::GetIO();
	(void)io;

	io.IniFilename = NULL;

	ImGui_ImplGlfw_InitForOpenGL(window, true);
	ImGui_ImplOpenGL3_Init();

	do {
		glfwPollEvents();

		ImGui_ImplOpenGL3_NewFrame();
		ImGui_ImplGlfw_NewFrame();
		ImGui::NewFrame();

		ImGui::Render();

		glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT);

		ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

		glfwSwapBuffers(window);
	} while (!glfwWindowShouldClose(window));

	ImGui_ImplOpenGL3_Shutdown();
	ImGui_ImplGlfw_Shutdown();
	ImGui::DestroyContext();

	glfwDestroyWindow(window);

	glfwTerminate();
}
ImGui::FileBrowser fileBrowser;

If you remove this line, the program will start, and if you leave it, the program will not respond at all and will not start, without any error.

What can I do in this situation?

I compiled this code with MinGW.

Hi,
I failed to reproduce the problem you meet. All operations in FileBrowser's constructor are just memory allocations and file queries. Could you please check which is the last successfully executed line in FileBrowser::FileBrowser? You can use either a debugger or printf. Thank you!

commented

Sorry to bother you, but I've fixed the bug. I just installed MSYS2 and all the mingw-w64 components and everything worked.