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

Add port of GLFW backend and use in GLFW example #13

Merged
merged 4 commits into from
Jun 28, 2020
Merged

Add port of GLFW backend and use in GLFW example #13

merged 4 commits into from
Jun 28, 2020

Conversation

junglie85
Copy link

The original Dear ImGui has an example GLFW backend that shows how we can configure and uself GLFW without having to pollute our application logic with backend specific calls. GLFW is the primary windowing system for LWJGL but I think porting this example is a good addition to the package.

Copy link
Owner

@SpaiR SpaiR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!
I've reviewed PR and with minor adjustments I would love to merge it. Appreciate your contribution!

@SpaiR
Copy link
Owner

SpaiR commented Jun 26, 2020

Speacking about buffers. I try to keep binding with lower overhead as possible. With avoiding of operations, which do complex things. For example, personally I would prefer to use

private final cursorPosX = new double[1];
private final cursorPosY = new double[1];

glfwGetCursorPos(windowId, cursorPosX, cursorPosY);
io.setMousePos((float) cursorPosX[0], (float) cursorPosY[0]);

instead of

try (MemoryStack stack = stackPush()) {
	final DoubleBuffer xPos = stack.mallocDouble(1);
	final DoubleBuffer yPos = stack.mallocDouble(1);
	glfwGetCursorPos(windowId, xPos, yPos);
	io.setMousePos((float) xPos.get(), (float) yPos.get());
}

MemoyStack is pretty efficient, but the first variant has the same (or even more) efficiency. Yet it is more straightforward and requeir less operations to do. I don't insist on anything, you can keep your PR in your current variant. Just giving a note.

@junglie85
Copy link
Author

That's helpful, thank you.

@SpaiR SpaiR merged commit 0b478fd into SpaiR:master Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants