File: example2.cpp

package info (click to toggle)
openscenegraph 1.2.0-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 26,924 kB
  • ctags: 25,229
  • sloc: cpp: 239,326; ansic: 2,178; sh: 1,990; yacc: 548; perl: 237; makefile: 227; lex: 151
file content (41 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <string>
#include <Producer/CameraConfig>
#include <Producer/CameraGroup>
#include "MySceneHandler"

int main( int argc, char **argv )
{
    Producer::ref_ptr<Producer::CameraGroup> cg;
	std::string configFileName;

	if( argc > 1 )
		configFileName = argv[1];

	if( configFileName.empty() )
	{
		cg = new Producer::CameraGroup;
	}
	else
	{
        Producer::ref_ptr<Producer::CameraConfig> cfg = new Producer::CameraConfig;
		if( cfg->parseFile( configFileName.c_str() ) == false )
        {
            std::cerr << argv[0] << ": Failed to parse config file " << configFileName << std::endl;
			return 1;
        }
		cg  = new Producer::CameraGroup( cfg.get() );
	}

	for( unsigned int i = 0; i < cg->getNumberOfCameras(); i++ )
        cg->getCamera(i)->setSceneHandler(new MySceneHandler);

//	cg->realize( Producer::CameraGroup::ThreadPerCamera );
	cg->realize( Producer::CameraGroup::SingleThreaded );

	while( cg->validForRendering() )
	{
		cg->sync();
		cg->frame();
	}
}