jimgui icon indicating copy to clipboard operation
jimgui copied to clipboard

fromExistingPointer

Open Hyper157 opened this issue 6 years ago • 9 comments
trafficstars

Hello,

I'm trying to use my own GLFW window to draw Jimgui instead of the default one it creates, however I keep getting errors and crashing, perhaps a bug or wrong usage? Thank you.

public static void main(String[] args) {
		JniLoader.load();
		glfwSetErrorCallback(errorCallback);

		glfwWindowHint(GLFW_ALPHA_BITS, 8);
		glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GL_TRUE);
		glfwWindowHint(GLFW_DECORATED, GL_FALSE);

		long window = glfwCreateWindow(800, 800, "Test", 0, 0);
		if (window == 0) {
			System.exit(1);
		}

		glfwMakeContextCurrent(window);
		GL.createCapabilities();

		glfwSwapInterval(1);
		glfwSetKeyCallback(window, keyCallback);
		
		JImGui gui = JImGui.fromExistingPointer(window);
        gui.initBeforeMainLoop();
		while (!glfwWindowShouldClose(window)) {

			glViewport(0, 0, 800, 800);
			glClearColor(0, 0, 0, 0);
			glClear(GL_COLOR_BUFFER_BIT);
			
			gui.initNewFrame();
			gui.text("This is gui");
			gui.render();
		}

		glfwDestroyWindow(window);
		glfwTerminate();
		System.out.println("Terminated.");
		System.exit(0);

	}

Hyper157 avatar Dec 10 '18 12:12 Hyper157

Could u plz try changing

JImGui gui = JImGui.fromExistingPointer(window);
gui.initBeforeMainLoop();
while (!window.windowShouldClose()) {
	glViewport(0, 0, 800, 800);
	glClearColor(0, 0, 0, 0);
	glClear(GL_COLOR_BUFFER_BIT);

	gui.initNewFrame();
	gui.text("This is gui");
	gui.render();
}

into

JImGui gui = JImGui.fromExistingPointer(window);
gui.initBeforeMainLoop();
while (!glfwWindowShouldClose(window)) {			
	gui.initNewFrame();
	gui.text("This is gui");
	gui.render();
}

ice1000 avatar Dec 11 '18 01:12 ice1000

BTW, OS, your GLFW dependency, please.

ice1000 avatar Dec 11 '18 01:12 ice1000

Thank you for answering,

tried doing what you told and still crashing :(

OS: Windows 10 GLFW Version: lwjgl-release-3.2.0

Crash log: hs_err_pid8812.log

Hyper157 avatar Dec 11 '18 04:12 Hyper157

Some related discussion #12 #13

ice1000 avatar Dec 11 '18 06:12 ice1000

I was following some discussions about this but I couldn't fix yet

Hyper157 avatar Dec 11 '18 06:12 Hyper157

Also tried your example of MultiWindows and it didn't even work, was crashing too

Hyper157 avatar Dec 11 '18 06:12 Hyper157

They work on Linux, and at that time I only have Linux device. Now I have Windows, but this week is the final exam week

ice1000 avatar Dec 11 '18 07:12 ice1000

All good I'll be looking forward for updates, take your time, thank you.

Hyper157 avatar Dec 11 '18 07:12 Hyper157

Hi,

I have the same problem. The creation works and I get an Instance of the JimGui Class. The error occurs when I try to execute something like: imGui.text("Hello, World!");

Its some time ago when you wrote that you now have a Windows machine. I also try it in Windows 10 and GLFW 3.2.1 build 12.

Please have again a look on it. If necessary I could deliver you also some hints.

Thanks in advance.

Schlupps avatar Jan 24 '19 12:01 Schlupps