Graphite Version 3
An experimental 3D geometry processing program
Loading...
Searching...
No Matches
OGF::Overlay Class Reference

A display list that memorizes simple graphic primitives to be displayed over the 3D rendering window. More...

#include <OGF/renderer/context/overlay.h>

Public Member Functions

 Overlay (RenderingContext *rendering_context)
 
void clear ()
 Removes all primitives to be displayed.
 
void playback ()
 Plays back this overlay to the current ImGui context.
 
void segment (vec2 p1, vec2 p2, Color color, double thickness=1.0)
 Adds a segment to the display list.
 
void rect (vec2 p1, vec2 p2, Color color, double thickness=1.0)
 Adds a rectangle to the display list.
 
void fillrect (vec2 p1, vec2 p2, Color color)
 Adds a filled rectangle to the display list.
 
void circle (vec2 p1, double R, Color color, double thickness=1.0)
 Adds a circle to the display list.
 
void fillcircle (vec2 p1, double R, Color color)
 Adds a filled circle to the display list.
 
void filltriangle (vec2 p1, vec2 p2, vec2 p3, Color color)
 Adds a filled triangle to the display list.
 
void fillquad (vec2 p1, vec2 p2, vec2 p3, vec2 p4, Color color)
 Adds a filled triangle to the display list.
 
vec2f imgui_to_GL (const vec2f &XY_imgui) const
 Converts Dear ImGui coordinates to OpenGL coordinate.
 
vec2f GL_to_imgui (const vec2f &XY_GL) const
 Converts OpenGL coordinates to Dear ImGui coordinate.
 
vec2f GL_to_imgui (const vec2 &XY_GL) const
 Converts OpenGL coordinates to Dear ImGui coordinate.
 

Detailed Description

A display list that memorizes simple graphic primitives to be displayed over the 3D rendering window.

Used by some tools. We cannot directly use ImDrawList API, because mouse event handler of the 3D window are called completely independelty of ImGui, so we need a "protocol" to communicate between the two worlds. All functions use OpenGL device coordinates, that is, in pixels, with origin in lower left corner.

Definition at line 57 of file overlay.h.

Constructor & Destructor Documentation

◆ Overlay()

OGF::Overlay::Overlay ( RenderingContext rendering_context)
inline

Definition at line 60 of file overlay.h.

Member Function Documentation

◆ circle()

void OGF::Overlay::circle ( vec2  p1,
double  R,
Color  color,
double  thickness = 1.0 
)

Adds a circle to the display list.

Parameters
[in]p1the 2D coordinates of the center of the circle. One may use Tool::project_point() to obtain them from real-world coordinates. Origin is lower-left corner.
[in]Rthe radius of the circle
[in]colorthe color, with alpha
[in]thicknessline thickness (ImGui can draw antialiased thick lines).

◆ fillcircle()

void OGF::Overlay::fillcircle ( vec2  p1,
double  R,
Color  color 
)

Adds a filled circle to the display list.

Parameters
[in]p1the 2D coordinates of the center of the circle. One may use Tool::project_point() to obtain them from real-world coordinates. Origin is lower-left corner.
[in]Rthe radius of the circle
[in]colorthe color, with alpha

◆ fillquad()

void OGF::Overlay::fillquad ( vec2  p1,
vec2  p2,
vec2  p3,
vec2  p4,
Color  color 
)

Adds a filled triangle to the display list.

Parameters
[in]p1,p2,p3,p4the 2D coordinates of two corners of the rectangle. One may use Tool::project_point() to obtain them from real-world coordinates. Origin is lower-left corner.
[in]colorthe color, with alpha

◆ fillrect()

void OGF::Overlay::fillrect ( vec2  p1,
vec2  p2,
Color  color 
)

Adds a filled rectangle to the display list.

Parameters
[in]p1,p2the 2D coordinates of two corners of the rectangle. One may use Tool::project_point() to obtain them from real-world coordinates. Origin is lower-left corner.
[in]colorthe color, with alpha

◆ filltriangle()

void OGF::Overlay::filltriangle ( vec2  p1,
vec2  p2,
vec2  p3,
Color  color 
)

Adds a filled triangle to the display list.

Parameters
[in]p1,p2,p3the 2D coordinates of two corners of the rectangle. One may use Tool::project_point() to obtain them from real-world coordinates. Origin is lower-left corner.
[in]colorthe color, with alpha

◆ GL_to_imgui() [1/2]

vec2f OGF::Overlay::GL_to_imgui ( const vec2 XY_GL) const
inline

Converts OpenGL coordinates to Dear ImGui coordinate.

Parameters
[in]XY_GLa point in OpenGL Window coordinates, with origin at bottom-left corner, in double-precision.
Returns
the corresponding point in Dear ImGui coordinates, with origin at top-left and possibly retina-screen scaling.

Definition at line 175 of file overlay.h.

◆ GL_to_imgui() [2/2]

vec2f OGF::Overlay::GL_to_imgui ( const vec2f XY_GL) const

Converts OpenGL coordinates to Dear ImGui coordinate.

Parameters
[in]XY_GLa point in OpenGL Window coordinates, with origin at bottom-left corner.
Returns
the corresponding point in Dear ImGui coordinates, with origin at top-left and possibly retina-screen scaling.

◆ imgui_to_GL()

vec2f OGF::Overlay::imgui_to_GL ( const vec2f XY_imgui) const

Converts Dear ImGui coordinates to OpenGL coordinate.

Parameters
[in]XY_imguia point in imgui coordinates, with origin at top-left corner and possibly retina-screen scaling
Returns
the corresponding point in OpenGL Window coordinates, with origin at bottom-left.

◆ playback()

void OGF::Overlay::playback ( )

Plays back this overlay to the current ImGui context.

This function needs to be called right before ImGui::Render(). It is called by ApplicationImpl::draw_gui() in skin_imgui.

◆ rect()

void OGF::Overlay::rect ( vec2  p1,
vec2  p2,
Color  color,
double  thickness = 1.0 
)

Adds a rectangle to the display list.

Parameters
[in]p1,p2the 2D coordinates of two corners of the rectangle. One may use Tool::project_point() to obtain them from real-world coordinates. Origin is lower-left corner.
[in]colorthe color, with alpha
[in]thicknessline thickness (ImGui can draw antialiased thick lines).

◆ segment()

void OGF::Overlay::segment ( vec2  p1,
vec2  p2,
Color  color,
double  thickness = 1.0 
)

Adds a segment to the display list.

Parameters
[in]p1,p2the 2D coordinates of the extremities of the segment. One may use Tool::project_point() to obtain them from real-world coordinates. Origin is lower-left corner.
[in]colorthe color, with alpha
[in]thicknessline thickness (ImGui can draw antialiased thick lines).

The documentation for this class was generated from the following file: