1 // all needed include files
2 #ifdef OSG_BUILD_ACTIVE
5 #include <OSGSimpleGeometry.h>
6 #include <OSGGLUTWindow.h>
7 #include <OSGSimpleSceneManager.h>
9 // these headers are need for textures and images
10 #include <OSGSimpleTexturedMaterial.h>
13 #include <OpenSG/OSGGLUT.h>
14 #include <OpenSG/OSGConfig.h>
15 #include <OpenSG/OSGSimpleGeometry.h>
16 #include <OpenSG/OSGGLUTWindow.h>
17 #include <OpenSG/OSGSimpleSceneManager.h>
19 // these headers are need for textures and images
20 #include <OpenSG/OSGSimpleTexturedMaterial.h>
21 #include <OpenSG/OSGImage.h>
24 OSG::SimpleSceneManagerRefPtr mgr
;
25 OSG::NodeRecPtr scene
;
27 int setupGLUT( int *argc
, char *argv
[] );
29 OSG::NodeRecPtr
createScenegraph(void)
31 // the scene must be created here
33 //create the geometry which we will assign a texture to
34 OSG::GeometryRecPtr boxGeo
= OSG::makeBoxGeo(10,10,10,1,1,1);
36 //Load the image we want to use as a texture
37 OSG::ImageRecPtr image
= OSG::Image::create();
38 image
->read("Data/bricks.jpg");
40 //now we create the texture that will hold the image
41 OSG::SimpleTexturedMaterialRecPtr tex
=
42 OSG::SimpleTexturedMaterial::create();
46 //now assign the fresh texture to the geometry
47 boxGeo
->setMaterial(tex
);
49 // Create the node that will hold our geometry
50 OSG::NodeRecPtr n
= OSG::Node::create();
53 return OSG::NodeTransitPtr(n
);
56 int main(int argc
, char **argv
)
58 OSG::osgInit(argc
,argv
);
61 int winid
= setupGLUT(&argc
, argv
);
62 OSG::GLUTWindowRecPtr gwin
= OSG::GLUTWindow::create();
63 gwin
->setGlutId(winid
);
66 scene
= createScenegraph();
68 mgr
= OSG::SimpleSceneManager::create();
69 mgr
->setWindow(gwin
);
81 void reshape(int w
, int h
)
92 void mouse(int button
, int state
, int x
, int y
)
95 mgr
->mouseButtonRelease(button
, x
, y
);
97 mgr
->mouseButtonPress(button
, x
, y
);
102 void motion(int x
, int y
)
104 mgr
->mouseMove(x
, y
);
108 int setupGLUT(int *argc
, char *argv
[])
110 glutInit(argc
, argv
);
111 glutInitDisplayMode(GLUT_RGB
| GLUT_DEPTH
| GLUT_DOUBLE
);
113 int winid
= glutCreateWindow("OpenSG First Application");
115 glutDisplayFunc(display
);
116 glutMouseFunc(mouse
);
117 glutMotionFunc(motion
);
118 glutReshapeFunc(reshape
);
119 glutIdleFunc(display
);