DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
dueca::GLSweeper Class Reference

Object that takes care of initializing GL interfacing code in a specific thread, and calling swapbuffers. More...

#include <GLSweeper.hxx>

Inheritance diagram for dueca::GLSweeper:
Inheritance graph
[legend]
Collaboration diagram for dueca::GLSweeper:
Collaboration graph
[legend]

Public Member Functions

 GLSweeper (Entity *e, const char *part, const PrioritySpec &ts)
 Constructor.
 
bool complete ()
 Continued construction.
 
 ~GLSweeper ()
 Destructor.
 
bool getDoubleBuffer () const
 query double buffering.
 
bool getAlphaBuffer () const
 query alpha buffer
 
int getDepthBufferSize () const
 get minimum depth buffer size.
 
int getStencilBufferSize () const
 get minimum stencil buffer size.
 
- Public Member Functions inherited from dueca::Module
virtual ~Module ()
 Destructor.
 
virtual bool isInitialPrepared ()
 To check whether the module is prepared to be prepared.
 
ObjectType getObjectType () const
 The object type within DUECA.
 
virtual void initialStartModule (const TimeSpec &time)
 Initial start opportunity.
 
virtual void finalStopModule (const TimeSpec &time)
 Final stop command.
 
const Entity * getMyEntity ()
 Return a pointer to the entity to which this module belongs.
 
const ModuleStategetState ()
 Return the module state.
 
- Public Member Functions inherited from dueca::NamedObject
const std::string getEntity () const
 Returns the "entity" part of the name.
 
const std::string getClass () const
 Returns the "class" part of the name.
 
const std::string getPart () const
 Returns the sub-entity or "part" part of the name.
 
const NameSetgetNameSet () const
 This returns the complete name set.
 
const GlobalIdgetId () const
 This returns the id.
 

Static Public Member Functions

static const ParameterTablegetMyParameterTable ()
 Return the parameter table.
 

Static Public Attributes

static const char *const classname
 Name of the module.
 

Additional Inherited Members

- Protected Member Functions inherited from dueca::Module
 Module (const Entity *e, const char *m_class, const char *part)
 Constructor.
 
virtual void setSafetyStop ()
 Put a brake on this module's activities.
 
- Protected Member Functions inherited from dueca::NamedObject
 NamedObject (const GlobalId &id)
 Reserve for AssociateObject.
 
 NamedObject (const NameSet &ns)
 Normal constructor, protected, because it has no use to create a NamedObject by itself.
 
virtual ~NamedObject ()
 Destructor.
 
- Protected Attributes inherited from dueca::Module
ModuleState state
 Flag to remember whether we are stopped due to some error with hardware device manipulation.
 

Detailed Description

Object that takes care of initializing GL interfacing code in a specific thread, and calling swapbuffers.

If you use this method of GL programming, all gl windowing code must be in the same thread. The GLSweeper module must run last in this thread, you can achieve this by giving it a negative (the lowest) value for the "order" of its PrioritySpec.

This only works reliably when you don't use any GL code from other threads (so no gtk or other windows). If you do use windowing code, combine all windowing code in one thread, normally priority 0.

I you have no other windowing code, you can use a priority other than 0 for the sweeper. To create this priority, specify something like the following in your dueca.cnf file, e.g. with

(dueca-list
 (make-environment
   'multi-thread #t
   'priority-nice 0         ; becomes priority level 1, non-realtime
   'priority-fifo 10 11 12  ; become priority levels 2, 3, 4, realtime
   ...
 )
)

Note that the priority specifications replace the highest-priority variable. In this example the highest priority level becomes 4, and you need to specify this when making the ticker.

Here an piece of example configuration for dueca.mod:

;; NOTE that this is only allowed when not using a GL
;; interface for the priority 0 thread!!!!!
(define opengl-priority      (make-priority-spec 1     0))
(define opengl-priority-last (make-priority-spec 1   -99))

If you want to use the sweeper for testing and development purposes (solo, single machine, etc.), use priority level 0

(define opengl-priority      (make-priority-spec 0     0))
(define opengl-priority-last (make-priority-spec 0   -99))

The rest of the configuration is as follows. Remember to first create the sweeper, otherwise the gl using module will use the gl facilities of your default graphics toolkit (or find none at all).

;; in the entity creation list .....
(list
 ;; make the GL sweeper. With the priority, it will come in the
 ;; graphics thread, but as last one, after all
 (make-module 'gl-sweeper "" opengl-priority-last

              ;; some parameters that control the timing.
              'set-timing opengl-last
              'check-timing 15000 20000

              ;; a set of parameters that specify the type of GL display
              'double-buffer #t
              'alpha-buffer #t
              'depth-buffer-size 16
              'stencil-buffer-size 0

              ;; specify the toolkit that runs this GL code
              ;; this example uses glut, check DUECA's startup blurp
              ;; to see which protocols are available
              'set-protocol
                (make-glut-protocol)
              )

 ;; your GL modules.
 (make-module 'my-opengl-module "" opengl-priority
              'set-timing opengl-timing
              ;; additional options to your liking)
              )

A final note is on the timing. Ideally, the sweeper runs after you have received new data in your module. This might be tricky, and you might need some tweaking. The sweeper by default runs on the clock, and, although you specify a priority that is after the priority of the module, the sweeper may have been scheduled and started by the time your module is scheduled, and then it will run first. Try tweaking the timing to get things right.

Constructor & Destructor Documentation

◆ GLSweeper()

dueca::GLSweeper::GLSweeper ( Entity * e,
const char * part,
const PrioritySpec & ts )

Constructor.

Is normally called from scheme/the creation script.

Member Function Documentation

◆ complete()

bool dueca::GLSweeper::complete ( )
virtual

Continued construction.

This is called after all script parameters have been read and filled in, according to the parameter table. Your running environment, e.g. for OpenGL drawing, is also prepared. Any lengty initialisations (like reading the 4 GB of wind tables) should be done here. Return false if something in the parameters is wrong (by the way, it would help if you printed what!) May be deleted.

Reimplemented from dueca::Module.

◆ getDoubleBuffer()

bool dueca::GLSweeper::getDoubleBuffer ( ) const
inline

query double buffering.

Returns
true if double buffer used

◆ getAlphaBuffer()

bool dueca::GLSweeper::getAlphaBuffer ( ) const
inline

query alpha buffer

Returns
true if alpha buffer used

◆ getDepthBufferSize()

int dueca::GLSweeper::getDepthBufferSize ( ) const
inline

get minimum depth buffer size.

Returns
The number of bits in the depth buffer.

◆ getStencilBufferSize()

int dueca::GLSweeper::getStencilBufferSize ( ) const
inline

get minimum stencil buffer size.

Returns
The number of bits in the stencil buffer

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