gramods
Classes | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
gramods::gmGraphics::Window Class Referenceabstract

The base of graphics Window implementations. More...

#include <Window.hh>

Inheritance diagram for gramods::gmGraphics::Window:
Inheritance graph
[legend]
Collaboration diagram for gramods::gmGraphics::Window:
Collaboration graph
[legend]

Classes

struct  event
 
struct  key_event
 

Public Member Functions

void renderFullPipeline (ViewSettings settings) override
 Dispatches specified renders, both method argument and class members, to the views in this window. More...
 
void traverse (Visitor *visitor) override
 Propagates the specified visitor. More...
 
void addView (std::shared_ptr< View > view)
 Adds a view to the window. More...
 
virtual void makeGLContextCurrent ()=0
 Asks the Window to make its GL context current. More...
 
virtual void close ()=0
 Asks the Window to close itself. More...
 
virtual void setFullscreen (bool on)
 Activates or deactivates fullscreen mode. More...
 
virtual void setDisplay (size_t N)
 Set on which display the window should be shown. More...
 
virtual void setSize (gmCore::size2 s)
 Sets the size of the drawable canvas of this window, in pixels. More...
 
virtual void setPosition (gmCore::int2 p)
 Sets the position of the window. More...
 
virtual gmCore::size2 getSize ()
 Returns the size of the drawable canvas of this window, in pixels. More...
 
virtual void setTitle (std::string t)
 Sets the title of the windows. More...
 
virtual void setBackgroundColor (gmCore::float4 c)
 Set the background color of the window. More...
 
virtual void processEvents ()=0
 Triggers the windows to process its incoming events. More...
 
virtual bool handleEvent (event *)
 Internal events handler, called from processEvents(). More...
 
void addEventHandler (std::function< bool(const event *)> fun, void *tag)
 Registers an event handler associated with the specified tag. More...
 
void removeEventHandler (void *tag)
 Removes the event handler associnated with the specified tag. More...
 
virtual bool isOpen ()
 Returns true as long as the window is open. More...
 
virtual void swap ()=0
 Posts a swap buffers command to the underlying windowing system, to show the newly rendered material. More...
 
virtual void sync ()
 Calls glFinish on the GL context. More...
 
- Public Member Functions inherited from gramods::gmGraphics::ViewBase
void addNode (std::shared_ptr< Node > node)
 Adds a scenegraph to the view. More...
 
void setViewpoint (std::shared_ptr< Viewpoint > viewpoint)
 Sets the viewpoint to use in the views rendered by this ViewBase. More...
 
void addViewpoint (std::shared_ptr< Viewpoint > viewpoint)
 Adds a viewpoint to use in the views rendered by this ViewBase. More...
 
- Public Member Functions inherited from gramods::gmCore::Object
 Object ()
 Initializes internal data. More...
 
virtual ~Object ()
 Cleaning up internal data. More...
 
virtual void initialize ()
 Called to initialize the Object. More...
 
virtual void accept (Visitor *visitor)
 Calls the visitors apply method with this as argument. More...
 
virtual std::string getDefaultKey ()
 Returns the default key for the Object when automatically instantiated in a Configuration, i.e. More...
 
bool isInitialized ()
 Returns true if the Object is initialized. More...
 

Static Public Attributes

static gramods::gmCore::OFactory::OFactoryInformation _gm_ofi
 
- Static Public Attributes inherited from gramods::gmGraphics::ViewBase
static gramods::gmCore::OFactory::OFactoryInformation _gm_ofi
 

Protected Attributes

std::vector< std::shared_ptr< View > > views
 
bool fullscreen = false
 
size_t display = 0
 
std::string title = "untitled gramods window"
 
gmCore::size2 size = {640, 480}
 
gmCore::int2 position
 
gmCore::float4 background_color = {0.f, 0.f, 0.f, 0.f}
 
std::unordered_map< void *, std::function< bool(const event *)> > event_handlers
 
- Protected Attributes inherited from gramods::gmGraphics::ViewBase
Node::list nodes
 
std::vector< std::shared_ptr< Viewpoint > > viewpoints
 

Additional Inherited Members

- Protected Member Functions inherited from gramods::gmGraphics::ViewBase
void populateViewSettings (ViewSettings &settings)
 Adds the dispatcher's local renderers and viewpoint, if set. More...
 

Detailed Description

The base of graphics Window implementations.

Member Function Documentation

◆ addEventHandler()

void gramods::gmGraphics::Window::addEventHandler ( std::function< bool(const event *)>  fun,
void *  tag 
)

Registers an event handler associated with the specified tag.

The tag can be a pointer to any object and is only used for calls to removeEventHandler.

◆ addView()

gramods::gmCore::OFactory::PointerSetterInsert gm_ofi_Window_pointer_view &Window::_gm_ofi(& gramods::gmGraphics::Window::addView ( std::shared_ptr< View view)
inline

Adds a view to the window.

A window without views will render nothing - it is the tiles that provide the graphics. If multiple views are added, then these will be rendered over each other.

XML-attribute: view

◆ close()

virtual void gramods::gmGraphics::Window::close ( )
pure virtual

Asks the Window to close itself.

This should be overloaded by sub classes to support run-time changes.

Implemented in gramods::gmGraphics::SdlWindow.

◆ getSize()

virtual gmCore::size2 gramods::gmGraphics::Window::getSize ( )
inlinevirtual

Returns the size of the drawable canvas of this window, in pixels.

This should be overloaded by sub classes to also support run-time changes.

Reimplemented in gramods::gmGraphics::SdlWindow.

◆ handleEvent()

bool gramods::gmGraphics::Window::handleEvent ( event evt)
virtual

Internal events handler, called from processEvents().

This will in turn call any registered event handler.

◆ isOpen()

virtual bool gramods::gmGraphics::Window::isOpen ( )
inlinevirtual

Returns true as long as the window is open.

This does not necessarily mean that the window is visible and it may even be minimized.

Reimplemented in gramods::gmGraphics::SdlWindow.

◆ makeGLContextCurrent()

virtual void gramods::gmGraphics::Window::makeGLContextCurrent ( )
pure virtual

Asks the Window to make its GL context current.

This is called automatically by the renderFullPipeline method.

Implemented in gramods::gmGraphics::SdlWindow.

◆ processEvents()

virtual void gramods::gmGraphics::Window::processEvents ( )
pure virtual

Triggers the windows to process its incoming events.

This must be called at even intervals for the window to behave properly.

Implemented in gramods::gmGraphics::SdlWindow.

◆ removeEventHandler()

void gramods::gmGraphics::Window::removeEventHandler ( void *  tag)

Removes the event handler associnated with the specified tag.

◆ renderFullPipeline()

void gramods::gmGraphics::Window::renderFullPipeline ( ViewSettings  settings)
overridevirtual

Dispatches specified renders, both method argument and class members, to the views in this window.

Reimplemented from gramods::gmGraphics::ViewBase.

◆ setBackgroundColor()

gramods::gmCore::OFactory::ParamSetterInsert gm_ofi_Window_param_backgroundColor &Window::_gm_ofi(& gramods::gmGraphics::Window::setBackgroundColor ( gmCore::float4  c)
inlinevirtual

Set the background color of the window.

XML-attribute: backgroundColor

◆ setDisplay()

gramods::gmCore::OFactory::ParamSetterInsert gm_ofi_Window_param_display &Window::_gm_ofi(& gramods::gmGraphics::Window::setDisplay ( size_t  N)
inlinevirtual

Set on which display the window should be shown.

XML-attribute: display

◆ setFullscreen()

gramods::gmCore::OFactory::ParamSetterInsert gm_ofi_Window_param_fullscreen &Window::_gm_ofi(& gramods::gmGraphics::Window::setFullscreen ( bool  on)
inlinevirtual

Activates or deactivates fullscreen mode.

This should be overloaded by sub classes to also support run-time changes.

XML-attribute: fullscreen

◆ setPosition()

gramods::gmCore::OFactory::ParamSetterInsert gm_ofi_Window_param_position &Window::_gm_ofi(& gramods::gmGraphics::Window::setPosition ( gmCore::int2  p)
inlinevirtual

Sets the position of the window.

XML-attribute: position

◆ setSize()

gramods::gmCore::OFactory::ParamSetterInsert gm_ofi_Window_param_size &Window::_gm_ofi(& gramods::gmGraphics::Window::setSize ( gmCore::size2  s)
inlinevirtual

Sets the size of the drawable canvas of this window, in pixels.

This should be overloaded by sub classes to also support run-time changes.

XML-attribute: size

◆ setTitle()

gramods::gmCore::OFactory::ParamSetterInsert gm_ofi_Window_param_title &Window::_gm_ofi(& gramods::gmGraphics::Window::setTitle ( std::string  t)
inlinevirtual

Sets the title of the windows.

This should be overloaded by sub classes to also support run-time changes.

XML-attribute: title

◆ swap()

virtual void gramods::gmGraphics::Window::swap ( )
pure virtual

Posts a swap buffers command to the underlying windowing system, to show the newly rendered material.

Most drivers allow this command to return immediately, however subsequent calls to render to the same context may stall to wait for vertical scan synchronization (v-sync).

Implemented in gramods::gmGraphics::SdlWindow.

◆ sync()

void gramods::gmGraphics::Window::sync ( )
virtual

Calls glFinish on the GL context.

The only reason to call this method is if the application needs to wait for vertical scan synchronization (v-sync), for example for timing reasons.

◆ traverse()

void gramods::gmGraphics::Window::traverse ( Visitor visitor)
overridevirtual

Propagates the specified visitor.

See also
Object::Visitor

Reimplemented from gramods::gmGraphics::ViewBase.

Member Data Documentation

◆ position

gmCore::int2 gramods::gmGraphics::Window::position
protected
Initial value:
= { (std::numeric_limits<int>::max)(),
(std::numeric_limits<int>::max)() }

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