CMU462 Library  1.0
15-462/15-662: Computer Graphics (Fall 2015)
Public Member Functions | Protected Attributes | List of all members
CMU462::Renderer Class Referenceabstract

Abstract renderer definition. More...

#include <renderer.h>

Public Member Functions

virtual ~Renderer (void)
 Virtual Destructor. More...
 
virtual void init (void)=0
 Initialize the renderer. More...
 
virtual void render (void)=0
 Draw content. More...
 
virtual void resize (size_t w, size_t h)=0
 Respond to buffer resize. More...
 
virtual std::string name (void)=0
 Return a name for the renderer. More...
 
virtual std::string info (void)=0
 Return a brief description of the renderer. More...
 
virtual void cursor_event (float x, float y)
 Respond to cursor events. More...
 
virtual void scroll_event (float offset_x, float offset_y)
 Respond to zoom event. More...
 
virtual void mouse_event (int key, int event, unsigned char mods)
 Respond to mouse click event. More...
 
virtual void keyboard_event (int key, int event, unsigned char mods)
 Respond to keyboard event. More...
 
void use_hdpi_reneder_target ()
 Internal - The viewer will tell the renderer if the screen is in HDPI mode.
 

Protected Attributes

bool use_hdpi
 if the render target is using HIDPI
 

Detailed Description

Abstract renderer definition.

The abstract class defines a general framework for user-space renderers. User space renderers can have different routines for drawing, and the viewer will call the render function to display the output of user space renderers. The viewer will also forward events such as buffer resizes to the user space renderer for it to respond. It will also pass events that it does not know how to handle to the renderer so that the renderer can define its own control keybindings, etc.

Constructor & Destructor Documentation

virtual CMU462::Renderer::~Renderer ( void  )
inlinevirtual

Virtual Destructor.

Each renderer implementation should define its own destructor that takes care of freeing the resources that it uses.

Member Function Documentation

virtual void CMU462::Renderer::init ( void  )
pure virtual

Initialize the renderer.

A renderer may have some initialization work to do before it is ready to be used. The viewer will call the init function before using the renderer in drawing.

virtual void CMU462::Renderer::render ( void  )
pure virtual

Draw content.

Renderers are free to define their own routines for drawing to the context. The viewer calls this function on every frame update.

virtual void CMU462::Renderer::resize ( size_t  w,
size_t  h 
)
pure virtual

Respond to buffer resize.

The viewer will inform the renderer of a context resize by calling this function. The renderer has complete freedom to handle resizing, and a good renderer implementation should handle resizes properly.

Parameters
wThe new width of the context
hThe new height of the context
virtual std::string CMU462::Renderer::name ( void  )
pure virtual

Return a name for the renderer.

If the viewer has a renderer set at initialization, it will include the renderer name in the window title.

virtual std::string CMU462::Renderer::info ( void  )
pure virtual

Return a brief description of the renderer.

Each renderer can define this differently. The viewer will use the returned value in the renderer section of its on-screen display.

virtual void CMU462::Renderer::cursor_event ( float  x,
float  y 
)
inlinevirtual

Respond to cursor events.

The viewer itself does not really care about the cursor but it will take the GLFW cursor events and forward the ones that matter to the renderer. The arguments are defined in screen space coordinates ( (0,0) at top left corner of the window and (w,h) at the bottom right corner.

Parameters
xthe x coordinate of the cursor
ythe y coordinate of the cursor
virtual void CMU462::Renderer::scroll_event ( float  offset_x,
float  offset_y 
)
inlinevirtual

Respond to zoom event.

Like cursor events, the viewer itself does not care about the mouse wheel either, but it will take the GLFW wheel events and forward them directly to the renderer.

Parameters
offset_xScroll offset in x direction
offset_yScroll offset in y direction
virtual void CMU462::Renderer::mouse_event ( int  key,
int  event,
unsigned char  mods 
)
inlinevirtual

Respond to mouse click event.

The viewer will always forward mouse click events to the renderer.

Parameters
keyThe key that spawned the event. The mapping between the key values and the mouse buttons are given by the macros defined at the top of this file.
eventThe type of event. Possible values are 0, 1 and 2, which corresponds to the events defined in macros.
modsif any modifier keys are held down at the time of the event modifiers are defined in macros.
virtual void CMU462::Renderer::keyboard_event ( int  key,
int  event,
unsigned char  mods 
)
inlinevirtual

Respond to keyboard event.

The viewer will always forward mouse key events to the renderer.

Parameters
keyThe key that spawned the event. ASCII numbers are used for letter characters. Non-letter keys are selectively supported and are defined in macros.
eventThe type of event. Possible values are 0, 1 and 2, which corresponds to the events defined in macros.
modsif any modifier keys are held down at the time of the event modifiers are defined in macros.

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