38#ifndef H_OGF_RENDERER_CONTEXT_RENDERING_CONTEXT_H
39#define H_OGF_RENDERER_CONTEXT_RENDERING_CONTEXT_H
43#include <OGF/renderer/context/overlay.h>
347 clipping_equation_ = x;
356 return clipping_equation_;
366 clipping_viewer_ = x;
376 return clipping_viewer_;
386 return clipping_mode_;
396 clipping_mode_ = mode;
405 return double_buffer_;
433 Image* image,
bool make_current=
true,
493 return full_screen_effect_;
584 return picked_depth_;
592 return picked_point_;
602 return picked_background_;
627 return frame_buffer_id_;
640 return last_frame_was_picking_;
705 double zScreen,
double zNear,
double zFar,
706 double eye_offset=0.0
745 return background_texture_;
811 int viewport_height_;
815 mat4 viewing_matrix_;
816 mutable mat4 inverse_viewing_matrix_;
817 mutable bool inverse_viewing_matrix_dirty_;
820 mat4 lighting_matrix_;
823 mat4 clipping_matrix_;
824 vec4 clipping_equation_;
825 bool clipping_viewer_;
826 GLUPclipMode clipping_mode_;
828 Color background_color_;
829 Color background_color_2_;
835 bool stereo_odd_frame_;
836 double stereo_eye_dist_;
842 double picked_depth_;
845 bool picked_background_;
846 bool last_frame_was_picking_;
858 bool frame_buffer_id_init_;
860 static bool geogram_gfx_initialized_;
883 bool owns_glup_context_;
885 bool use_core_profile_;
886 bool use_ES_profile_;
void * GLUPcontext
Opaque identifier of a GLUP context.
Some utility functions for OpenGL graphics.
Base class for reference-counted objects.
An OpenGL frame buffer object.
Implementation of full screen effects.
ComponentEncoding
Indicates the datatype used to encode each component of the colors.
ColorEncoding
Indicates how colors are encoded within the image.
A display list that memorizes simple graphic primitives to be displayed over the 3D rendering window.
Implementation of RenderArea using ImGui.
Helper class for OpenGL context management.
std::string get_gpu_information() const
Gets the information on the GPU.
vec3 unproject(const vec2 &p_ndc, double depth) const
Back-transforms a point given by its normalized device coordinates and depth.
void set_initialized(bool x=true)
Indicates whether this RenderingContext is initialized.
void setup_viewport()
Setups the viewport transform.
void set_height(index_t h)
Sets the height.
virtual void make_current()
Makes this RenderingContext the current one.
virtual void end_picking()
Exits picking mode.
virtual void resize(index_t w, index_t h)
Must be called whenever the rendering context is resized.
virtual void draw_background()
Draws the background.
virtual FrameBufferObject * get_FBO(RenderingContextFBO FBO_id)
Gets one of the FBOs.
static RenderingContext * current()
Gets the current RenderingContext.
index_t picked_id() const
Gets the picked id that was encoded in the pixel color under the mouse pointer.
virtual void begin_picking(const vec2 &ndc)
Enters picking mode.
bool get_clipping_viewer() const
Tests whether clipping translation and rotation are applied in object bounding box or in viewer coord...
virtual void end_frame()
Terminates a frame.
void setup_modelview(double zScreen)
Setups the OpenGL model view transform from the viewing parameters.
Overlay & overlay()
Gets the Overlay.
void set_full_screen_effect(FullScreenEffectImpl *fse)
Sets the full screen effect.
const Color & background_color() const
Gets the primary background color.
RenderingContextFBO
Constants for get_FBO()
void set_lighting_matrix(const mat4 &m)
Sets the lighting matrix.
virtual void begin_frame()
Begins a new frame.
void set_clipping_equation(const vec4 &x)
Sets the clipping equation.
static index_t nb_render_locks_
The number of RenderingContext instances that are currently rendering something, i....
int get_center_y() const
Gets the y coordinate of the center.
void setup_projection_ortho(double zNear, double zFar)
Setups the OpenGL projection matrix in orthographic mode.
void set_background_color(const Color &c)
Sets the primary background color.
void setup_projection_perspective(double zScreen, double zNear, double zFar, double eye_offset=0.0)
Setups the OpenGL projection matrix in orthographic mode.
static bool is_currently_rendering()
Tests whether a rendering operation is occuring.
std::string gl_renderer() const
Gets the OpenGL renderer.
bool picked_background() const
Tests whether the background was picked.
GLuint frame_buffer_id_
The identifier of the default frame buffer associated with this RenderingContext.
vec2 screen_to_ndc(index_t x, index_t y) const
Transforms screen coordinates to normalized device coordinates (viewport transform).
std::string gl_version() const
Gets the OpenGL version.
const vec3 & picked_point() const
Gets the picked point in world coordinates.
~RenderingContext() override
RenderingContext destructor.
virtual void set_double_buffer(bool b)
Specifies whether double buffering should be used.
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)
void set_background_image(Image *image)
Sets the background image.
mat4 clipping_matrix() const
Gets the clipping matrix.
void load_viewing_matrix(const mat4 &m)
Sets the current viewing matrix.
const vec4 & get_clipping_translation() const
Gets the clipping equation.
GLUPclipMode get_clipping_mode() const
Gets the current clipping mode.
index_t get_width() const
Gets the width.
bool double_buffer() const
Tests whether this RenderingContext uses double buffering.
bool initialized() const
Tests whether this RenderingContext is initialized.
GLuint frame_buffer_id() const
Gets the default frame buffer id.
const mat4 & lighting_matrix() const
Gets the lighting matrix.
virtual void done_current()
This function should be called when client code is done with rendering to the current context.
const Color & background_color_2() const
Gets the secondary background color.
RenderingContext(GLUPcontext glup_context=nullptr)
RenderingContext constructor.
void ndc_to_screen(const vec2 &ndc, index_t &x, index_t &y) const
Transforms normalized device coordinates to screen coordinates (inverse viewport transform)....
const mat4 & inverse_viewing_matrix() const
Gets the inverse of the current viewing matrix.
void get_picked_point()
In picking mode, this function gets all the information about the picked point, by reading the depth ...
void get_view_parameters()
Queries the Graphite environment for global rendering parameters, e.g. stereo & perspective,...
void setup_lighting()
Setups OpenGL lighting parameters.
std::string get_gpu_extensions() const
Gets the GPU extensions.
void set_width(index_t w)
Sets the width.
void set_clipping_mode(GLUPclipMode mode)
Sets the current clipping mode.
bool stereo() const
Tests whether this RenderingContext uses stereo rendering.
void update_clipping()
Create a clipping plane perpendicular to the Z axis, transformed by the current clipping matrix and t...
void set_clipping_viewer(bool x)
Sets whether clipping translation and rotation are applied in object bounding box or in viewer coordi...
virtual void swap_buffers()
Meant to make the rendered frame visible.
int get_center_x() const
Gets the x coordinate of the center.
std::string gl_extensions() const
Gets the OpenGL extension.
static bool is_currently_picking()
Tests whether a picking operation is occuring.
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.
void set_clipping_matrix(const mat4 &m)
Sets the lighting matrix.
void set_center(int x, int y)
Sets the center.
bool contains_picking_image() const
Tests whether the image is a picking image.
mat4 projection_matrix() const
Gets the projection matrix.
double picked_depth() const
Gets the depth of the picked point in screen coordinates.
std::string gl_vendor() const
Gets the OpenGL vendor.
void load_projection_matrix(const mat4 &m)
Sets the projection matrix and sends it to OpenGL.
void mul_viewing_matrix(const mat4 &m)
Multiplies the current viewing matrix by another one.
Texture * background_texture() const
Gets the background texture.
void clear()
Clears this RenderingContext.
static const double * convert_matrix(const mat4 &M)
Converts (transposes) a Graphite matrix for OpenGL use.
void set_clipping(bool x)
Activates or deactivates clipping.
void set_background_color_2(const Color &c)
Sets the secondary background color.
const mat4 & viewing_matrix() const
Gets the current viewing matrix.
void check_gl() const
Tests whether there was any OpenGL error.
bool get_clipping() const
Tests whether clipping is active.
FullScreenEffectImpl * get_full_screen_effect() const
Gets the current full screen effect.
GLUPcontext glup_context_
The GLUP context.
index_t get_height() const
Gets the height.
static index_t nb_picking_locks_
The number of RenderingContext instances that are currently picking something, or that contain a pick...
Low-level base class for full screen effects.
byte * pointer
Pointer to unsigned byte(s)
geo_index_t index_t
The type for storing and manipulating indices.
Global Graphite namespace.
Definitions common to all include files in the renderer library.
Helper class for manipulating OpenGL textures.