SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
ImGui Interface class for forwarding all events to the ImGui Handlers. More...
#include <SLGLImGui.h>
Public Member Functions | |
SLGLImGui (cbOnImGuiBuild buildCB, cbOnImGuiLoadConfig loadConfigCB, cbOnImGuiSaveConfig saveConfigCB, int dpi, SLIOBuffer fontDataProp, SLIOBuffer fontDataFixed) | |
~SLGLImGui () override | |
void | init (const string &configPath) override |
Initializes OpenGL handles to zero and sets the ImGui key map. More... | |
void | onInitNewFrame (SLScene *s, SLSceneView *sv) override |
Inits a new frame for the ImGui system. More... | |
void | onResize (const SLRecti &viewportRect) override |
Callback if window got resized. More... | |
void | onPaint (const SLRecti &viewport) override |
Callback for main rendering for the ImGui GUI system. More... | |
void | onMouseDown (SLMouseButton button, SLint x, SLint y) override |
Callback on mouse button down event. More... | |
void | onMouseUp (SLMouseButton button, SLint x, SLint y) override |
Callback on mouse button up event. More... | |
void | onMouseMove (SLint xPos, SLint yPos) override |
Updates the mouse cursor position. More... | |
void | onMouseWheel (SLfloat yoffset) override |
Callback for the mouse scroll movement. More... | |
void | onKeyPress (SLKey key, SLKey mod) override |
Callback on key press event. More... | |
void | onKeyRelease (SLKey key, SLKey mod) override |
Callback on key release event. More... | |
void | onCharInput (SLuint c) override |
Callback on character input. More... | |
void | onClose () override |
Callback on closing the application. More... | |
void | renderExtraFrame (SLScene *s, SLSceneView *sv, SLint mouseX, SLint mouseY) override |
Renders an extra frame with the current mouse position. More... | |
bool | doNotDispatchKeyboard () override |
inform if user keyboard input was consumed by the ui More... | |
bool | doNotDispatchMouse () override |
inform if user mouse input was consumed by the ui More... | |
void | loadFonts (SLfloat fontPropDots, SLfloat fontFixedDots) |
Loads the proportional and fixed size font depending on the passed DPI. More... | |
void | drawMouseCursor (bool doDraw) override |
Turns on or off the mouse cursor drawing. More... | |
Public Member Functions inherited from SLUiInterface | |
virtual | ~SLUiInterface () |
Static Public Attributes | |
static SLfloat | fontPropDots = 16.0f |
Default font size of proportional font. More... | |
static SLfloat | fontFixedDots = 13.0f |
Default font size of fixed size font. More... | |
Private Member Functions | |
void | deleteOpenGLObjects () |
Deletes all OpenGL objects for drawing the imGui. More... | |
void | createOpenGLObjects () |
Creates all OpenGL objects for drawing the imGui. More... | |
void | printCompileErrors (SLint shaderHandle, const SLchar *src) |
Prints the compile errors in case of a GLSL compile failure. More... | |
Private Attributes | |
cbOnImGuiBuild | _build = nullptr |
cbOnImGuiSaveConfig | _saveConfig = nullptr |
SLfloat | _timeSec |
Time in seconds. More... | |
SLVec2f | _mousePosPX |
Mouse cursor position. More... | |
SLfloat | _mouseWheel |
Mouse wheel position. More... | |
SLbool | _mousePressed [3] |
Mouse button press state. More... | |
SLuint | _fontTexture |
OpenGL texture id for font. More... | |
SLint | _progHandle |
OpenGL handle for shader program. More... | |
SLint | _vertHandle |
OpenGL handle for vertex shader. More... | |
SLint | _fragHandle |
OpenGL handle for fragment shader. More... | |
SLint | _attribLocTex |
OpenGL attribute location for texture. More... | |
SLint | _attribLocProjMtx |
OpenGL attribute location for ??? More... | |
SLint | _attribLocPosition |
OpenGL attribute location for vertex pos. More... | |
SLint | _attribLocUV |
OpenGL attribute location for texture coords. More... | |
SLint | _attribLocColor |
OpenGL attribute location for color. More... | |
SLuint | _vboHandle |
OpenGL handle for vertex buffer object. More... | |
SLuint | _vaoHandle |
OpenGL vertex array object handle. More... | |
SLuint | _elementsHandle |
OpenGL handle for vertex indexes. More... | |
SLfloat | _fontPropDots |
Active font size of proportional font. More... | |
SLfloat | _fontFixedDots |
Active font size of fixed size font. More... | |
SLstring | _configPath |
Path to config files. More... | |
SLIOBuffer | _fontDataProp |
Raw data of proportional font file. More... | |
SLIOBuffer | _fontDataFixed |
Raw data of fixed size font file. More... | |
ImGui Interface class for forwarding all events to the ImGui Handlers.
ImGui is a super easy GUI library for the rendering of a UI with OpenGL. For more information see: https://github.com/ocornut/imgui
This class provides only the interface into ImGui. In the event handlers of SLSceneView the according callback in ImGui is called.
There is no UI drawn with this class. It must be defined in another class that provides the build function. For the Demo apps this is done in the class SLDemoGui and the build function is passed e.g. in glfwMain function of the app-demo project.
The full call stack for rendering one frame is:
Definition at line 62 of file SLGLImGui.h.
SLGLImGui::SLGLImGui | ( | cbOnImGuiBuild | buildCB, |
cbOnImGuiLoadConfig | loadConfigCB, | ||
cbOnImGuiSaveConfig | saveConfigCB, | ||
int | dpi, | ||
SLIOBuffer | fontDataProp, | ||
SLIOBuffer | fontDataFixed | ||
) |
Definition at line 24 of file SLGLImGui.cpp.
|
override |
Definition at line 79 of file SLGLImGui.cpp.
|
private |
Creates all OpenGL objects for drawing the imGui.
Definition at line 188 of file SLGLImGui.cpp.
|
private |
|
inlineoverridevirtual |
inform if user keyboard input was consumed by the ui
Reimplemented from SLUiInterface.
Definition at line 87 of file SLGLImGui.h.
|
inlineoverridevirtual |
inform if user mouse input was consumed by the ui
(e.g. the ui was hit by a mouse click. In this case the user input would not be forwarded to 3D scene graph)
Reimplemented from SLUiInterface.
Definition at line 88 of file SLGLImGui.h.
|
inlineoverridevirtual |
Turns on or off the mouse cursor drawing.
Reimplemented from SLUiInterface.
Definition at line 90 of file SLGLImGui.h.
|
overridevirtual |
Initializes OpenGL handles to zero and sets the ImGui key map.
Reimplemented from SLUiInterface.
Definition at line 89 of file SLGLImGui.cpp.
Loads the proportional and fixed size font depending on the passed DPI.
Definition at line 160 of file SLGLImGui.cpp.
Callback on character input.
Reimplemented from SLUiInterface.
Definition at line 689 of file SLGLImGui.cpp.
|
overridevirtual |
Callback on closing the application.
Reimplemented from SLUiInterface.
Definition at line 697 of file SLGLImGui.cpp.
|
overridevirtual |
Inits a new frame for the ImGui system.
Reimplemented from SLUiInterface.
Definition at line 399 of file SLGLImGui.cpp.
Callback on key press event.
Reimplemented from SLUiInterface.
Definition at line 669 of file SLGLImGui.cpp.
Callback on key release event.
Reimplemented from SLUiInterface.
Definition at line 679 of file SLGLImGui.cpp.
|
overridevirtual |
Callback on mouse button down event.
Reimplemented from SLUiInterface.
Definition at line 633 of file SLGLImGui.cpp.
Updates the mouse cursor position.
Reimplemented from SLUiInterface.
Definition at line 655 of file SLGLImGui.cpp.
|
overridevirtual |
Callback on mouse button up event.
Reimplemented from SLUiInterface.
Definition at line 644 of file SLGLImGui.cpp.
Callback for the mouse scroll movement.
Reimplemented from SLUiInterface.
Definition at line 662 of file SLGLImGui.cpp.
Callback for main rendering for the ImGui GUI system.
Reimplemented from SLUiInterface.
Definition at line 453 of file SLGLImGui.cpp.
Callback if window got resized.
Reimplemented from SLUiInterface.
Definition at line 445 of file SLGLImGui.cpp.
Prints the compile errors in case of a GLSL compile failure.
Definition at line 380 of file SLGLImGui.cpp.
|
overridevirtual |
Renders an extra frame with the current mouse position.
Reimplemented from SLUiInterface.
Definition at line 703 of file SLGLImGui.cpp.
|
private |
OpenGL attribute location for color.
Definition at line 120 of file SLGLImGui.h.
|
private |
OpenGL attribute location for vertex pos.
Definition at line 118 of file SLGLImGui.h.
|
private |
OpenGL attribute location for ???
Definition at line 117 of file SLGLImGui.h.
|
private |
OpenGL attribute location for texture.
Definition at line 116 of file SLGLImGui.h.
|
private |
OpenGL attribute location for texture coords.
Definition at line 119 of file SLGLImGui.h.
|
private |
Definition at line 103 of file SLGLImGui.h.
|
private |
Path to config files.
Definition at line 126 of file SLGLImGui.h.
|
private |
OpenGL handle for vertex indexes.
Definition at line 123 of file SLGLImGui.h.
|
private |
Raw data of fixed size font file.
Definition at line 128 of file SLGLImGui.h.
|
private |
Raw data of proportional font file.
Definition at line 127 of file SLGLImGui.h.
|
private |
Active font size of fixed size font.
Definition at line 125 of file SLGLImGui.h.
|
private |
Active font size of proportional font.
Definition at line 124 of file SLGLImGui.h.
|
private |
OpenGL texture id for font.
Definition at line 112 of file SLGLImGui.h.
|
private |
OpenGL handle for fragment shader.
Definition at line 115 of file SLGLImGui.h.
|
private |
Mouse cursor position.
Definition at line 109 of file SLGLImGui.h.
|
private |
Mouse button press state.
Definition at line 111 of file SLGLImGui.h.
|
private |
Mouse wheel position.
Definition at line 110 of file SLGLImGui.h.
|
private |
OpenGL handle for shader program.
Definition at line 113 of file SLGLImGui.h.
|
private |
Definition at line 106 of file SLGLImGui.h.
|
private |
Time in seconds.
Definition at line 108 of file SLGLImGui.h.
|
private |
OpenGL vertex array object handle.
Definition at line 122 of file SLGLImGui.h.
|
private |
OpenGL handle for vertex buffer object.
Definition at line 121 of file SLGLImGui.h.
|
private |
OpenGL handle for vertex shader.
Definition at line 114 of file SLGLImGui.h.
|
static |
Default font size of fixed size font.
Definition at line 94 of file SLGLImGui.h.
|
static |
Default font size of proportional font.
Definition at line 93 of file SLGLImGui.h.