DUECA/DUSIME
|
Provides a DUECA shell around a window with a Gtk4 GtkGlarea. More...
#include <DuecaGLGtk4Window.hxx>
Public Member Functions | |
DuecaGLGtk4Window (const char *window_title="DUECA", bool pass_passive=false, bool depth_buffer=true, bool stencil_buffer=false) | |
Constructor. | |
~DuecaGLGtk4Window () | |
Destructor. | |
bool | setFullScreen (const bool &fs=true) |
Request full screen drawing – or not. | |
bool | setWindow (const std::vector< int > &wpos) |
Set the window position, at least if the window manager will honour this. | |
void | setWindow (int posx, int poxy, int width, int height) |
Set up the window initial position and size. | |
void | openWindow () |
Do the opening and displaying of the window. | |
void | placeWindow () |
If position given, place the window. | |
void | selectCursor (int cursor) |
Select cursor type. | |
void | redraw () |
Indicate that a redraw of the window is needed. | |
void | swapBuffers () |
Swap front and back buffers. | |
bool | selectGraphicsContext (bool do_select=true) |
Set the graphics content as current. | |
void | makeCurrent () |
If you want to do GL work outside the draw routine (add GL lists etc.) the window needs to be current. | |
virtual void | display ()=0 |
Function to implement in a derived class. | |
virtual void | initGL () |
Function to implement in a derived class. | |
![]() | |
void | newSize (int w, int h) |
Specify a new size. | |
DuecaGtkInteraction (GtkWidget *widget=NULL, int w=0, int h=0) | |
Constructor. | |
~DuecaGtkInteraction () | |
Destructor. | |
int | getWidth () |
Information function, retrieve width. | |
int | getHeight () |
Information function, retrieve height. | |
int | getXOffset () |
Retrieve x position. | |
int | getYOffset () |
Retrieve y position. | |
void | passShape () |
pass a previous/default shape. | |
virtual void | reshape (int x, int y) |
callback function, override to get notified of shape changes | |
virtual void | keyboard (char c, int x, int y) |
callback function, override to get notified of keypresses | |
virtual void | special (int c, int x, int y) |
callback function, override to get notified of special key presses | |
virtual void | motion (int x, int y) |
mouse motion, with pressed key | |
virtual void | passive (int x, int y) |
mouse motion, nothing pressed | |
virtual void | mouse (int button, int state, int x, int y) |
mouse button press actions | |
Additional Inherited Members | |
![]() | |
void | init (GtkWidget *widget=NULL) |
Helper function, initialization. | |
![]() | |
int | width |
Width of the GL widget. | |
int | height |
Height of the GL widget. | |
int | x |
X position of the GL widget. | |
int | y |
Y position of the GL widget. | |
bool | dopass |
Flag to indicate passing events. | |
Provides a DUECA shell around a window with a Gtk4 GtkGlarea.
After deriving from this class, you should implement the GL drawing routine.
You can also implement callbacks for reshape, initialisation and mouse and keyboard events, check DuecaGtkInteraction for these.
Note that these GL windows are primarily for testing. Using e.g. BareDuecaGLWindow you will get a window with lower overhead, that can also be run in a separate thread, blocking for the graphics refresh. Use that for serious deployment, and the GTK version for testing.
Also note that under "modern" desktops, you would get a Wayland window with the default gtk4 GLArea, and these use OpenGL ES, rather than the "classic" desktop OpenGL you might be used to. The shaders you use need to be compliant with ES, see
As far as I can tell it is not possible to mix this in the same DUECA process with X11 GL windows.
dueca::DuecaGLGtk4Window::DuecaGLGtk4Window | ( | const char * | window_title = "DUECA", |
bool | pass_passive = false, | ||
bool | depth_buffer = true, | ||
bool | stencil_buffer = false ) |
Constructor.
window_title | Title for the window |
pass_passive | For compatibility, passive movement always passed. |
depth_buffer | Request a depth buffer |
stencil_buffer | Request a stencil buffer |
bool dueca::DuecaGLGtk4Window::setFullScreen | ( | const bool & | fs = true | ) |
Request full screen drawing – or not.
Can be linked to Scheme in a parameter table. This call is ignored for
bool dueca::DuecaGLGtk4Window::setWindow | ( | const std::vector< int > & | wpos | ) |
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::DuecaGLGtk4Window::setWindow | ( | int | posx, |
int | poxy, | ||
int | width, | ||
int | height ) |
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.
void dueca::DuecaGLGtk4Window::openWindow | ( | ) |
Do the opening and displaying of the window.
In your module, preferably place this call in the "complete()" method. At this time, all GL stuff is in place, while the system is normally not yet running real-time.
void dueca::DuecaGLGtk4Window::selectCursor | ( | int | cursor | ) |
Select cursor type.
bool dueca::DuecaGLGtk4Window::selectGraphicsContext | ( | bool | do_select = true | ) |
Set the graphics content as current.
Note that this is normally not needed, in the initGL, display and reshape callbacks, the GC will be current. You can use this in your destructor, when GL objects are deleted, and you need a correct GC for that.
do_select | When false, resets the GC |
void dueca::DuecaGLGtk4Window::makeCurrent | ( | ) |
If you want to do GL work outside the draw routine (add GL lists etc.) the window needs to be current.
First call this routine in that case.
|
pure virtual |
Function to implement in a derived class.
Can assume that the GL context is current, do not need a swap call at the end! Only draw!
|
virtual |
Function to implement in a derived class.
Called with the GL context current.