SDLdisplay Class Reference

Class fo do various fast graphics displays. More...

#include <GUI/SDLdisplay.H>

Inheritance diagram for SDLdisplay:
Inheritance graph
[legend]
Collaboration diagram for SDLdisplay:
Collaboration graph
[legend]

List of all members.

Public Types

enum  DelayType { NO_WAIT, NEXT_VSYNC, NEXT_FRAMETIME }
 

Different types of inter-frame delay that can be requested.

More...

Public Member Functions

void displaySDLSurfacePatch (SDL_Surface *surf, SDL_Rect *offset, SDL_Rect *clip, const int frame=-2, const bool vsync=true, const bool flip=true)
 Display an SDLSurface patch on thescreen.
Constructors, destructor and initialization

 SDLdisplay (OptionManager &mgr, const std::string &descrName="SDL Display", const std::string &tagName="SDLdisplay")
 Constructor.
virtual ~SDLdisplay ()
 Destructor.
void setEventLog (nub::soft_ref< EventLog > elog)
 Link us to an EventLog component.
General display property functions

int getBytesPerPixel () const
 Get bytes per pixel.
Dims getDims () const
 Get display dimensions, in pixels.
int getWidth () const
 Get display width, in pixels.
int getHeight () const
 Get display height, in pixels.
void showCursor (const bool showit)
 Show or hide mouse pointer.
Pixel-level functions

Uint32 getUint32color (const PixRGB< byte > &col) const
 Get the 32 bit color value corresponding to a given RGB pixel.
PixRGB< bytegetRGBcolor (const Uint32 col) const
 Get the RGB color triplet corresponding to a given Uint32 color.
Basic display and interaction functions

void openDisplay ()
 open a SDL display
void closeDisplay ()
 close a SDL display
void lockScreen ()
 Lock the screen, as required before using some functions.
void unlockScreen ()
 Unlock the (previously locked) screen.
void clearScreen (const PixRGB< byte > col, const bool vsync=true)
 clear the screen
void clearBackBuffer ()
 clear the video back buffer
Uint32 getPixel32 (const int x, const int y) const
 Return the pixel value at (x, y).
void putPixel32 (const int x, const int y, const Uint32 pixel)
 Set the pixel at (x, y) to the given value.
void displayText (const std::string &msg, const bool vsync, const PixRGB< byte > txtcol, const PixRGB< byte > bgcol, int ind=0, const int=10)
 show a text message
void displayText (const std::string &msg, Point2D< int > p, const PixRGB< byte > txtcol, const PixRGB< byte > bgcol, const bool vsync)
 show a text message in a given place
void waitNextRequestedVsync (const bool checkdelay=false, const bool quiet=true)
 Wait until start of the next vertical blanking, per our frame rate.
void waitNextRequestedFrameTime (const int frame, const bool checkdelay=false, const bool quiet=true)
 Wait for the next frame time, per our frame rate.
void waitFrames (const int n)
 Wait for a number of frame periods.
void setDesiredRefreshDelayUsec (float usec, float tol=0.05F)
 Set a desired refresh delay in microseconds, and a fractional tolerance around that delay.
Keyboard functions

int waitForKey (bool doWait=true)
 wait for a keypress and return character for key pressed
int waitForKeyTimeout (double timeout=1000, bool doWait=true)
 wait for a keypress and return character for key pressed
int waitForMouseClick (bool doWait=true)
 wait for a mouseclick and return 1 for left button click and 2 for right button click
long getTimerValue ()
int waitForMouseWheelEvent (bool doWait=true)
int checkForMouseClick ()
 check whether a mouseclick has occurred and return 1 for key left button clicked and 2 for right button clicked
int checkForKey ()
 check whether a keypress has occurred and return char for key pressed
std::string getString (char terminator)
 store the string of keypresses input by the user until the terminating character has been reached
Image blitting functions

void displayImage (const Image< PixRGB< byte > > &img, const bool resiz=false, const PixRGB< byte > bgcol=PixRGB< byte >(0, 0, 0), const int frame=-1, const bool vsync=true)
 Display an image, centered over the screen area.
SDL_Surface * makeBlittableSurface (const Image< PixRGB< byte > > &img, const bool resiz=false, const PixRGB< byte > bgcol=PixRGB< byte >(0, 0, 0))
 Make a blittable surface from an Image.
void displaySurface (SDL_Surface *img, const int frame=-1, const bool vsync=true)
 Display an SDL surface that has been pre-formatted for fast blitting.
void displayImagePatch (const Image< PixRGB< byte > > &image, const Point2D< int > &pos, const int frame=-1, const bool vsync=true, const bool flip=true)
 Display an image patch.
YUV overlay functions

bool hasYUVoverlay () const
 Check whether somebody has already created a YUV overlay for this display.
void createYUVoverlay (const Uint32 format, const int w, const int h)
 create a YUV overlay of specified size
void createYUVoverlay (const Uint32 format)
 create a YUV overlay
void destroyYUVoverlay ()
 destroy a previously-created YUV overlay
SDL_Overlay * lockYUVoverlay ()
 Lock YUV overlay and get a pointer to it for direct access to pixel data.
void unlockYUVoverlay ()
 Unlock YUV overlay.
void displayYUVoverlay (const int frame, const DelayType dly, const int x, const int y, const int w, const int h)
 display current YUV overlay
void displayYUVoverlay (const int frame, const DelayType w)
 display current YUV overlay
bool supportsVideoOverlay (const VideoFormat vidformat) const
 test whether we can do video overlays in the given frame format
void createVideoOverlay (const VideoFormat vidformat, const int w, const int h)
 create a YUV overlay of specific size from a video format
void createVideoOverlay (const VideoFormat vidformat)
 create a YUV overlay from a video format
void displayVideoOverlay (const VideoFrame &buf, const int frame, const DelayType w)
 copy video data to the current YUV overlay, and display it
void displayVideoOverlay_pos (const VideoFrame &buf, const int frame, const DelayType w, const int x, const int y, const int rw, const int rh)
 copy video data to the current YUV overlay, and display it
void displayVideoOverlay_image (const VideoFrame &frame, const int framenum, const DelayType dly, const Image< PixRGB< byte > > &img, const PixRGB< byte > &transpix, const uint threads=1)
 overlay an image onto a video and copy it to the current YUV
void displayVideoOverlay_patch (const VideoFrame &frame, const int framenum, const DelayType dly, const uint x, const uint y, const Image< PixRGB< byte > > &img)
 overlay an small patch onto a video and copy it to the current
Event logging functions

void pushEvent (const std::string &msg)
 Pass-through to EventLog::pushEvent().
void pushEventBegin (const std::string &msg)
 Pass-through to EventLog::pushEventBegin().
void pushEventEnd (const std::string &msg)
 Pass-through to EventLog::pushEventEnd().

Protected Member Functions

void start2 ()
 get started
void stop1 ()
 get stopped
void syncScreen (const bool vsync=true, const bool checkdelay=false, const bool quiet=false)

Protected Attributes

OModelParam< DimsitsDims
 screen resolution
OModelParam< int > itsPriority
 priority for SCHED_FIFO, or 0 for normal
OModelParam< float > itsRefreshDelay
 desired refresh delay in usec
OModelParam< bool > itsFullscreen
 whether to run in a fullscreen window
NModelParam< bool > itsSlaveMode
 slave mode (someone else opens screen)
OModelParam< uintitsVBlankKludge
 workaround for non-working vblank
OModelParam< RectangleitsSyncRect
 patch for syncing with photodiode
Timer itsTimer
uint64 itsLastSync
uint64 itsLastOvlDisplay
float itsRefreshTolerance
SDL_Surface * itsScreen
SDL_Overlay * itsOverlay
SDL_Overlay * videoOverlay

Detailed Description

Class fo do various fast graphics displays.

This class is to facilitate the display of various graphics stimuli, with an emphasis on strict real-time operation and in particular on playing movies at a controlled framerate with microsecond accuracy. Programs using this class, such as psycho-movie.C, should run as root if SCHED_FIFO scheduling is required (and I highly recommend it, as it will make timing reliable). The class uses the SDL library to do the displays. This class attempts to lock onto the display's vertical blanking for reliable timing of movie playing. Note that, as far as I know, SDL does not provide a way to select a screen refresh rate; instead, you need to specify the refresh rate in your X config. I used the modeline calculator at http://xtiming.sourceforge.net/cgi-bin/xtiming.pl to figure out good modelines for the refresh rates I wanted. For example: for a 120Hz 640x480 display, I got:

Modeline "640x480@120" 55.43 640 672 880 912 480 487 497 505

which I added to the "Monitor" section of /etc/X11/XF86Config-4, and I also specified that this mode should be used by giving its name in the "Screen" section:

Subsection "Display" Depth 24 Modes "1280x1024" "1280x960" "1152x864" "1024x768" "800x600" "640x480@120" EndSubsection

Always verify on the OSD info page of your monitor that you are actually getting the refresh rate you want.

For 640x480 @ 60Hz doublescan, I use: Modeline "640x480@60d" 48.21 640 672 760 792 480 490 495 505 doublescan

For 800x600 @ 60Hz (for LCD goggles): ModeLine "800x600@60" 40.0 800 840 968 1056 600 601 605 628 +hsync +vsync

For standard VESA 640x480 @ 60Hz: Modeline "psycho" 25.2 640 656 752 800 480 490 492 525 -hsync -vsync

Definition at line 97 of file SDLdisplay.H.


Member Enumeration Documentation

Different types of inter-frame delay that can be requested.

Enumerator:
NO_WAIT 

Don't wait at all between frames.

NEXT_VSYNC 

Wait for the next vertical blanking period.

NEXT_FRAMETIME 

Wait for the next frame time according to itsRefreshDelay.

Definition at line 102 of file SDLdisplay.H.


Constructor & Destructor Documentation

SDLdisplay::SDLdisplay ( OptionManager mgr,
const std::string descrName = "SDL Display",
const std::string tagName = "SDLdisplay" 
)

Constructor.

Definition at line 380 of file SDLdisplay.C.

SDLdisplay::~SDLdisplay (  )  [virtual]

Destructor.

Definition at line 399 of file SDLdisplay.C.


Member Function Documentation

int SDLdisplay::checkForKey (  ) 

check whether a keypress has occurred and return char for key pressed

a value of -1 is returned if no keypress occured

Definition at line 731 of file SDLdisplay.C.

References pushEvent(), and sformat().

Referenced by waitForKey(), and waitForKeyTimeout().

int SDLdisplay::checkForMouseClick (  ) 

check whether a mouseclick has occurred and return 1 for key left button clicked and 2 for right button clicked

a value of -1 is returned if no mouse click event occured

Definition at line 756 of file SDLdisplay.C.

References pushEvent(), and sformat().

Referenced by waitForMouseClick().

void SDLdisplay::clearBackBuffer (  ) 

clear the video back buffer

Definition at line 622 of file SDLdisplay.C.

References getBytesPerPixel(), OModelParam< T >::getVal(), itsDims, lockScreen(), Dims::sz(), and unlockScreen().

void SDLdisplay::clearScreen ( const PixRGB< byte col,
const bool  vsync = true 
)

clear the screen

Parameters:
col the background color to use
vsync will attempt to sync with vertical blanking if true

Definition at line 598 of file SDLdisplay.C.

References getHeight(), getUint32color(), getWidth(), Rectangle::height(), Rectangle::isValid(), Rectangle::left(), pushEventBegin(), pushEventEnd(), Rectangle::top(), and Rectangle::width().

Referenced by openDisplay(), and start2().

void SDLdisplay::closeDisplay (  ) 

close a SDL display

Definition at line 564 of file SDLdisplay.C.

References destroyYUVoverlay(), OModelParam< T >::getVal(), NModelParam< T >::getVal(), itsPriority, and itsSlaveMode.

Referenced by stop1().

void SDLdisplay::createVideoOverlay ( const VideoFormat  vidformat  ) 

create a YUV overlay from a video format

All the other overlay functions will throw a fatal error if no overlay has been created.

Definition at line 1178 of file SDLdisplay.C.

References createYUVoverlay().

void SDLdisplay::createVideoOverlay ( const VideoFormat  vidformat,
const int  w,
const int  h 
)

create a YUV overlay of specific size from a video format

All the other overlay functions will throw a fatal error if no overlay has been created.

Definition at line 1169 of file SDLdisplay.C.

References createYUVoverlay().

void SDLdisplay::createYUVoverlay ( const Uint32  format  ) 

create a YUV overlay

All the other overlay functions will throw a fatal error if no overlay has been created.

Definition at line 966 of file SDLdisplay.C.

References destroyYUVoverlay(), getHeight(), getWidth(), and SDLFATAL.

void SDLdisplay::createYUVoverlay ( const Uint32  format,
const int  w,
const int  h 
)

create a YUV overlay of specified size

All the other overlay functions will throw a fatal error if no overlay has been created.

Definition at line 947 of file SDLdisplay.C.

References destroyYUVoverlay(), and SDLFATAL.

Referenced by createVideoOverlay().

void SDLdisplay::destroyYUVoverlay (  ) 

destroy a previously-created YUV overlay

Overlay displays and normal displays don't mix well in SDL. So, typically, you would create the overlay just before playing a movie in YUV mode, then play the movie, then clear the screen and destroy the overlay, do a few normal displays (like a fixation cross, some text, etc), and loop.

Definition at line 985 of file SDLdisplay.C.

Referenced by closeDisplay(), and createYUVoverlay().

void SDLdisplay::displayImage ( const Image< PixRGB< byte > > &  img,
const bool  resiz = false,
const PixRGB< byte bgcol = PixRGB<byte>(0, 0, 0),
const int  frame = -1,
const bool  vsync = true 
)

Display an image, centered over the screen area.

If you want to display an image that is smaller than the display area at a well-defined location on the screen, see displayImagePatch(). This just calls makeBlittableSurface() followed by displaySurface(). It is often beneficial to use these other two functions for real-time applications, first preparing your surfaces when you have some extra available time, and then getting a faster blit.

Definition at line 794 of file SDLdisplay.C.

References displaySurface(), and makeBlittableSurface().

void SDLdisplay::displayImagePatch ( const Image< PixRGB< byte > > &  image,
const Point2D< int > &  pos,
const int  frame = -1,
const bool  vsync = true,
const bool  flip = true 
)

Display an image patch.

Parameters:
image an image patch
pos the position of the top-left corner of the image
frame this is just used for the log messages; if it is -1 then no frame number/duration are logged; if it is -2 both the start and end of the function execution are logged
vsync will attempt to sync with vertical blanking if true

Definition at line 905 of file SDLdisplay.C.

References Image< T >::getHeight(), Image< T >::getWidth(), Point2D< T >::i, image, pushEvent(), pushEventBegin(), pushEventEnd(), SDLFATAL, sformat(), and waitNextRequestedVsync().

Referenced by PsychoDisplay::displayFixationIcon().

void SDLdisplay::displaySDLSurfacePatch ( SDL_Surface *  surf,
SDL_Rect *  offset,
SDL_Rect *  clip,
const int  frame = -2,
const bool  vsync = true,
const bool  flip = true 
)

Display an SDLSurface patch on thescreen.

Parameters:
surf a pointer to a SDL_Surface
offset a pointer to a SDL_Rect which encapsulates the offset
clip a pointer to a SDL_Rect which encapsulates the clip to be shown from surf
frame this is just used for the log messages; if it is -1 then no frame number/duration are logged; if it is -2 both the start and end of the function execution are logged
vsync will attempt to sync with vertical blanking if true
flip will attempt to flip if true

Definition at line 880 of file SDLdisplay.C.

References pushEvent(), pushEventBegin(), pushEventEnd(), SDLFATAL, sformat(), and waitNextRequestedVsync().

void SDLdisplay::displaySurface ( SDL_Surface *  img,
const int  frame = -1,
const bool  vsync = true 
)

Display an SDL surface that has been pre-formatted for fast blitting.

Parameters:
img a pre-formatted image; no rescaling will be attempted and it will just be blitted into the screen. Suitable surfaces may be obtained by makeBlittableSurface()
frame this is just used for the log messages; if it is -1 then no frame number/duration are logged; if it is -2 both the start and end of the function execution are logged
vsync will attempt to sync with vertical blanking if true

Definition at line 856 of file SDLdisplay.C.

References pushEvent(), pushEventBegin(), pushEventEnd(), SDLFATAL, sformat(), and waitNextRequestedVsync().

Referenced by displayImage(), PsychoDisplay::displayNumbers(), and displayText().

void SDLdisplay::displayText ( const std::string msg,
Point2D< int >  p,
const PixRGB< byte txtcol,
const PixRGB< byte bgcol,
const bool  vsync 
)

show a text message in a given place

Definition at line 1609 of file SDLdisplay.C.

References displaySurface(), OModelParam< T >::getVal(), itsDims, NO_INIT, and writeText().

void SDLdisplay::displayText ( const std::string msg,
const bool  vsync,
const PixRGB< byte txtcol,
const PixRGB< byte bgcol,
int  ind = 0,
const int  fontsize = 10 
)

show a text message

Parameters:
ind ind=0 displays the text in the middle of screen, ind =1 displays the text on top or the screen and ind = -1 displays the message at the buttom of the display

Definition at line 1573 of file SDLdisplay.C.

References displaySurface(), SimpleFont::FIXED(), OModelParam< T >::getVal(), Dims::h(), Point2D< T >::i, itsDims, NO_INIT, Dims::w(), and writeText().

void SDLdisplay::displayVideoOverlay ( const VideoFrame buf,
const int  frame,
const DelayType  w 
)

copy video data to the current YUV overlay, and display it

Definition at line 1186 of file SDLdisplay.C.

References displayYUVoverlay(), VideoFrame::getBuffer(), getDims(), VideoFrame::getDims(), VideoFrame::getMode(), Dims::h(), lockYUVoverlay(), unlockYUVoverlay(), and Dims::w().

void SDLdisplay::displayVideoOverlay_image ( const VideoFrame frame,
const int  framenum,
const DelayType  dly,
const Image< PixRGB< byte > > &  img,
const PixRGB< byte > &  transpix,
const uint  threads = 1 
)
void SDLdisplay::displayVideoOverlay_patch ( const VideoFrame frame,
const int  framenum,
const DelayType  dly,
const uint  x,
const uint  y,
const Image< PixRGB< byte > > &  img 
)

overlay an small patch onto a video and copy it to the current

Definition at line 1466 of file SDLdisplay.C.

References displayYUVoverlay(), VideoFrame::getBuffer(), getDims(), VideoFrame::getDims(), VideoFrame::getMode(), Dims::h(), lockYUVoverlay(), toVideoYUV422(), unlockYUVoverlay(), and Dims::w().

void SDLdisplay::displayVideoOverlay_pos ( const VideoFrame buf,
const int  frame,
const DelayType  w,
const int  x,
const int  y,
const int  rw,
const int  rh 
)

copy video data to the current YUV overlay, and display it

Definition at line 1265 of file SDLdisplay.C.

References displayYUVoverlay(), VideoFrame::getBuffer(), getDims(), VideoFrame::getDims(), VideoFrame::getMode(), Dims::h(), lockYUVoverlay(), unlockYUVoverlay(), and Dims::w().

void SDLdisplay::displayYUVoverlay ( const int  frame,
const DelayType  w 
)
void SDLdisplay::displayYUVoverlay ( const int  frame,
const DelayType  dly,
const int  x,
const int  y,
const int  w,
const int  h 
)
int SDLdisplay::getBytesPerPixel (  )  const [inline]

Get bytes per pixel.

Definition at line 508 of file SDLdisplay.H.

Referenced by clearBackBuffer(), getPixel32(), and putPixel32().

Dims SDLdisplay::getDims (  )  const [inline]

Get display dimensions, in pixels.

Definition at line 496 of file SDLdisplay.H.

References OModelParam< T >::getVal(), and itsDims.

Referenced by displayVideoOverlay(), displayVideoOverlay_image(), displayVideoOverlay_patch(), and displayVideoOverlay_pos().

int SDLdisplay::getHeight ( void   )  const [inline]

Get display height, in pixels.

Definition at line 504 of file SDLdisplay.H.

References OModelParam< T >::getVal(), Dims::h(), and itsDims.

Referenced by clearScreen(), createYUVoverlay(), displayYUVoverlay(), and makeBlittableSurface().

Uint32 SDLdisplay::getPixel32 ( const int  x,
const int  y 
) const

Return the pixel value at (x, y).

Definition at line 1829 of file SDLdisplay.C.

References getBytesPerPixel().

PixRGB< byte > SDLdisplay::getRGBcolor ( const Uint32  col  )  const [inline]

Get the RGB color triplet corresponding to a given Uint32 color.

Definition at line 516 of file SDLdisplay.H.

std::string SDLdisplay::getString ( char  terminator = '\n'  ) 

store the string of keypresses input by the user until the terminating character has been reached

Definition at line 780 of file SDLdisplay.C.

References waitForKey().

Uint32 SDLdisplay::getUint32color ( const PixRGB< byte > &  col  )  const [inline]
int SDLdisplay::getWidth ( void   )  const [inline]

Get display width, in pixels.

Definition at line 500 of file SDLdisplay.H.

References OModelParam< T >::getVal(), itsDims, and Dims::w().

Referenced by clearScreen(), createYUVoverlay(), displayYUVoverlay(), and makeBlittableSurface().

bool SDLdisplay::hasYUVoverlay (  )  const

Check whether somebody has already created a YUV overlay for this display.

Definition at line 941 of file SDLdisplay.C.

void SDLdisplay::lockScreen (  )  [inline]

Lock the screen, as required before using some functions.

Definition at line 527 of file SDLdisplay.H.

Referenced by clearBackBuffer().

SDL_Overlay * SDLdisplay::lockYUVoverlay (  ) 

Lock YUV overlay and get a pointer to it for direct access to pixel data.

And what can you do with the pixel data? see psycho-movie.C and pvisionTCP3-master.C for examples of how to fill it from either raw MPEG movie frames or from an Image<PixRGB<byte> >.

Definition at line 993 of file SDLdisplay.C.

Referenced by displayVideoOverlay(), displayVideoOverlay_image(), displayVideoOverlay_patch(), and displayVideoOverlay_pos().

SDL_Surface * SDLdisplay::makeBlittableSurface ( const Image< PixRGB< byte > > &  img,
const bool  resiz = false,
const PixRGB< byte bgcol = PixRGB<byte>(0, 0, 0) 
)

Make a blittable surface from an Image.

The resulting surface can be displayed using displaySurface(). It should be freed using SDL_FreeSurface()

Parameters:
img the image to be displayed
resiz if true, the image will be resized such as to fill-up at least one dimension of the display (but aspect ratio will be maintained, and possible borders filled with bgcol)
bgcol background color to use around image if image has different aspect ratio from screen

Draw a filled rectangle with white

Definition at line 805 of file SDLdisplay.C.

References ASSERT, Image< T >::clear(), drawFilledRect(), Image< T >::getArrayPtr(), Image< T >::getBounds(), Image< T >::getDims(), getHeight(), Image< T >::getHeight(), OModelParam< T >::getVal(), Image< T >::getWidth(), getWidth(), image, inplaceEmbed(), inplacePaste(), Rectangle::isValid(), itsDims, and NO_INIT.

Referenced by displayImage(), and PsychoDisplay::displayMovingDotTrain().

void SDLdisplay::openDisplay (  ) 

open a SDL display

Definition at line 413 of file SDLdisplay.C.

References clearScreen(), OModelParam< T >::getVal(), Dims::h(), itsDims, itsFullscreen, SDLFATAL, showCursor(), and Dims::w().

void SDLdisplay::pushEvent ( const std::string msg  )  [inline]
void SDLdisplay::pushEventBegin ( const std::string msg  )  [inline]
void SDLdisplay::pushEventEnd ( const std::string msg  )  [inline]
void SDLdisplay::putPixel32 ( const int  x,
const int  y,
const Uint32  pixel 
)

Set the pixel at (x, y) to the given value.

Definition at line 1859 of file SDLdisplay.C.

References getBytesPerPixel().

Referenced by PsychoDisplay::drawCloud(), and PsychoDisplay::drawClouds().

void SDLdisplay::setDesiredRefreshDelayUsec ( float  usec,
float  tol = 0.05F 
)

Set a desired refresh delay in microseconds, and a fractional tolerance around that delay.

Definition at line 1820 of file SDLdisplay.C.

References itsRefreshDelay, and OModelParam< T >::setVal().

void SDLdisplay::setEventLog ( nub::soft_ref< EventLog elog  ) 

Link us to an EventLog component.

If an EventLog component is registered with us, we will send it lots of event messages, each time a frame or overlay is displayed, a key pressed, etc.

Definition at line 409 of file SDLdisplay.C.

void SDLdisplay::showCursor ( const bool  showit  )  [inline]

Show or hide mouse pointer.

Definition at line 520 of file SDLdisplay.H.

Referenced by openDisplay(), and start2().

void SDLdisplay::start2 (  )  [protected, virtual]
void SDLdisplay::stop1 (  )  [protected, virtual]

get stopped

Reimplemented from ModelComponent.

Definition at line 592 of file SDLdisplay.C.

References closeDisplay().

bool SDLdisplay::supportsVideoOverlay ( const VideoFormat  vidformat  )  const

test whether we can do video overlays in the given frame format

Definition at line 1162 of file SDLdisplay.C.

void SDLdisplay::unlockScreen (  )  [inline]

Unlock the (previously locked) screen.

Definition at line 536 of file SDLdisplay.H.

Referenced by clearBackBuffer().

void SDLdisplay::unlockYUVoverlay (  ) 
int SDLdisplay::waitForKey ( bool  doWait = true  ) 

wait for a keypress and return character for key pressed

by default stdin is cleared try waitForKey(false) to keep stdin buffer

Definition at line 662 of file SDLdisplay.C.

References checkForKey(), pushEventBegin(), pushEventEnd(), and sformat().

Referenced by PsychoDisplay::displayEyeTrackerCalibration(), PsychoDisplay::displaySmoothPursuitGroupCalibration(), and getString().

int SDLdisplay::waitForKeyTimeout ( double  timeout = 1000,
bool  doWait = true 
)

wait for a keypress and return character for key pressed

by default stdin is cleared try waitForKey(false) to keep stdin buffer

Definition at line 636 of file SDLdisplay.C.

References checkForKey(), Timer::getSecs(), pushEventBegin(), pushEventEnd(), and sformat().

int SDLdisplay::waitForMouseClick ( bool  doWait = true  ) 

wait for a mouseclick and return 1 for left button click and 2 for right button click

by default stdin is cleared try waitForMouseClick(false) to keep stdin buffer

Definition at line 683 of file SDLdisplay.C.

References checkForMouseClick(), pushEvent(), pushEventBegin(), and sformat().

Referenced by PsychoDisplay::displayEyeTrackerCalibration().

void SDLdisplay::waitFrames ( const int  n  ) 

Wait for a number of frame periods.

This just repeatedly calles waitNextRequestedVsync()

Definition at line 1814 of file SDLdisplay.C.

References waitNextRequestedVsync().

void SDLdisplay::waitNextRequestedFrameTime ( const int  frame,
const bool  checkdelay = false,
const bool  quiet = true 
)

Wait for the next frame time, per our frame rate.

Definition at line 1731 of file SDLdisplay.C.

References ASSERT, Timer::get(), OModelParam< T >::getVal(), itsRefreshDelay, log(), max(), pushEventBegin(), pushEventEnd(), Timer::reset(), and sformat().

Referenced by displayYUVoverlay().

void SDLdisplay::waitNextRequestedVsync ( const bool  checkdelay = false,
const bool  quiet = true 
)

Wait until start of the next vertical blanking, per our frame rate.

The vertical blanking period is when the monitor's electron gun travels from the bottom of the screen back to the top. This function updates our itsLastSync data member with current time at start of vertical blanking pulse. Most display functions have a 'vsync' argument and will call this function to perform the sync, so you usually never have to call this directly. It is provided here just in case. If checkdelay is true, we will log a warning if it has been more than one itsRefreshDelay period since the last time we were called. No logging is made if quiet is true, otherwise start and end times are logged.

NOTE that this does not necessarily wait for just the next hardware vsync; instead we wait for the next hardware vsync that just precedes our next desired frame according to itsRefreshDelay. So even though your monitor may run at 60Hz or 120Hz, if itsRefreshDelay is 33333us, your actual displayed frame rate will only be 30Hz when you use waitNextRequestedVsync().

Definition at line 1650 of file SDLdisplay.C.

References Timer::get(), OModelParam< T >::getVal(), itsPriority, itsRefreshDelay, itsVBlankKludge, pushEventBegin(), pushEventEnd(), and sformat().

Referenced by PsychoDisplay::displayColorDotFixationBlink(), PsychoDisplay::displayEyeTrackerCalibration(), PsychoDisplay::displayFixationBlink(), PsychoDisplay::displayFixationIconBlink(), displayImagePatch(), PsychoDisplay::displayMovingDotBackground(), PsychoDisplay::displayMovingDotTrain(), PsychoDisplay::displayRedDotFixationBlink(), displaySDLSurfacePatch(), PsychoDisplay::displaySmoothPursuitCalibration(), PsychoDisplay::displaySmoothPursuitFancyTrace(), displaySurface(), displayYUVoverlay(), and waitFrames().


Member Data Documentation

whether to run in a fullscreen window

Definition at line 460 of file SDLdisplay.H.

Referenced by openDisplay(), and start2().

priority for SCHED_FIFO, or 0 for normal

Definition at line 458 of file SDLdisplay.H.

Referenced by closeDisplay(), start2(), and waitNextRequestedVsync().

desired refresh delay in usec

Definition at line 459 of file SDLdisplay.H.

Referenced by displayYUVoverlay(), setDesiredRefreshDelayUsec(), start2(), waitNextRequestedFrameTime(), and waitNextRequestedVsync().

slave mode (someone else opens screen)

Definition at line 461 of file SDLdisplay.H.

Referenced by closeDisplay(), and start2().

patch for syncing with photodiode

Definition at line 463 of file SDLdisplay.H.

Referenced by start2().

workaround for non-working vblank

Definition at line 462 of file SDLdisplay.H.

Referenced by start2(), and waitNextRequestedVsync().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:43:47 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3