Skip to content

fromExistingPointer #18

Open
Open
@Hyper157

Description

@Hyper157

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

	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions