Graphite  Version 3
An experimental 3D geometry processing program
OGF::RenderingContext Class Reference

Helper class for OpenGL context management. More...

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

Inheritance diagram for OGF::RenderingContext:
GEO::Counted OGF::SkinImGUIRenderingContext

Public Member Functions

 RenderingContext (GLUPcontext glup_context=nullptr)
 RenderingContext constructor. More...
 
 ~RenderingContext ()
 RenderingContext destructor.
 
index_t get_width () const
 Gets the width. More...
 
index_t get_height () const
 Gets the height. More...
 
bool initialized () const
 Tests whether this RenderingContext is initialized. More...
 
virtual void make_current ()
 Makes this RenderingContext the current one. More...
 
virtual void done_current ()
 This function should be called when client code is done with rendering to the current context. More...
 
virtual void swap_buffers ()
 Meant to make the rendered frame visible. More...
 
void clear ()
 Clears this RenderingContext. More...
 
void load_viewing_matrix (const mat4 &m)
 Sets the current viewing matrix. More...
 
void mul_viewing_matrix (const mat4 &m)
 Multiplies the current viewing matrix by another one. More...
 
const mat4viewing_matrix () const
 Gets the current viewing matrix. More...
 
const mat4inverse_viewing_matrix () const
 Gets the inverse of the current viewing matrix. More...
 
void load_projection_matrix (const mat4 &m)
 Sets the projection matrix and sends it to OpenGL. More...
 
mat4 projection_matrix () const
 Gets the projection matrix. More...
 
virtual void begin_frame ()
 Begins a new frame. More...
 
virtual void end_frame ()
 Terminates a frame.
 
const Colorbackground_color () const
 Gets the primary background color. More...
 
void set_background_color (const Color &c)
 Sets the primary background color. More...
 
const Colorbackground_color_2 () const
 Gets the secondary background color. More...
 
void set_background_color_2 (const Color &c)
 Sets the secondary background color. More...
 
void set_background_image (Image *image)
 Sets the background image. More...
 
void update_background_image_from_data (Memory::pointer ptr, Image::ColorEncoding color_encoding, Image::ComponentEncoding component_encoding, index_t width, index_t height)
 Updates the background image from raw data pointer. More...
 
void set_lighting_matrix (const mat4 &m)
 Sets the lighting matrix. More...
 
const mat4lighting_matrix () const
 Gets the lighting matrix. More...
 
mat4 clipping_matrix () const
 Gets the clipping matrix. More...
 
void set_clipping_matrix (const mat4 &m)
 Sets the lighting matrix. More...
 
void set_clipping (bool x)
 Activates or deactivates clipping. More...
 
bool get_clipping () const
 Tests whether clipping is active. More...
 
void set_clipping_equation (const vec4 &x)
 Sets the clipping equation. More...
 
const vec4get_clipping_translation () const
 Gets the clipping equation. More...
 
void set_clipping_viewer (bool x)
 Sets whether clipping translation and rotation are applied in object bounding box or in viewer coordinates. More...
 
bool get_clipping_viewer () const
 Tests whether clipping translation and rotation are applied in object bounding box or in viewer coordinates. More...
 
GLUPclipMode get_clipping_mode () const
 Gets the current clipping mode. More...
 
void set_clipping_mode (GLUPclipMode mode)
 Sets the current clipping mode. More...
 
bool double_buffer () const
 Tests whether this RenderingContext uses double buffering. More...
 
bool stereo () const
 Tests whether this RenderingContext uses stereo rendering. More...
 
virtual void set_double_buffer (bool b)
 Specifies whether double buffering should be used. More...
 
virtual void snapshot (Image *image, bool make_current=true, index_t x0=0, index_t y0=0, index_t width=0, index_t height=0)
 
std::string gl_vendor () const
 Gets the OpenGL vendor. More...
 
std::string gl_renderer () const
 Gets the OpenGL renderer. More...
 
std::string gl_version () const
 Gets the OpenGL version. More...
 
std::string gl_extensions () const
 Gets the OpenGL extension. More...
 
std::string get_gpu_information () const
 Gets the information on the GPU. More...
 
std::string get_gpu_extensions () const
 Gets the GPU extensions. More...
 
void set_full_screen_effect (FullScreenEffectImpl *fse)
 Sets the full screen effect. More...
 
FullScreenEffectImplget_full_screen_effect () const
 Gets the current full screen effect. More...
 
virtual void resize (index_t w, index_t h)
 Must be called whenever the rendering context is resized. More...
 
vec2 screen_to_ndc (index_t x, index_t y) const
 Transforms screen coordinates to normalized device coordinates (viewport transform). More...
 
void ndc_to_screen (const vec2 &ndc, index_t &x, index_t &y) const
 Transforms normalized device coordinates to screen coordinates (inverse viewport transform). \parma[in] ndc the normalized device coordinates of the point (x and y between -1.0 and 1.0). More...
 
virtual void begin_picking (const vec2 &ndc)
 Enters picking mode. More...
 
virtual void end_picking ()
 Exits picking mode. More...
 
index_t picked_id () const
 Gets the picked id that was encoded in the pixel color under the mouse pointer. More...
 
double picked_depth () const
 Gets the depth of the picked point in screen coordinates. More...
 
const vec3picked_point () const
 Gets the picked point in world coordinates. More...
 
bool picked_background () const
 Tests whether the background was picked. More...
 
vec3 unproject (const vec2 &p_ndc, double depth) const
 Back-transforms a point given by its normalized device coordinates and depth. More...
 
void check_gl () const
 Tests whether there was any OpenGL error. More...
 
GLuint frame_buffer_id () const
 Gets the default frame buffer id. More...
 
bool contains_picking_image () const
 Tests whether the image is a picking image. More...
 
Overlayoverlay ()
 Gets the Overlay. More...
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 

Static Public Member Functions

static RenderingContextcurrent ()
 Gets the current RenderingContext. More...
 
static bool is_currently_rendering ()
 Tests whether a rendering operation is occuring. More...
 
static bool is_currently_picking ()
 Tests whether a picking operation is occuring. More...
 
- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 

Protected Member Functions

virtual void draw_background ()
 Draws the background. More...
 
void setup_viewport ()
 Setups the viewport transform. More...
 
void setup_projection_ortho (double zNear, double zFar)
 Setups the OpenGL projection matrix in orthographic mode. More...
 
void setup_projection_perspective (double zScreen, double zNear, double zFar, double eye_offset=0.0)
 Setups the OpenGL projection matrix in orthographic mode. More...
 
void setup_modelview (double zScreen)
 Setups the OpenGL model view transform from the viewing parameters. More...
 
void setup_lighting ()
 Setups OpenGL lighting parameters.
 
void update_clipping ()
 Create a clipping plane perpendicular to the Z axis, transformed by the current clipping matrix and the modelview matrix.
 
Texturebackground_texture () const
 Gets the background texture. More...
 
void set_initialized (bool x=true)
 Indicates whether this RenderingContext is initialized. More...
 
void set_width (index_t w)
 Sets the width. More...
 
void set_height (index_t h)
 Sets the height. More...
 
void get_view_parameters ()
 Queries the Graphite environment for global rendering parameters, e.g. stereo & perspective, and updates member variables if this RenderingContext accordingly.
 
void get_picked_point ()
 In picking mode, this function gets all the information about the picked point, by reading the depth buffer and the color buffer with color-coded id.
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 

Static Protected Member Functions

static const double * convert_matrix (const mat4 &M)
 Converts (transposes) a Graphite matrix for OpenGL use. More...
 

Protected Attributes

bool initialized_
 
index_t width_
 
index_t height_
 
bool double_buffer_
 
int viewport_x_
 
int viewport_y_
 
int viewport_width_
 
int viewport_height_
 
mat4 viewing_matrix_
 
mat4 inverse_viewing_matrix_
 
bool inverse_viewing_matrix_dirty_
 
bool lighting_
 
mat4 lighting_matrix_
 
bool clipping_
 
mat4 clipping_matrix_
 
vec4 clipping_equation_
 
bool clipping_viewer_
 
GLUPclipMode clipping_mode_
 
Color background_color_
 
Color background_color_2_
 
Texture_var background_texture_
 
FullScreenEffectImpl_var full_screen_effect_
 
bool perspective_
 
bool stereo_
 
bool stereo_odd_frame_
 
double stereo_eye_dist_
 
vec3 head_position_
 
double head_tilt_
 
bool picking_mode_
 
vec2 picked_ndc_
 
double picked_depth_
 
index_t picked_id_
 
vec3 picked_point_
 
bool picked_background_
 
bool last_frame_was_picking_
 
GLuint frame_buffer_id_
 The identifier of the default frame buffer associated with this RenderingContext. More...
 
bool frame_buffer_id_init_
 
GLUPcontext glup_context_
 The GLUP context. More...
 
bool owns_glup_context_
 
bool use_core_profile_
 
bool use_ES_profile_
 
bool transparent_
 
Overlay overlay_
 

Static Protected Attributes

static RenderingContextcurrent_
 
static bool geogram_gfx_initialized_
 
static index_t nb_render_locks_
 The number of RenderingContext instances that are currently rendering something, i.e. between begin_frame() and end_frame().
 
static index_t nb_picking_locks_
 The number of RenderingContext instances that are currently picking something, or that contain a picking image in their color buffer.
 

Friends

class RenderArea
 

Detailed Description

Helper class for OpenGL context management.

RenderingContext manages the viewing matrices and light sources. It also provides functionalities for picking.

Definition at line 67 of file rendering_context.h.

Constructor & Destructor Documentation

◆ RenderingContext()

OGF::RenderingContext::RenderingContext ( GLUPcontext  glup_context = nullptr)

RenderingContext constructor.

Parameters
[in]glup_contextthe GLUP context to be used for rendering, or 0. If 0, then RenderingContext will create and manage its own GLUP context.

Member Function Documentation

◆ background_color()

const Color& OGF::RenderingContext::background_color ( ) const

Gets the primary background color.

The primary background color is used to clear the color buffer.

Returns
a const reference to the primary background color

◆ background_color_2()

const Color& OGF::RenderingContext::background_color_2 ( ) const

Gets the secondary background color.

If the secondary background color is different from the primary background color, then a vertical colorramp is generated in the background.

Returns
a const reference to the secondary background color

◆ background_texture()

Texture* OGF::RenderingContext::background_texture ( ) const
inlineprotected

Gets the background texture.

Returns
a pointer to the background texture if it is defined, nil otherwise

Definition at line 698 of file rendering_context.h.

◆ begin_frame()

virtual void OGF::RenderingContext::begin_frame ( )
virtual

Begins a new frame.

This clears the color and depth buffer, and setups the viewing matrix. This function calls make_current() before issuing any OpenGL call.

Reimplemented in OGF::SkinImGUIRenderingContext.

◆ begin_picking()

virtual void OGF::RenderingContext::begin_picking ( const vec2 ndc)
virtual

Enters picking mode.

This function should be called before begin_frame()

Parameters
[in]ndcndc the normalized device coordinates of the picked point (x and y between -1.0 and 1.0).

◆ check_gl()

void OGF::RenderingContext::check_gl ( ) const

Tests whether there was any OpenGL error.

Displays error messages in the console as obtained by glGetError()

◆ clear()

void OGF::RenderingContext::clear ( )

Clears this RenderingContext.

This clears both the color buffer and the frame buffer.

◆ clipping_matrix()

mat4 OGF::RenderingContext::clipping_matrix ( ) const

Gets the clipping matrix.

The clipping matrix transforms the clipping plane.

Returns
a const reference to the clipping matrix

◆ contains_picking_image()

bool OGF::RenderingContext::contains_picking_image ( ) const
inline

Tests whether the image is a picking image.

Graphite picking uses images made of picking IDs (instead of colors). This function tests whether the last rendering operation generated such images. In this case, the image should not be displayed to the user.

Return values
trueif the contained image has picking ids.
falseotherwise.

Definition at line 611 of file rendering_context.h.

◆ convert_matrix()

static const double* OGF::RenderingContext::convert_matrix ( const mat4 M)
staticprotected

Converts (transposes) a Graphite matrix for OpenGL use.

Parameters
[in]Ma const reference to the matrix to be converted
Returns
a pointer to a static buffer with the converted (i.e. transposed) matrix

◆ current()

static RenderingContext* OGF::RenderingContext::current ( )
inlinestatic

Gets the current RenderingContext.

Returns
a pointer to the current RenderingContext

Definition at line 87 of file rendering_context.h.

◆ done_current()

virtual void OGF::RenderingContext::done_current ( )
virtual

This function should be called when client code is done with rendering to the current context.

Some implementations of make_current() acquire a lock, that is released by done_current()

◆ double_buffer()

bool OGF::RenderingContext::double_buffer ( ) const
inline

Tests whether this RenderingContext uses double buffering.

Return values
trueif double buffering is used \retvavl false otherwise

Definition at line 404 of file rendering_context.h.

◆ draw_background()

virtual void OGF::RenderingContext::draw_background ( )
protectedvirtual

Draws the background.

If a background texture was specified, uses the texture, else generates a colorramp between the primary background color and the secondary background color.

See also
set_background_color(), set_background_color_2(), set_background_image(), update_background_image_from_data()

◆ end_picking()

virtual void OGF::RenderingContext::end_picking ( )
virtual

Exits picking mode.

This function should be called after end_frame().

◆ frame_buffer_id()

GLuint OGF::RenderingContext::frame_buffer_id ( ) const
inline

Gets the default frame buffer id.

Some versions of Qt use a FrameBufferObject instead of a full OpenGL context in rendering widgets.

Returns
the id of the default frame buffer object used with this context, or 0 if no frame buffer object is used.

Definition at line 598 of file rendering_context.h.

◆ get_clipping()

bool OGF::RenderingContext::get_clipping ( ) const

Tests whether clipping is active.

Return values
trueif clipping is active
falseotherwise

◆ get_clipping_mode()

GLUPclipMode OGF::RenderingContext::get_clipping_mode ( ) const
inline

Gets the current clipping mode.

Returns
one of GLUP_CLIP_STANDARD, GLUP_CLIP_WHOLE_CELLS, GLUP_CLIP_STRADDLING_CELLS, GLUP_CLIP_SLICE_CELLS

Definition at line 385 of file rendering_context.h.

◆ get_clipping_translation()

const vec4& OGF::RenderingContext::get_clipping_translation ( ) const
inline

Gets the clipping equation.

Returns
a const reference to the clipping equation as a vec4

Definition at line 355 of file rendering_context.h.

◆ get_clipping_viewer()

bool OGF::RenderingContext::get_clipping_viewer ( ) const
inline

Tests whether clipping translation and rotation are applied in object bounding box or in viewer coordinates.

Return values
trueif clipping plane is fixed in viewer space
falseif clipping is defined in object space

Definition at line 375 of file rendering_context.h.

◆ get_full_screen_effect()

FullScreenEffectImpl* OGF::RenderingContext::get_full_screen_effect ( ) const
inline

Gets the current full screen effect.

Returns
a pointer to the implementation of the current full screen effect, or nil if no full screen effect is used.

Definition at line 492 of file rendering_context.h.

◆ get_gpu_extensions()

std::string OGF::RenderingContext::get_gpu_extensions ( ) const

Gets the GPU extensions.

Returns
same as gl_extensions()

◆ get_gpu_information()

std::string OGF::RenderingContext::get_gpu_information ( ) const

Gets the information on the GPU.

Returns
a string with the OpenGL renderer, version and vendor

◆ get_height()

index_t OGF::RenderingContext::get_height ( ) const
inline

Gets the height.

Returns
the height of this RenderingContext in pixels.

Definition at line 128 of file rendering_context.h.

◆ get_width()

index_t OGF::RenderingContext::get_width ( ) const
inline

Gets the width.

Returns
the width of this RenderingContext in pixels.

Definition at line 120 of file rendering_context.h.

◆ gl_extensions()

std::string OGF::RenderingContext::gl_extensions ( ) const

Gets the OpenGL extension.

Returns
a string with the list of the supported OpenGL extensions

◆ gl_renderer()

std::string OGF::RenderingContext::gl_renderer ( ) const

Gets the OpenGL renderer.

Returns
the OpenGL renderer as a string.

◆ gl_vendor()

std::string OGF::RenderingContext::gl_vendor ( ) const

Gets the OpenGL vendor.

Returns
the OpenGL vendor as a string.

◆ gl_version()

std::string OGF::RenderingContext::gl_version ( ) const

Gets the OpenGL version.

Returns
the OpenGL version as a string.

◆ initialized()

bool OGF::RenderingContext::initialized ( ) const
inline

Tests whether this RenderingContext is initialized.

A RenderingContext is initialized once the first drawing event was processed.

Return values
trueif this RenderingContext is initialized
falseotherwise

Definition at line 139 of file rendering_context.h.

◆ inverse_viewing_matrix()

const mat4& OGF::RenderingContext::inverse_viewing_matrix ( ) const

Gets the inverse of the current viewing matrix.

Returns
a const reference to the inverse of the current viewing matrix.

◆ is_currently_picking()

static bool OGF::RenderingContext::is_currently_picking ( )
static

Tests whether a picking operation is occuring.

This concerns all the rendering contexts (this a static method).

Return values
trueif the content of one of the framebuffers is a picking image
falseotherwise

◆ is_currently_rendering()

static bool OGF::RenderingContext::is_currently_rendering ( )
static

Tests whether a rendering operation is occuring.

This concerns all the rendering contexts (thus a static method).

Return values
trueif a rendering operation is currently occuring
falseotherwise

◆ lighting_matrix()

const mat4& OGF::RenderingContext::lighting_matrix ( ) const

Gets the lighting matrix.

Returns
a const reference to the lighting matrix.

◆ load_projection_matrix()

void OGF::RenderingContext::load_projection_matrix ( const mat4 m)

Sets the projection matrix and sends it to OpenGL.

Parameters
[in]ma const reference to the projection matrix.

◆ load_viewing_matrix()

void OGF::RenderingContext::load_viewing_matrix ( const mat4 m)

Sets the current viewing matrix.

This just changes the stored viewing matrix, nothing is sent to OpenGL. The viewing matrix is sent to OpenGL when begin_frame() is called.

Parameters
[in]ma const reference to the viewing matrix

◆ make_current()

virtual void OGF::RenderingContext::make_current ( )
virtual

Makes this RenderingContext the current one.

OpenGL uses global variables. Since several 3D graphic windows may be opened at the same time, the corresponding renderer has to be 'made current' before issuing 3D drawing commands to it. Note that begin_frame() automatically calls make_current() and clear().

◆ mul_viewing_matrix()

void OGF::RenderingContext::mul_viewing_matrix ( const mat4 m)

Multiplies the current viewing matrix by another one.

This just changes the stored viewing matrix, nothing is sent to OpenGL. The viewing matrix is sent to OpenGL when begin_frame() is called. This replaces the viewing matrix with m times the viewing matrix (mutliplies m on the left).

Parameters
[in]ma const reference to the viewing matrix

◆ ndc_to_screen()

void OGF::RenderingContext::ndc_to_screen ( const vec2 ndc,
index_t x,
index_t y 
) const

Transforms normalized device coordinates to screen coordinates (inverse viewport transform). \parma[in] ndc the normalized device coordinates of the point (x and y between -1.0 and 1.0).

Parameters
[out]x,ythe integer coordinates of the point, in screen space

◆ overlay()

Overlay& OGF::RenderingContext::overlay ( )
inline

Gets the Overlay.

The Overlay has a couple of basic drawing primitives for displaying graphics over the rendering window.

Definition at line 620 of file rendering_context.h.

◆ picked_background()

bool OGF::RenderingContext::picked_background ( ) const
inline

Tests whether the background was picked.

This tests whether the picked depth is equal to 1.0

Return values
trueif the background was picked (i.e. no object was picked)
falseotherwise (i.e. an object was picked)

Definition at line 573 of file rendering_context.h.

◆ picked_depth()

double OGF::RenderingContext::picked_depth ( ) const
inline

Gets the depth of the picked point in screen coordinates.

Returns
the depth of the picked point

Definition at line 555 of file rendering_context.h.

◆ picked_id()

index_t OGF::RenderingContext::picked_id ( ) const
inline

Gets the picked id that was encoded in the pixel color under the mouse pointer.

Some specialized shaders replace the color with (color-coded) identifiers.

Returns
the picked id

Definition at line 546 of file rendering_context.h.

◆ picked_point()

const vec3& OGF::RenderingContext::picked_point ( ) const
inline

Gets the picked point in world coordinates.

Returns
a const reference to the picked point

Definition at line 563 of file rendering_context.h.

◆ projection_matrix()

mat4 OGF::RenderingContext::projection_matrix ( ) const

Gets the projection matrix.

Returns
The projection matrix

◆ resize()

virtual void OGF::RenderingContext::resize ( index_t  w,
index_t  h 
)
virtual

Must be called whenever the rendering context is resized.

Updates the viewport transform.

Parameters
[in]wthe new width
[in]hthe new height

Reimplemented in OGF::SkinImGUIRenderingContext.

◆ screen_to_ndc()

vec2 OGF::RenderingContext::screen_to_ndc ( index_t  x,
index_t  y 
) const

Transforms screen coordinates to normalized device coordinates (viewport transform).

Parameters
[in]x,ythe integer coordinates of a point, in screen space.
Returns
the coordinates of the point in normalized device coordinates (both between -1.0 and 1.0).

◆ set_background_color()

void OGF::RenderingContext::set_background_color ( const Color c)

Sets the primary background color.

Parameters
[in]ca const reference to the primary background color

◆ set_background_color_2()

void OGF::RenderingContext::set_background_color_2 ( const Color c)

Sets the secondary background color.

If the secondary background color is different from the primary background color, then a vertical colorramp is generated in the background.

Parameters
[in]ca const reference to the secondary background color

◆ set_background_image()

void OGF::RenderingContext::set_background_image ( Image image)

Sets the background image.

If a background image is defined, then it is used to fill the background. This generates an OpenGL texture from the image.

Parameters
[in]imagea pointer to the image

◆ set_clipping()

void OGF::RenderingContext::set_clipping ( bool  x)

Activates or deactivates clipping.

Parameters
[in]xtrue if clipping should be used, false otherwise
See also
set_clipping_matrix(), clipping_matrix()

◆ set_clipping_equation()

void OGF::RenderingContext::set_clipping_equation ( const vec4 x)
inline

Sets the clipping equation.

Parameters
[in]xa const reference to the clipping equation, stored in a vec4.

Definition at line 346 of file rendering_context.h.

◆ set_clipping_matrix()

void OGF::RenderingContext::set_clipping_matrix ( const mat4 m)

Sets the lighting matrix.

The clipping matrix transforms the clipping plane. Nothing is sent to OpenGL, this is taken into account by begin_frame().

Parameters
[in]ma const reference to the clipping matrix.

◆ set_clipping_mode()

void OGF::RenderingContext::set_clipping_mode ( GLUPclipMode  mode)
inline

Sets the current clipping mode.

Parameters
[in]modeone of GLUP_CLIP_STANDARD, GLUP_CLIP_WHOLE_CELLS, GLUP_CLIP_STRADDLING_CELLS, GLUP_CLIP_SLICE_CELLS

Definition at line 395 of file rendering_context.h.

◆ set_clipping_viewer()

void OGF::RenderingContext::set_clipping_viewer ( bool  x)
inline

Sets whether clipping translation and rotation are applied in object bounding box or in viewer coordinates.

Parameters
[in]xtrue if clipping plane is fixed in viewer space, false if clipping is defined in object space

Definition at line 365 of file rendering_context.h.

◆ set_double_buffer()

virtual void OGF::RenderingContext::set_double_buffer ( bool  b)
virtual

Specifies whether double buffering should be used.

Parameters
[in]btrue if double buffering should be used, false otherwise

◆ set_full_screen_effect()

void OGF::RenderingContext::set_full_screen_effect ( FullScreenEffectImpl fse)

Sets the full screen effect.

Full screen effects are shaders that operate on the content of the color buffer and depth buffer.

Parameters
[in]fsea pointer to the FullScreenEffectImpl that implements the full screen effect or nil if no full screen effect should be used.

◆ set_height()

void OGF::RenderingContext::set_height ( index_t  h)
inlineprotected

Sets the height.

This function is just used to indicate to this RenderingContext what is its current height (it does not resize the RenderingContext).

Parameters
[in]hthe height

Definition at line 733 of file rendering_context.h.

◆ set_initialized()

void OGF::RenderingContext::set_initialized ( bool  x = true)
inlineprotected

Indicates whether this RenderingContext is initialized.

This function is called by the RenderArea widget, after the first repaint event, once the RenderingContext is ready for rendering.

Parameters
[in]xtrue if this rendering context is initialized, false otherwise

Definition at line 711 of file rendering_context.h.

◆ set_lighting_matrix()

void OGF::RenderingContext::set_lighting_matrix ( const mat4 m)

Sets the lighting matrix.

The lighting matrix transforms the light sources. Nothing is sent to OpenGL, this is taken into account by begin_frame().

Parameters
[in]ma const reference to the lighting matrix.

◆ set_width()

void OGF::RenderingContext::set_width ( index_t  w)
inlineprotected

Sets the width.

This function is just used to indicate to this RenderingContext what is its current width (it does not resize the RenderingContext).

Parameters
[in]wthe width

Definition at line 722 of file rendering_context.h.

◆ setup_modelview()

void OGF::RenderingContext::setup_modelview ( double  zScreen)
protected

Setups the OpenGL model view transform from the viewing parameters.

Parameters
[in]zScreenscreen projection plane

◆ setup_projection_ortho()

void OGF::RenderingContext::setup_projection_ortho ( double  zNear,
double  zFar 
)
protected

Setups the OpenGL projection matrix in orthographic mode.

Parameters
[in]zNeardepth coordinate of the near plane
[in]zFardepth coordinate of the far plane

◆ setup_projection_perspective()

void OGF::RenderingContext::setup_projection_perspective ( double  zScreen,
double  zNear,
double  zFar,
double  eye_offset = 0.0 
)
protected

Setups the OpenGL projection matrix in orthographic mode.

Parameters
[in]zScreenscreen projection plane, used to compute the frustrum angle
[in]zNeardepth coordinate of the near plane
[in]zFardepth coordinate of the far plane
[in]eye_offsetdistance between the eyes, used in stereo rendering

◆ setup_viewport()

void OGF::RenderingContext::setup_viewport ( )
protected

Setups the viewport transform.

Sends the stored viewport parameters to OpenGL.

◆ snapshot()

virtual void OGF::RenderingContext::snapshot ( Image image,
bool  make_current = true,
index_t  x0 = 0,
index_t  y0 = 0,
index_t  width = 0,
index_t  height = 0 
)
virtual

Copies the color buffer onto the specified image.

Parameters
[out]imageThe image, it should have the same size as this RenderingContext and should be in RGB mode.
[in]make_currentif true, makes this rendering context the current rendering context before reading the pixels.
[in]x0,y0,width,heightoptional image bounds. If let unspecified, the entire picking buffer is copied.

◆ stereo()

bool OGF::RenderingContext::stereo ( ) const
inline

Tests whether this RenderingContext uses stereo rendering.

Return values
trueif stereo rendering is used
falseotherwise

Definition at line 413 of file rendering_context.h.

◆ swap_buffers()

virtual void OGF::RenderingContext::swap_buffers ( )
virtual

Meant to make the rendered frame visible.

Base class implementation does nothing. In most cases, this operation is already done by the toolkit (e.g. Qt), therefore this function does not need to be overloaded in most cases.

◆ unproject()

vec3 OGF::RenderingContext::unproject ( const vec2 p_ndc,
double  depth 
) const

Back-transforms a point given by its normalized device coordinates and depth.

Returns
the world-coordinates of the point.

◆ update_background_image_from_data()

void OGF::RenderingContext::update_background_image_from_data ( Memory::pointer  ptr,
Image::ColorEncoding  color_encoding,
Image::ComponentEncoding  component_encoding,
index_t  width,
index_t  height 
)

Updates the background image from raw data pointer.

If a background texture is already present, then it updates it with the data, else it creates a new background texture.

Parameters
[in]ptra pointer to image data
[in]color_encodingthe color encoding of the data
[in]component_encodingthe data type used for the color components
[in]widthimage width
[in]heightimage height

◆ viewing_matrix()

const mat4& OGF::RenderingContext::viewing_matrix ( ) const

Gets the current viewing matrix.

Returns
a const reference to the current viewing matrix.

Member Data Documentation

◆ frame_buffer_id_

GLuint OGF::RenderingContext::frame_buffer_id_
protected

The identifier of the default frame buffer associated with this RenderingContext.

QOpenGLWidget in Qt5.4 does not use a real OpenGL context, it uses a FrameBuffer object. Therefore, when we want to unbind a FrameBuffer object, we need to restore the binding to the one used by Qt instead.

Definition at line 810 of file rendering_context.h.

◆ glup_context_

GLUPcontext OGF::RenderingContext::glup_context_
protected

The GLUP context.

The GLUP API provides immediate-mode OpenGL-like primitives and other ones, such as tetrahedra, hexahedra etc...

Definition at line 835 of file rendering_context.h.


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