Carna  Version 3.0.1
Public Member Functions | List of all members
Carna::base::Viewport Class Reference

Defines a rendering viewport. The viewport is a property of the current OpenGL context. More...

#include <Viewport.h>

Public Member Functions

 Viewport (unsigned int rootWidth, unsigned int rootHeight, bool fitSquare)
 Creates root viewport.
 
 Viewport (const Framebuffer &)
 
 Viewport (const Viewport &parent, unsigned int left, unsigned int top, unsigned int width, unsigned int height)
 Derives viewport from parent.
 
 ~Viewport ()
 Restores the parent viewport if this viewport is still active.
 
void makeActive () const
 Makes this viewport the active one of the current OpenGL context.
 
bool isActive () const
 Tells whether this viewport is currently active.
 
void done () const
 Restores the previous viewport. More...
 
void setWidth (unsigned int)
 Sets viewport width. More...
 
void setHeight (unsigned int)
 Sets viewport height. More...
 
void setMarginLeft (unsigned int)
 Sets viewport left margin. More...
 
void setMarginTop (unsigned int)
 Sets viewport top margin. More...
 
unsigned int width () const
 Tells viewport width.
 
unsigned int height () const
 Tells viewport height.
 
unsigned int parentWidth () const
 Tells parent viewport's width.
 
unsigned int parentHeight () const
 Tells parent viewport's height.
 
unsigned int marginLeft () const
 Tells viewport's left margin.
 
unsigned int marginTop () const
 Tells viewport's top margin.
 
unsigned int marginRight () const
 Tells viewport's right margin.
 
unsigned int marginBottom () const
 Tells viewport's bottom margin.
 

Detailed Description

Defines a rendering viewport. The viewport is a property of the current OpenGL context.

The viewport specifies how normalized device coordinates are mapped to frame coordinates, as described here. This makes the viewport always somehow *"naturally"* related to a frame. It has proven to be convenient to organize viewports hierarchically. In this terms, each Viewport instance is associated with another parent viewport that it is derived from. Viewports, that do not have such a parent viewport, are named root viewports.

Author
Leonid Kostrykin
Date
22.2.15 - 20.3.15

Definition at line 48 of file Viewport.h.

Constructor & Destructor Documentation

Carna::base::Viewport::Viewport ( const Framebuffer )
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Function Documentation

void Carna::base::Viewport::done ( ) const

Restores the previous viewport.

Precondition
isActive() == true
void Carna::base::Viewport::setHeight ( unsigned  int)

Sets viewport height.

Precondition
isActive() == false
void Carna::base::Viewport::setMarginLeft ( unsigned  int)

Sets viewport left margin.

Precondition
isActive() == false
void Carna::base::Viewport::setMarginTop ( unsigned  int)

Sets viewport top margin.

Precondition
isActive() == false
void Carna::base::Viewport::setWidth ( unsigned  int)

Sets viewport width.

Precondition
isActive() == false

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