File: example1.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 (47 lines) | stat: -rw-r--r-- 1,411 bytes parent folder | download | duplicates (2)
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
42
43
44
45
46
47
//C++ source file - Open Producer - Copyright (C) 2002 Don Burns
//Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)
//as published by the Free Software Foundation.

// Simple example of use of Producer::RenderSurface
// The MyGraphics class is a simple sample of how one would implement
// graphics drawing with Producer::RenderSurface

#include <Producer/RenderSurface>
#include "MyGraphics"

int main(int argc, char **argv )
{
    // Declare a RenderSurface
    Producer::ref_ptr<Producer::RenderSurface> rs = new Producer::RenderSurface;

    // Optional.  Set the window size.  
    // Arguments are x, y, width, height
    // If this call is not made, the RenderSurface
    // will occupy the entire screen with no border
    rs->setWindowRectangle( 100, 100, 640, 480 );
    // Give the window a name in the border
    rs->setWindowName( "Producer Example using Render Surface" );

    // required.  This creates the window and
    // sets up the graphics context.
    rs->realize();

    // Add your own rendering code.
    MyGraphics gfx(*rs.get());
    gfx.init();

    while( rs->isRealized() )
    {
       	// If possible, RenderSurface will synchronize
    	// the application run-time to the vertical 
        // retrace signal
    	// rs->sync();

    	// Call your own draw routine
    	gfx.draw();

    	// Swap Buffers
    	rs->swapBuffers();
    }
    return 0;
}