-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Freeglut OpenGL2 example #801
Conversation
…ouse position does not change. (2) mouse sroll events, tab, backspace bindings.
… clarity. Adding win32 comandline build script.
Hi, Thank you very much for developping the great glut example! It is really useful because I have many resources using glut. I would like to ask a question about keyboard input:
In my environment (Windows 10 (japanese ver.); Visual C++ 2017), the shortcuts did not work. I had a similar problem in some special keys (arrow keys, delete key, backspace key, etc) but I could fix it by adding the following code: bool keyboardEvent(unsigned char nChar, int nX, int nY)
{
ImGuiIO& io = ImGui::GetIO();
switch (nChar)
{
case 127: // delete
io.KeysDown[nChar] = true; break;
case 8: // backspace
io.KeysDown[nChar] = true; break;
default:
io.AddInputCharacter(nChar);
}
return true;
}
void KeyboardSpecial(int key, int x, int y)
{
ImGuiIO& io = ImGui::GetIO();
//io.AddInputCharacter(key);
io.KeysDown[key] = true;
} and corresponding "keyboardup" callbacks. Could you kindly give me advice about what I need to add for implementing the copy and paste shortcut? Thank you very much! |
GLFW has glfwSetClipboardString and glfwGetClipboardString funcs which make it easy to binding copy and paste in imgui. It seems glut lacks these funcs. You may need to implemente it yourself. The ctrl+c,ctrl+v key binding can refer to the implentation bellow: |
Hi bitxue, Thank you very much for the information. Thank you again! |
Hi! Thanks! |
Hi @lramati Although I forget what I have done exactly, you can check following my codes recently uploaded on github:
The first one corresponds to "imgui_impl_glut.cpp" which I slightly modified keymap as in the link. The second one corresponds to "main.cpp". Check keyboard related functions and clipboard related functions in the code for your information. |
Thank you! |
Great to have (at least a potential, but not included yet) freeglut port! |
Mostly because of a lack of time. Maintaining the examples and binding has taken a lot of energy.
Should at least use the enum on the left side, etc. Now, I've recently been refactoring the example (see https://github.com/ocornut/imgui/tree/viewport) meaning this kind of code will be easier to integrate and maintain. Importing the FreeGlut example was part of my plan for this new branch so I will use this PR for it. EDIT There's also many bugs in that code, e.g. this is incorrect in the mouse event handler for at least two reason:
|
@bitxue @MatsumotoJ @lramati @Johndeep As far as I understand GLUT API doesn't allow distinguishing things like TAB vs CTRL+I, so it is severely constrained. Honestly I would recommend against using FreeGLUT in 2018, but AFAIK everything works now. The new examples/ architecture will allow you to combine FreeGLUT with a different renderer if needed. |
Thank you very much for your kindness! |
A simple example on integrating imgui with Freeglut.