libcvd
Classes | Public Member Functions | Static Public Attributes | Related Functions | List of all members
CVD::VideoDisplay Class Reference

A cheap and cheerful GL display window using X and the GLX library. More...

#include <videodisplay.h>

Collaboration diagram for CVD::VideoDisplay:
Collaboration graph
[legend]

Public Member Functions

 VideoDisplay (double left, double top, double right, double bottom, double scale=1, int *visualAttr=defAttr, bool map=true)
 Construct (and display) a display window. More...
 
 VideoDisplay (ImageRef size, const DoNotMapStruct &, int *visualAttr=defAttr)
 Construct (and display) a display window. More...
 
 VideoDisplay (ImageRef size, double scale=1, int *visualAttr=defAttr)
 Construct (and display) a display window. More...
 
 ~VideoDisplay ()
 Destructor. This also removes the window from the display.
 
void set_title (const std::string &s)
 Set the window title. More...
 
int get_fd ()
 Returns the connection number for this display.
 
void select_events (long event_mask)
 Select which X events to handle (by default, nothing is handled) More...
 
void get_event (XEvent *event)
 Get the next X event from the queue by calling XNextEvent. More...
 
void locate_display_pointer (int &x, int &y)
 Where is the mouse pointer in the window? More...
 
void locate_video_pointer (double &x, double &y)
 Where is the mouse pointer in local GL co-ordinates? More...
 
void flush ()
 Flushes the output buffer by calling XFlush.
 
int pending ()
 How many events are waiting the queue?
 
void set_zoom (double left, double top, double right, double bottom, double scale)
 Set the desired mapping between local GL and image co-ordinates. More...
 
void zoom_in (double cx, double cy, double factor=2)
 Change the image mapping to zoom in around the specified point. More...
 
void zoom_out (double cx, double cy, double factor=2)
 Change the image mapping to zoom out around the specified point. More...
 
void zoom_reset ()
 Reset the image mapping to that when the VideoDisplay was created.
 
double video_width () const
 What is the width of the local GL co-ordinates displayed?
 
double video_height () const
 What is the height of the local GL co-ordinates displayed?
 
void display_to_video (int dx, int dy, double &vx, double &vy)
 Convert image co-ordinates into local GL co-ordinates. More...
 
void video_to_display (double dx, double dy, int &vx, int &vy)
 Convert local GL co-ordinates into image co-ordinates. More...
 
void make_current ()
 Make this window the current GL context. More...
 
void swap_buffers ()
 Swap the front and back GL buffers. More...
 
Display * display ()
 What is my display?
 
Window window ()
 Which is my window?
 

Static Public Attributes

static const DoNotMapStruct DoNotMap
 

Related Functions

(Note that these are not member functions.)

int defAttr []
 The default GLX display request, corresponding to the minimum specification Gl display visual (8-bit colour) More...
 

Detailed Description

A cheap and cheerful GL display window using X and the GLX library.

VideoDisplay maintains for you the mapping between your choice of local GL co-ordinates, and image co-ordinates and provides functions for converting between the two. It does not, however, manage any X events, for example resize or redraw events. To develop a more sophisticated display window, you must select which XEvents to monitor using select_events() and then poll using pending() and use get_event() to handle events.

Constructor & Destructor Documentation

◆ VideoDisplay() [1/3]

CVD::VideoDisplay::VideoDisplay ( double  left,
double  top,
double  right,
double  bottom,
double  scale = 1,
int *  visualAttr = defAttr,
bool  map = true 
)

Construct (and display) a display window.

Parameters
leftThe local GL co-ordinate of the left of the window
topThe local GL co-ordinate of the top of the window
rightThe local GL co-ordinate of the right of the window
bottomThe local GL co-ordinate of bottom of the window
scaleThe number of image pixels per GL unit (default 1:1)
visualAttrThe attributes passed to glXChooseVisual
mapWhether or not to map the window

◆ VideoDisplay() [2/3]

CVD::VideoDisplay::VideoDisplay ( ImageRef  size,
const DoNotMapStruct &  ,
int *  visualAttr = defAttr 
)

Construct (and display) a display window.

Parameters
sizeThe GL co-ordinate window goes from (0,0) to (size.x, size.y)
mapWhether or not to map the window
visualAttrThe attributes passed to glXChooseVisual

◆ VideoDisplay() [3/3]

CVD::VideoDisplay::VideoDisplay ( ImageRef  size,
double  scale = 1,
int *  visualAttr = defAttr 
)

Construct (and display) a display window.

Parameters
sizeThe GL co-ordinate window goes from (0,0) to (size.x, size.y)
scaleThe number of image pixels per GL unit (default 1:1)
visualAttrThe attributes passed to glXChooseVisual

Member Function Documentation

◆ display_to_video()

void CVD::VideoDisplay::display_to_video ( int  dx,
int  dy,
double &  vx,
double &  vy 
)

Convert image co-ordinates into local GL co-ordinates.

Parameters
dxThe image x co-ordinate to convert
dyThe image y co-ordinate to convert
vxThe returned local GL x co-ordinate
vyThe returned local GL y co-ordinate

◆ get_event()

void CVD::VideoDisplay::get_event ( XEvent *  event)

Get the next X event from the queue by calling XNextEvent.

If the queue is empty, this function blocks until the next event

Parameters
eventThe next event

◆ locate_display_pointer()

void CVD::VideoDisplay::locate_display_pointer ( int &  x,
int &  y 
)

Where is the mouse pointer in the window?

Parameters
xThe x co-ordinate
yThe y co-ordinate

◆ locate_video_pointer()

void CVD::VideoDisplay::locate_video_pointer ( double &  x,
double &  y 
)

Where is the mouse pointer in local GL co-ordinates?

Parameters
xThe x co-ordinate
yThe y co-ordinate

◆ make_current()

void CVD::VideoDisplay::make_current ( )

Make this window the current GL context.

If there is more than one GL window being used in your program, this function should be called before drawing to ensure you draw to the correct window.

◆ select_events()

void CVD::VideoDisplay::select_events ( long  event_mask)

Select which X events to handle (by default, nothing is handled)

Parameters
event_maskORed list of XEvents to handle

◆ set_title()

void CVD::VideoDisplay::set_title ( const std::string &  s)

Set the window title.

Parameters
sThe new title

◆ set_zoom()

void CVD::VideoDisplay::set_zoom ( double  left,
double  top,
double  right,
double  bottom,
double  scale 
)

Set the desired mapping between local GL and image co-ordinates.

Parameters
leftThe local GL co-ordinate of the left of the window
topThe local GL co-ordinate of the top of the window
rightThe local GL co-ordinate of the right of the window
bottomThe local GL co-ordinate of bottom of the window
scaleThe number if image pixels per GL unit

◆ swap_buffers()

void CVD::VideoDisplay::swap_buffers ( )

Swap the front and back GL buffers.

This calls glXSwapBuffers for the current context.

◆ video_to_display()

void CVD::VideoDisplay::video_to_display ( double  dx,
double  dy,
int &  vx,
int &  vy 
)

Convert local GL co-ordinates into image co-ordinates.

Parameters
dxThe local GL x co-ordinate to convert
dyThe local GL y co-ordinate to convert
vxThe returned image x co-ordinate
vyThe returned image y co-ordinate

◆ zoom_in()

void CVD::VideoDisplay::zoom_in ( double  cx,
double  cy,
double  factor = 2 
)

Change the image mapping to zoom in around the specified point.

Parameters
cxThe x co-ordinate of the zoom centre
cyThe y co-ordinate of the zoom centre
factorThe zoom factor (default 2)

◆ zoom_out()

void CVD::VideoDisplay::zoom_out ( double  cx,
double  cy,
double  factor = 2 
)
inline

Change the image mapping to zoom out around the specified point.

Parameters
cxThe x co-ordinate of the zoom centre
cyThe y co-ordinate of the zoom centre
factorThe zoom factor (default 2)

Friends And Related Function Documentation

◆ defAttr

int defAttr[]
related

The default GLX display request, corresponding to the minimum specification Gl display visual (8-bit colour)


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