OpenVideo Documentation

   Main Page       Modules       Class Hierarchy       Alphabetical List       Compound List       File List       Compound Members       Related Pages   

openvideo::GLUTSink Class Reference
[Node Classes]

GLUTSink implements an OpenVideo node to display a certain video stream. More...

#include <GLUTSink.h>

Inherits openvideo::Node.

List of all members.

Public Member Functions

 GLUTSink ()
 ~GLUTSink ()
virtual void start ()
virtual void init ()
virtual void process ()
virtual void initPixelFormats ()
HGLRC getGLContext ()
HDC getDeviceHandle ()
Display * getDisplay ()
GLXContext getGLContext ()
GLXDrawable getDeviceHandle ()

Static Public Attributes

static std::vector< openvideo::GLUTSink * > glutSinks

Protected Types

enum  { TEXTURE_WIDTH = 1024, TEXTURE_HEIGHT = 1024 }

Protected Member Functions

void updateTexture ()
void redraw ()

Static Protected Member Functions

static void * mainLoop (void *)
static void mainDisplayFunc ()
static void idleFunc ()

Protected Attributes

int winHandle
bool updateVideo
int width
int height
int originX
int originY
int format
int internalFormat
unsigned int video_texture_id
bool flip_h
bool flip_v
float t_u0
float t_u1
float t_v0
float t_v1
BufferSynchronizer bufferSychronizer
unsigned int updateCtr
GLXDrawable dc
Display * dsp
GLXContext glContext
HGLRC glContext
HDC dc

Static Protected Attributes

static bool glutRedraw = false
static bool isGlutThread = false


Detailed Description

GLUTSink implements an OpenVideo node to display a certain video stream.

It displays the frame buffer of the context element of it's first input node as a 2dtexture which gets updated every time a traversal takes place. The glut environment runs in it's own thread. it permanently checks in it's idle function if something has changed which forces a redraw of one of the glut windows.


Supported Pixel Formats:

Definition at line 65 of file GLUTSink.h.


Member Enumeration Documentation

anonymous enum [protected]
 

maximal texture size

Enumeration values:
TEXTURE_WIDTH 
TEXTURE_HEIGHT 

Definition at line 197 of file GLUTSink.h.


Constructor & Destructor Documentation

GLUTSink::GLUTSink  ) 
 

constructor

Definition at line 72 of file GLUTSink.cxx.

References dsp, glContext, height, internalFormat, openvideo::Node::name, originX, originY, openvideo::Node::state, openvideo::Node::typeName, updateCtr, updateVideo, and width.

GLUTSink::~GLUTSink  ) 
 

destructor

Definition at line 136 of file GLUTSink.cxx.


Member Function Documentation

GLXDrawable openvideo::GLUTSink::getDeviceHandle  ) 
 

GLXDrawable GLUTSink::getDeviceHandle  ) 
 

Definition at line 96 of file GLUTSink.cxx.

References dc.

Referenced by mainDisplayFunc().

Display * GLUTSink::getDisplay  ) 
 

Definition at line 116 of file GLUTSink.cxx.

References dsp.

Referenced by mainDisplayFunc().

GLXContext openvideo::GLUTSink::getGLContext  ) 
 

GLXContext GLUTSink::getGLContext  ) 
 

Definition at line 90 of file GLUTSink.cxx.

References glContext.

Referenced by mainDisplayFunc().

void GLUTSink::idleFunc  )  [static, protected]
 

glut's idle function

Definition at line 411 of file GLUTSink.cxx.

Referenced by mainLoop().

void GLUTSink::init  )  [virtual]
 

Is called once before the (process)traversal starts.

Init should be used to implement any initializations a specific node needs.

Reimplemented from openvideo::Node.

Definition at line 205 of file GLUTSink.cxx.

References openvideo::Node::curPixelFormat, flip_h, flip_v, format, openvideo::FORMAT_B8G8R8, openvideo::FORMAT_B8G8R8X8, openvideo::FORMAT_L8, openvideo::FORMAT_R8G8B8, openvideo::FORMAT_R8G8B8X8, openvideo::PixelFormat::FormatToString(), openvideo::Manager::getInstance(), glutSinks, openvideo::State::height, height, openvideo::Node::inputs, internalFormat, openvideo::Node::name, openvideo::Node::state, t_u0, t_u1, t_v0, t_v1, TEXTURE_HEIGHT, TEXTURE_WIDTH, openvideo::State::width, and width.

void GLUTSink::initPixelFormats  )  [virtual]
 

return value = the number of supported input formats.

the formats are stored in 'pixelFormats'.

Implements openvideo::Node.

Definition at line 122 of file GLUTSink.cxx.

References openvideo::FORMAT_B8G8R8, openvideo::FORMAT_B8G8R8X8, openvideo::FORMAT_L8, openvideo::FORMAT_R8G8B8, openvideo::FORMAT_R8G8B8X8, and openvideo::Node::pixelFormats.

void GLUTSink::mainDisplayFunc  )  [static, protected]
 

glut's main display function

Definition at line 417 of file GLUTSink.cxx.

References getDeviceHandle(), getDisplay(), getGLContext(), openvideo::Manager::getInstance(), glutSinks, and winHandle.

Referenced by mainLoop().

void * GLUTSink::mainLoop void *   )  [static, protected]
 

glut's main loop

Definition at line 142 of file GLUTSink.cxx.

References dc, dsp, format, openvideo::Node::getName(), glContext, glutSinks, height, idleFunc(), internalFormat, mainDisplayFunc(), originX, originY, TEXTURE_HEIGHT, TEXTURE_WIDTH, video_texture_id, width, and winHandle.

Referenced by start().

void GLUTSink::process  )  [virtual]
 

Sets a flag which is read by glut's idle function, which afterwards calls a 'glutPostRedisplay()'.

We do it this way because glut's idle function runs in the same thread than gluts main display function. 'process()' then waits untill the main display function updates the texture with the new video data.

Reimplemented from openvideo::Node.

Definition at line 328 of file GLUTSink.cxx.

References openvideo::BufferSynchronizer::assign(), bufferSychronizer, openvideo::State::getCurrentBuffer(), and openvideo::Node::state.

void GLUTSink::redraw  )  [protected]
 

applies the texture.

postGLCalls()

Definition at line 370 of file GLUTSink.cxx.

References t_u0, t_u1, t_v0, t_v1, and video_texture_id.

void GLUTSink::start  )  [virtual]
 

sets its context to use the context of its first parent and initializes the texture paramaters.

start() also adds itself to the static list of "glutSinks", which is later used by the glut thread to access all the glutsink nodes. if the glut environment isn't up and running yet, start() will create a new thread where the main glut loop runs in.

Reimplemented from openvideo::Node.

Definition at line 304 of file GLUTSink.cxx.

References openvideo::Manager::getInstance(), isGlutThread, and mainLoop().

void GLUTSink::updateTexture  )  [protected]
 

function which updated the texture with the new video frame.

Definition at line 339 of file GLUTSink.cxx.

References bufferSychronizer, openvideo::BufferSynchronizer::getLocked(), openvideo::Buffer::getPixels(), openvideo::Buffer::getUpdateCounter(), height, openvideo::Buffer::unlock(), updateCtr, video_texture_id, and width.


Member Data Documentation

BufferSynchronizer openvideo::GLUTSink::bufferSychronizer [protected]
 

Definition at line 199 of file GLUTSink.h.

Referenced by process(), and updateTexture().

HDC openvideo::GLUTSink::dc [protected]
 

Definition at line 211 of file GLUTSink.h.

GLXDrawable openvideo::GLUTSink::dc [protected]
 

Definition at line 204 of file GLUTSink.h.

Referenced by getDeviceHandle(), and mainLoop().

Display* openvideo::GLUTSink::dsp [protected]
 

Definition at line 205 of file GLUTSink.h.

Referenced by getDisplay(), GLUTSink(), and mainLoop().

bool openvideo::GLUTSink::flip_h [protected]
 

Defines a video flip.

Definition at line 186 of file GLUTSink.h.

Referenced by init().

bool openvideo::GLUTSink::flip_v [protected]
 

Defines a video flip.

Definition at line 186 of file GLUTSink.h.

Referenced by init().

int openvideo::GLUTSink::format [protected]
 

texture format.

Definition at line 171 of file GLUTSink.h.

Referenced by init(), and mainLoop().

HGLRC openvideo::GLUTSink::glContext [protected]
 

Definition at line 210 of file GLUTSink.h.

GLXContext openvideo::GLUTSink::glContext [protected]
 

Definition at line 206 of file GLUTSink.h.

Referenced by getGLContext(), GLUTSink(), and mainLoop().

bool GLUTSink::glutRedraw = false [static, protected]
 

A flag to indicate glut's idle function we need a redraw.

Definition at line 69 of file GLUTSink.cxx.

std::vector< GLUTSink * > GLUTSink::glutSinks [static]
 

static list off all glut sinks currently running.

Definition at line 68 of file GLUTSink.cxx.

Referenced by init(), mainDisplayFunc(), and mainLoop().

int openvideo::GLUTSink::height [protected]
 

self explaining

Definition at line 166 of file GLUTSink.h.

Referenced by GLUTSink(), init(), mainLoop(), and updateTexture().

int openvideo::GLUTSink::internalFormat [protected]
 

Internal texture format.

defines the number of color components in the texture. valid values = 1,2,3, or 4.

Definition at line 176 of file GLUTSink.h.

Referenced by GLUTSink(), init(), and mainLoop().

bool GLUTSink::isGlutThread = false [static, protected]
 

A flag to prevent multiple calls to start the glut environment.

Definition at line 67 of file GLUTSink.cxx.

Referenced by start().

int openvideo::GLUTSink::originX [protected]
 

self explaining

Definition at line 166 of file GLUTSink.h.

Referenced by GLUTSink(), and mainLoop().

int openvideo::GLUTSink::originY [protected]
 

self explaining

Definition at line 166 of file GLUTSink.h.

Referenced by GLUTSink(), and mainLoop().

float openvideo::GLUTSink::t_u0 [protected]
 

Define the current ratio of the max.

texture size and the current video size.

Definition at line 191 of file GLUTSink.h.

Referenced by init(), and redraw().

float openvideo::GLUTSink::t_u1 [protected]
 

Define the current ratio of the max.

texture size and the current video size.

Definition at line 191 of file GLUTSink.h.

Referenced by init(), and redraw().

float openvideo::GLUTSink::t_v0 [protected]
 

Definition at line 192 of file GLUTSink.h.

Referenced by init(), and redraw().

float openvideo::GLUTSink::t_v1 [protected]
 

Definition at line 192 of file GLUTSink.h.

Referenced by init(), and redraw().

unsigned int openvideo::GLUTSink::updateCtr [protected]
 

Definition at line 200 of file GLUTSink.h.

Referenced by GLUTSink(), and updateTexture().

bool openvideo::GLUTSink::updateVideo [protected]
 

A flag to indicate this sink needs an update of it's video texture.

it is set in the 'process()' function and used by the main window function to find the sink which invokes the redraw.

Definition at line 151 of file GLUTSink.h.

Referenced by GLUTSink().

unsigned int openvideo::GLUTSink::video_texture_id [protected]
 

open gl's texture id

Definition at line 181 of file GLUTSink.h.

Referenced by mainLoop(), redraw(), and updateTexture().

int openvideo::GLUTSink::width [protected]
 

self explaining

Definition at line 166 of file GLUTSink.h.

Referenced by GLUTSink(), init(), mainLoop(), and updateTexture().

int openvideo::GLUTSink::winHandle [protected]
 

The sinks window handle.

Definition at line 145 of file GLUTSink.h.

Referenced by mainDisplayFunc(), and mainLoop().


The documentation for this class was generated from the following files:
 This page was generated at Wed May 31 13:04:18 2006 for OpenVideo by Doxygen.
 If you have any comments, please send a message to schmalstieg@icg.tu-graz.ac.at.
www.studierstube.org