DUECA/DUSIME
|
This class provides a barebones, simple GL canvas for you to draw on, as an alternative to the toolkit-integrated DuecaGLWindow. More...
#include <BareDuecaGLWindow.hxx>
Public Member Functions | |
BareDuecaGLWindow (const char *window_title="A DUECA GL window", bool pass_pointer=false, bool pass_keys=false, bool pass_passive=false, bool pointer_visible=false, unsigned display_periods=0, bool pass_touch=false) | |
Construct a GL window based on X11 interaction. | |
bool | setFullScreen (const bool &fs=true) |
Request full screen drawing – or not. | |
bool | selectCursor (const int &cursor) |
Request a cursor type. | |
bool | setWindow (const std::vector< int > &wpos) |
Set the window position, at least if the window manager will honour this. | |
void | openWindow () |
open the window. | |
void | setWindow (int posx, int poxy, int width, int height) |
Set up the window initial position and size. | |
virtual | ~BareDuecaGLWindow () |
Destructor. | |
virtual void | reshape (int x, int y) |
This is called if the size of the window is changed. | |
virtual void | display ()=0 |
This is called whenever the display needs to be redrawn. | |
virtual void | initGL () |
This is called when the window is ready, for first-time set-up. | |
void | waitSwap () |
Wait on the buffer swap. | |
void | redraw () |
Indicate that a redraw is required. | |
virtual void | keyboard (unsigned char key, int x, int y) |
Called when a key is pressed, override to get key information. | |
virtual void | special (int key, int x, int y) |
Called when a function key is pressed. | |
virtual void | mouse (int button, int state, int x, int y) |
This is called whenever a mouse button event comes in. | |
virtual void | motion (int x, int y) |
This is called whenever a mouse motion event comes in. | |
virtual void | passive (int x, int y) |
This is called whenever a mouse motion event comes in, but none of the buttons are pressed. | |
virtual void | touch (unsigned finger, bool s, float x, float y) |
This is called for touch events. | |
int | getWidth () |
Obtain the current widget width. | |
int | getHeight () |
Obtain the current widget height. | |
int | getXOffset () |
Obtain current widget x-position. | |
int | getYOffset () |
Obtain current widget y-position. | |
void | swapBuffers () |
Swapbuffers is only for compatibility with DuecaGLWindow. | |
This class provides a barebones, simple GL canvas for you to draw on, as an alternative to the toolkit-integrated DuecaGLWindow.
It will directly open a window in the native windowing environment of your system.
You can use it to have a display that is synced to your graphics card retrace. In that case, either create a drawing class that derives from this BareDuecaGLWindow, or use double inheritance to derive a DUECA module also from this class.
In your doCalculation routine, use the following basic pattern. You need two variables defined in your class,
claim_thread is a flag that indicates whether the drawing is in its own thread (a necessity for following the graphics card retrace) or not. Typically, you make this user-configurable.
run_until is a TimeTickType, that is set in startModule and stopModule. Initialize to 0.
have_to_open is a flag to remember to open the display. Initialize to true.
startModule and stopModule need to be adjusted accordingly:
And depending on the mode, connect one or the other to your activity in your complete() method.
Instead of triggering on the time of your own clock, you can of course also trigger on incoming data.
Don't forget to adjust your clock's rate if you get passed a time spec
dueca::BareDuecaGLWindow::BareDuecaGLWindow | ( | const char * | window_title = "A DUECA GL window", |
bool | pass_pointer = false, | ||
bool | pass_keys = false, | ||
bool | pass_passive = false, | ||
bool | pointer_visible = false, | ||
unsigned | display_periods = 0, | ||
bool | pass_touch = false ) |
Construct a GL window based on X11 interaction.
window_title | Title for the window |
pass_pointer | Pass pointer actions (clicks, release, drag) through the "mouse" callback |
pass_keys | Pass keypresses through the "keyboard" and "special" callbacks |
pass_passive | Also pass passive mouse/pointer motion |
pointer_visible | Show the pointer in the screen |
display_periods | If nonzero, attempt to sync to the display refresh, number indicates division |
pass_touch | Pass touch events |
Request full screen drawing – or not.
Can be linked to Scheme in a parameter table. Use this call before opening the window with openWindow.
Set the window position, at least if the window manager will honour this.
Can be linked to Scheme in a parameter table. Use this call before opening the window with openWindow.
void dueca::BareDuecaGLWindow::openWindow | ( | ) |
open the window.
Take care to do this in the same thread as in which you will be running the drawing and waiting.
Set up the window initial position and size.
Honouring of initial position depends on the window manager. Use this call before opening the window with openWindow.
This is called if the size of the window is changed.
You might need to update the image set-up for a different screen format.
This is called whenever the display needs to be redrawn.
When called, the appropriate display context has been made current.
This is called when the window is ready, for first-time set-up.
DO NOT CALL THIS FUNCTION YOURSELF! Override this function, and when it is called, you can assume the gl code is possible. So creating viewports, GL lists, allocating textures etc. can be done in initGL.
void dueca::BareDuecaGLWindow::redraw | ( | ) |
Indicate that a redraw is required.
This will set the context, and call your display routine.
|
inline |
Swapbuffers is only for compatibility with DuecaGLWindow.
Does nothing.