SLProject 4.0.000
|
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, SLstring fontDir) | |
~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 (SLint scrW, SLint scrH) 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, SLstring fontDir) |
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 () |
virtual void | init (const string &configPath) |
initialization (called by SLSceneView init) More... | |
virtual void | onResize (SLint scrW, SLint scrH) |
inform the ui about scene view size change More... | |
virtual void | onClose () |
shutdown ui More... | |
virtual void | onInitNewFrame (SLScene *s, SLSceneView *sv) |
prepare the ui for a new rendering, e.g. update visual ui representation (called by SLSceneView onPaint) More... | |
virtual void | onPaint (const SLRecti &viewport) |
ui render call (called by SLSceneView draw2DGL) More... | |
virtual void | renderExtraFrame (SLScene *s, SLSceneView *sv, SLint mouseX, SLint mouseY) |
virtual void | onMouseDown (SLMouseButton button, SLint x, SLint y) |
forward user input to ui More... | |
virtual void | onMouseUp (SLMouseButton button, SLint x, SLint y) |
forward user input to ui More... | |
virtual void | onMouseMove (SLint xPos, SLint yPos) |
forward user input to ui More... | |
virtual void | onMouseWheel (SLfloat yoffset) |
forward user input to ui More... | |
virtual void | onKeyPress (SLKey key, SLKey mod) |
forward user input to ui More... | |
virtual void | onKeyRelease (SLKey key, SLKey mod) |
forward user input to ui More... | |
virtual void | onCharInput (SLuint c) |
forward user input to ui More... | |
virtual bool | doNotDispatchKeyboard () |
inform if user keyboard input was consumed by the ui More... | |
virtual bool | doNotDispatchMouse () |
inform if user mouse input was consumed by the ui More... | |
virtual void | drawMouseCursor (bool doDraw) |
Turns on or off the mouse cursor drawing. More... | |
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 | _fontDir |
SLstring | _configPath |
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-SLProject project.
The full call stack for rendering one frame is:
SLGLImGui::SLGLImGui | ( | cbOnImGuiBuild | buildCB, |
cbOnImGuiLoadConfig | loadConfigCB, | ||
cbOnImGuiSaveConfig | saveConfigCB, | ||
int | dpi, | ||
SLstring | fontDir | ||
) |
|
override |
|
private |
Creates all OpenGL objects for drawing the imGui.
|
private |
Deletes all OpenGL objects for drawing the imGui.
|
inlineoverridevirtual |
inform if user keyboard input was consumed by the ui
Reimplemented from SLUiInterface.
|
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.
|
inlineoverridevirtual |
Turns on or off the mouse cursor drawing.
Reimplemented from SLUiInterface.
|
overridevirtual |
Initializes OpenGL handles to zero and sets the ImGui key map.
Reimplemented from SLUiInterface.
Loads the proportional and fixed size font depending on the passed DPI.
|
overridevirtual |
Callback on character input.
Reimplemented from SLUiInterface.
|
overridevirtual |
Callback on closing the application.
Reimplemented from SLUiInterface.
|
overridevirtual |
Inits a new frame for the ImGui system.
Reimplemented from SLUiInterface.
Callback on key press event.
Reimplemented from SLUiInterface.
Callback on key release event.
Reimplemented from SLUiInterface.
|
overridevirtual |
Callback on mouse button down event.
Reimplemented from SLUiInterface.
Updates the mouse cursor position.
Reimplemented from SLUiInterface.
|
overridevirtual |
Callback on mouse button up event.
Reimplemented from SLUiInterface.
|
overridevirtual |
Callback for the mouse scroll movement.
Reimplemented from SLUiInterface.
|
overridevirtual |
Callback for main rendering for the ImGui GUI system.
Reimplemented from SLUiInterface.
Callback if window got resized.
Reimplemented from SLUiInterface.
Prints the compile errors in case of a GLSL compile failure.
|
overridevirtual |
Renders an extra frame with the current mouse position.
Reimplemented from SLUiInterface.
|
private |
OpenGL attribute location for color.
|
private |
OpenGL attribute location for vertex pos.
|
private |
OpenGL attribute location for ???
|
private |
OpenGL attribute location for texture.
|
private |
OpenGL attribute location for texture coords.
|
private |
|
private |
|
private |
OpenGL handle for vertex indexes.
|
private |
|
private |
Active font size of fixed size font.
|
private |
Active font size of proportional font.
|
private |
OpenGL texture id for font.
|
private |
OpenGL handle for fragment shader.
|
private |
Mouse cursor position.
|
private |
Mouse button press state.
|
private |
Mouse wheel position.
|
private |
OpenGL handle for shader program.
|
private |
|
private |
Time in seconds.
|
private |
OpenGL vertex array object handle.
|
private |
OpenGL handle for vertex buffer object.
|
private |
OpenGL handle for vertex shader.
|
static |
Default font size of fixed size font.
|
static |
Default font size of proportional font.