Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fromExistingPointer #18

Open
Hyper157 opened this issue Dec 10, 2018 · 9 comments
Open

fromExistingPointer #18

Hyper157 opened this issue Dec 10, 2018 · 9 comments
Labels
question Further information is requested

Comments

@Hyper157
Copy link

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);

	}
@ice1000 ice1000 added the question Further information is requested label Dec 11, 2018
@ice1000
Copy link
Owner

ice1000 commented Dec 11, 2018

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
Copy link
Owner

ice1000 commented Dec 11, 2018

BTW, OS, your GLFW dependency, please.

@Hyper157
Copy link
Author

Hyper157 commented Dec 11, 2018

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

@ice1000
Copy link
Owner

ice1000 commented Dec 11, 2018

Some related discussion #12 #13

@Hyper157
Copy link
Author

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

@Hyper157
Copy link
Author

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

@ice1000
Copy link
Owner

ice1000 commented Dec 11, 2018

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

@Hyper157
Copy link
Author

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

@Schlupps
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants