scg3  0.6
scg::Viewer Class Reference

Central viewer managing window, controllers, animations, and main loop. More...

#include "Viewer.h"

Collaboration diagram for scg::Viewer:
[legend]

Public Member Functions

 Viewer ()
 
virtual ~Viewer ()
 
Viewerinit (RendererSP renderer)
 
ViewerinitSimpleRenderer (CameraSP &camera, GroupSP &scene)
 
ViewerinitSimpleRenderer (CameraSP &camera, GroupSP &scene, LightSP &light)
 
ViewersetOpenGLConfig (const OGLConfig &oglConfig)
 
VieweraddController (ControllerSP controller)
 
VieweraddControllers (const std::vector< ControllerSP > &controllers)
 
VieweraddControllers (std::vector< ControllerSP > &&controllers)
 
VieweraddAnimation (AnimationSP animation)
 
VieweraddAnimations (const std::vector< AnimationSP > &animations)
 
VieweraddAnimations (std::vector< AnimationSP > &&animations)
 
ViewerstartAnimations ()
 
void getWindowSize (int &width, int &height) const
 
ViewersetWindowSize (int width, int height)
 
bool isWindowResized ()
 
ViewersetWindowTitle (const char *title)
 
ViewercreateWindow (const char *title, int width, int height)
 
ViewercreateFullscreenWindow (const char *title)
 
void startMainLoop ()
 

Static Public Member Functions

static ViewerSP create ()
 

Protected Member Functions

void createWindow_ (const char *title, int width, int height, bool fullscreenMode)
 
void processControllers_ ()
 
void processAnimations_ ()
 

Static Protected Member Functions

static void errorCB_ (int error, const char *description)
 
static void framebufferSizeCB_ (GLFWwindow *window, int width, int height)
 

Protected Attributes

GLFWwindow * window_
 
ViewStateUP viewState_
 
OGLConfig oglConfig_
 
int oglVersion_
 
RendererSP renderer_
 
std::vector< AnimationSPanimations_
 
std::vector< ControllerSPcontrollers_
 
FrameBufferSize frameBufferSize_
 
GLbitfield frameBufferClearMask_
 

Static Protected Attributes

static bool isInstantiated_
 
static bool isWindowResized_
 

Private Member Functions

 SCG_DISALLOW_COPY_AND_ASSIGN (Viewer)
 

Detailed Description

Central viewer managing window, controllers, animations, and main loop.

A few static functions are required for GLFW callbacks.

Examples
scg3_table_scene_example.cpp.

Definition at line 108 of file Viewer.h.

Constructor & Destructor Documentation

◆ Viewer()

scg::Viewer::Viewer ( )

Constructor.

◆ ~Viewer()

virtual scg::Viewer::~Viewer ( )
virtual

Destructor.

Member Function Documentation

◆ addAnimation()

Viewer* scg::Viewer::addAnimation ( AnimationSP  animation)

Add animation to be updated in main loop.

Returns
this pointer for method chaining

◆ addAnimations() [1/2]

Viewer* scg::Viewer::addAnimations ( const std::vector< AnimationSP > &  animations)

Add animations to be updated in main loop.

Returns
this pointer for method chaining

◆ addAnimations() [2/2]

Viewer* scg::Viewer::addAnimations ( std::vector< AnimationSP > &&  animations)

Add animations to be updated in main loop.

Returns
this pointer for method chaining

◆ addController()

Viewer* scg::Viewer::addController ( ControllerSP  controller)

Add controller to be checked in main loop, e.g., a camera controller.

Returns
this pointer for method chaining

◆ addControllers() [1/2]

Viewer* scg::Viewer::addControllers ( const std::vector< ControllerSP > &  controllers)

Add controllers to be checked in main loop, e.g., a camera controller.

Returns
this pointer for method chaining
Examples
scg3_table_scene_example.cpp.

◆ addControllers() [2/2]

Viewer* scg::Viewer::addControllers ( std::vector< ControllerSP > &&  controllers)

Add controllers to be checked in main loop, e.g., a camera controller.

Returns
this pointer for method chaining

◆ create()

static ViewerSP scg::Viewer::create ( )
static

Create shared pointer.

Examples
scg3_minimal_example.cpp, and scg3_table_scene_example.cpp.

◆ createFullscreenWindow()

Viewer* scg::Viewer::createFullscreenWindow ( const char *  title)

Create OpenGL context, open fullscreen window with given title, hide mouse cursor, and initialize GLEW.

Returns
this pointer for method chaining

◆ createWindow()

Viewer* scg::Viewer::createWindow ( const char *  title,
int  width,
int  height 
)

Create OpenGL context, open window with given title and dimensions, and initialize GLEW.

Returns
this pointer for method chaining

◆ createWindow_()

void scg::Viewer::createWindow_ ( const char *  title,
int  width,
int  height,
bool  fullscreenMode 
)
protected

Create OpenGL context, open window with given title, dimensions, and fullscreen mode, and initialize GLEW. Called by createWindow() and createFullscrennWindow().

◆ errorCB_()

static void scg::Viewer::errorCB_ ( int  error,
const char *  description 
)
staticprotected

GLFW error callback function.

◆ framebufferSizeCB_()

static void scg::Viewer::framebufferSizeCB_ ( GLFWwindow *  window,
int  width,
int  height 
)
staticprotected

GLFW callback function for framebuffer resize event. Note: Use glfwSetFramebufferSizeCallback() instead of glfwSetWindowSizeCallback() to correctly handle Mac Retina display

◆ getWindowSize()

void scg::Viewer::getWindowSize ( int &  width,
int &  height 
) const

Get current window dimensions.

◆ init()

Viewer* scg::Viewer::init ( RendererSP  renderer)

Initialize GLFW with given renderer.

Returns
this pointer for method chaining

◆ initSimpleRenderer() [1/2]

Viewer* scg::Viewer::initSimpleRenderer ( CameraSP camera,
GroupSP scene 
)

Initialize viewer with default renderer, Gouraud shader, perspective camera, and empty scene (with child node camera).

Parameters
cameraunallocated pointer
sceneunallocated pointer
Returns
this pointer for method chaining

◆ initSimpleRenderer() [2/2]

Viewer* scg::Viewer::initSimpleRenderer ( CameraSP camera,
GroupSP scene,
LightSP light 
)

Initialize viewer with default renderer, Gouraud shader, perspective camera, directed light, and empty scene (with child nodes camera and light).

Parameters
cameraunallocated pointer
sceneunallocated pointer
lightunallocated pointer
Returns
this pointer for method chaining

◆ isWindowResized()

bool scg::Viewer::isWindowResized ( )

Check if window has been resized since last call of this method. The internal resize flag is cleared afterwards.

◆ processAnimations_()

void scg::Viewer::processAnimations_ ( )
protected

Update animations, called by startMainLoop().

◆ processControllers_()

void scg::Viewer::processControllers_ ( )
protected

Check controllers for input, called by startMainLoop().

◆ SCG_DISALLOW_COPY_AND_ASSIGN()

scg::Viewer::SCG_DISALLOW_COPY_AND_ASSIGN ( Viewer  )
private

Disallow copy constructor and assignment operator.

◆ setOpenGLConfig()

Viewer* scg::Viewer::setOpenGLConfig ( const OGLConfig oglConfig)

Set OpenGL configuration. In order to take effect, this method has to be called before init().

Returns
this pointer for method chaining

◆ setWindowSize()

Viewer* scg::Viewer::setWindowSize ( int  width,
int  height 
)

Set window dimensions.

Returns
this pointer for method chaining

◆ setWindowTitle()

Viewer* scg::Viewer::setWindowTitle ( const char *  title)

Set window title.

Returns
this pointer for method chaining

◆ startAnimations()

Viewer* scg::Viewer::startAnimations ( )

Start all animations.

Returns
this pointer for method chaining

◆ startMainLoop()

void scg::Viewer::startMainLoop ( )

Start main loop, periodically check input devices and render scene.

Member Data Documentation

◆ animations_

std::vector<AnimationSP> scg::Viewer::animations_
protected

Definition at line 293 of file Viewer.h.

◆ controllers_

std::vector<ControllerSP> scg::Viewer::controllers_
protected

Definition at line 294 of file Viewer.h.

◆ frameBufferClearMask_

GLbitfield scg::Viewer::frameBufferClearMask_
protected

Definition at line 296 of file Viewer.h.

◆ frameBufferSize_

FrameBufferSize scg::Viewer::frameBufferSize_
protected

Definition at line 295 of file Viewer.h.

◆ isInstantiated_

bool scg::Viewer::isInstantiated_
staticprotected

Definition at line 286 of file Viewer.h.

◆ isWindowResized_

bool scg::Viewer::isWindowResized_
staticprotected

Definition at line 287 of file Viewer.h.

◆ oglConfig_

OGLConfig scg::Viewer::oglConfig_
protected

Definition at line 290 of file Viewer.h.

◆ oglVersion_

int scg::Viewer::oglVersion_
protected

Definition at line 291 of file Viewer.h.

◆ renderer_

RendererSP scg::Viewer::renderer_
protected

Definition at line 292 of file Viewer.h.

◆ viewState_

ViewStateUP scg::Viewer::viewState_
protected

Definition at line 289 of file Viewer.h.

◆ window_

GLFWwindow* scg::Viewer::window_
protected

Definition at line 288 of file Viewer.h.


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