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_;
556 return picked_depth_;
564 return picked_point_;
574 return picked_background_;
599 return frame_buffer_id_;
612 return last_frame_was_picking_;
659 double zScreen,
double zNear,
double zFar,
660 double eye_offset=0.0
699 return background_texture_;
765 int viewport_height_;
767 mat4 viewing_matrix_;
768 mutable mat4 inverse_viewing_matrix_;
769 mutable bool inverse_viewing_matrix_dirty_;
772 mat4 lighting_matrix_;
775 mat4 clipping_matrix_;
776 vec4 clipping_equation_;
777 bool clipping_viewer_;
778 GLUPclipMode clipping_mode_;
780 Color background_color_;
781 Color background_color_2_;
787 bool stereo_odd_frame_;
788 double stereo_eye_dist_;
795 double picked_depth_;
798 bool picked_background_;
799 bool last_frame_was_picking_;
811 bool frame_buffer_id_init_;
813 static bool geogram_gfx_initialized_;
836 bool owns_glup_context_;
838 bool use_core_profile_;
839 bool use_ES_profile_;
void * GLUPcontext
Opaque identifier of a GLUP context.
Some utility functions for OpenGL graphics.
Base class for reference-counted objects.
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.
FullScreenEffectImpl * get_full_screen_effect() const
Gets the current full screen effect.
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.
const mat4 & viewing_matrix() const
Gets the current viewing matrix.
virtual void draw_background()
Draws the background.
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.
void set_full_screen_effect(FullScreenEffectImpl *fse)
Sets the full screen effect.
~RenderingContext()
RenderingContext destructor.
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....
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.
const Color & background_color() const
Gets the primary background color.
const Color & background_color_2() const
Gets the secondary background color.
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.
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.
GLUPclipMode get_clipping_mode() const
Gets the current clipping mode.
static RenderingContext * current()
Gets the current RenderingContext.
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 vec4 & get_clipping_translation() const
Gets the clipping equation.
virtual void done_current()
This function should be called when client code is done with rendering to the current context.
static const double * convert_matrix(const mat4 &M)
Converts (transposes) a Graphite matrix for OpenGL use.
const vec3 & picked_point() const
Gets the picked point in world coordinates.
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)....
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...
const mat4 & lighting_matrix() const
Gets the lighting matrix.
const mat4 & inverse_viewing_matrix() const
Gets the inverse of the current viewing matrix.
void set_clipping_viewer(bool x)
Sets whether clipping translation and rotation are applied in object bounding box or in viewer coordi...
Overlay & overlay()
Gets the Overlay.
virtual void swap_buffers()
Meant to make the rendered frame visible.
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.
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.
void set_clipping(bool x)
Activates or deactivates clipping.
void set_background_color_2(const Color &c)
Sets the secondary background color.
void check_gl() const
Tests whether there was any OpenGL error.
bool get_clipping() const
Tests whether clipping is active.
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.