ImFusion SDK 4.3
GlView Class Referenceabstract

#include <ImFusion/GL/GlView.h>

Base class for implementing OpenGL views. More...

+ Inheritance diagram for GlView:

Detailed Description

Base class for implementing OpenGL views.

A GlView represents an OpenGL Viewport, i.e. a rectangular drawing area on the screen. Each GlView contains a matrix that converts view coordinates to world coordinates (camera located in the origin, looking down the negative z-axis). In order to map the 3D view coordinates to the 2D screen, each view internally uses a projection matrix converting view coordinates to clip coordinates (visible objects will be in a cube of -1 to 1 side length). You can access view and projection matrices through the GL::ViewState object that is updated during every render call.

The view is aware of the width and height of the viewport but it will not set glViewport. Thus, the actual glViewport must be set before calling render().

Derived classes shall draw all GlObjects of the view with the current view- and projection matrix in the current viewport on render(). Furthermore, they must set the GL::ViewState correctly.

Usually a GlView is wrapped by an InteractiveView to allow for handling user input events and for putting it into a DisplayWidget.

Examples
MyCustomGlObject.cpp, and MyCustomGlObject.h.

Classes

class  ViewStateGuard
 Temporarily changes the GL::ViewState of a GlView and resetting to the original value on destruction. More...
 

Public Types

enum  Type { SLICE2D = 0 , SLICE3D = 1 , SPACE3D = 2 , OTHER = 3 }
 Type of the view. More...
 

Public Member Functions

virtual bool render ()=0
 Render scene. glViewport must be set before. Called with valid OpenGL context.
 
virtual Type type () const =0
 Return the type of this view.
 
virtual void setMatrix (const mat4 &mat)
 Sets the view matrix (view coordinates to world coordinates).
 
virtual const mat4 & matrix () const
 Returns the current view matrix (view coordinates to world coordinates).
 
virtual void resize (int width, int height)
 Set a new viewport size for this view.
 
virtual const GL::OrderIndependentTransparencyorderIndependentTransparency () const
 Returns the optional OIT manager instance of the view if the feature is supported and enabled.
 
int height () const
 Current viewport height of the view.
 
int width () const
 Current viewport width of the view.
 
void addObject (GlObject *object)
 Add a reference to a GlObject to be drawn by this view.
 
void removeObject (GlObject *object)
 Remove a reference to a GlObject drawn by this view.
 
const std::vector< GlObject * > & objects () const
 Return the set of GlObjects that are drawn by this view.
 
const GL::ViewStatestate () const
 Return the view state that was set during the last render() call.
 

Protected Member Functions

GL::OrderIndependentTransparencysharedOitInstance () const
 Offers support for GlViews sharing GL::OrderIndependentTransparency instances to reduce GPU memory consumption.
 

Protected Attributes

std::vector< GlObject * > m_objects
 Other objects to consider during rendering.
 
mat4 m_matrix = mat4::Identity()
 Matrix converting view coordinates to world coords (inverse of a traditional OpenGL view matrix)
 
GL::ViewState m_state
 OpenGL state describing viewport, projection and model-view matrix of last render call.
 
int m_width = 0
 
int m_height = 0
 

Member Enumeration Documentation

◆ Type

enum Type

Type of the view.

Enumerator
SLICE2D 

2D slice view

SLICE3D 

3D MPR slice view

SPACE3D 

3D volume view

OTHER 

Other/unknown kind of view.

Member Function Documentation

◆ render()

virtual bool render ( )
pure virtual

Render scene. glViewport must be set before. Called with valid OpenGL context.

Implemented in GlGeometryView, GlCurvedView, GlPlotView, GlSliceView, and GlVolumeView.

◆ type()

virtual Type type ( ) const
pure virtual

Return the type of this view.

Implemented in GlGeometryView, GlCurvedView, GlPlotView, GlSliceView, and GlVolumeView.

◆ setMatrix()

virtual void setMatrix ( const mat4 & mat)
inlinevirtual

Sets the view matrix (view coordinates to world coordinates).

Reimplemented in GlSliceView, and GlVolumeView.

◆ matrix()

virtual const mat4 & matrix ( ) const
inlinevirtual

Returns the current view matrix (view coordinates to world coordinates).

Reimplemented in GlVolumeView.

◆ resize()

virtual void resize ( int width,
int height )
virtual

Set a new viewport size for this view.

Updates the width and height properties but does not change the glViewport. Depending on the view type, this may also update the view matrix.

Reimplemented in GlSliceView.

◆ orderIndependentTransparency()

virtual const GL::OrderIndependentTransparency * orderIndependentTransparency ( ) const
inlinevirtual

Returns the optional OIT manager instance of the view if the feature is supported and enabled.

A GlView may choose to support correct order-independent blending of semi-transparent surfaces of scene objects. In this case it should override this function to return its corresponding GL::OrderIndependentTransparency instance. Draw calls of GlObjects can query OIT support through this function and use the pointer to setup their shaders so that it writes semi-transparent fragments to the OIT buffer which the view will ultimately resolve at the end of the render pass.

Reimplemented in GlSliceView, and GlVolumeView.

◆ sharedOitInstance()

GL::OrderIndependentTransparency * sharedOitInstance ( ) const
protected

Offers support for GlViews sharing GL::OrderIndependentTransparency instances to reduce GPU memory consumption.

Internally, this function will use the GL::InstanceManager interface to manage the internal caching. Usage of this class must be limited to a single GlView::render() call in order to ensure that multiple views sharing the same instance do not compromise each other. This function will return nullptr if OIT is not supported.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close