[coin3] 10/58: Add autopkgtests.
Anton Gladky
gladk at moszumanska.debian.org
Tue Dec 26 23:52:48 UTC 2017
This is an automated email from the git hooks/post-receive script.
gladk pushed a commit to branch experimental
in repository coin3.
commit c558799c6afa828ed6fdbfdb0572f0c1ec39eb00
Author: Anton Gladky <gladk at debian.org>
Date: Sat May 10 22:45:17 2014 +0200
Add autopkgtests.
---
debian/control | 1 +
debian/tests/build1 | 241 ++++++++++++++++++++++++++++++++++++++
debian/tests/build2 | 325 +++++++++++++++++++++++++++++++++++++++++++++++++++
debian/tests/build3 | 311 ++++++++++++++++++++++++++++++++++++++++++++++++
debian/tests/control | 2 +
5 files changed, 880 insertions(+)
diff --git a/debian/control b/debian/control
index 7de6399..445601c 100644
--- a/debian/control
+++ b/debian/control
@@ -20,6 +20,7 @@ Standards-Version: 3.9.4
Homepage: https://bitbucket.org/Coin3D/coin/
Vcs-Git: git://git.debian.org/git/debian-science/packages/coin3.git
Vcs-Browser: http://git.debian.org/?p=debian-science/packages/coin3.git
+XS-Testsuite: autopkgtest
Package: libcoin80
Architecture: any
diff --git a/debian/tests/build1 b/debian/tests/build1
new file mode 100755
index 0000000..d4d15c0
--- /dev/null
+++ b/debian/tests/build1
@@ -0,0 +1,241 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > demo.cpp
+/* Simple example that demonstrates how to generate a texture based on
+ * a rendered scene, using offscreen rendering. Based on glutiv.cpp
+ * by Morten Eriksen and 09.2.Texture.cpp.in from the Inventor Mentor.
+ *
+ * Note: This example uses GLUT, so you do not need to have any of the
+ * SoGUI libraries installed. If you have a working Coin installation,
+ * you should be able to build the example as follows:
+ *
+ * UNIX:
+ * coin-config --build glut_tex glut_tex.cpp -lglut3
+ *
+ * Windows:
+ * coin-config --build glut_tex glut_tex.cpp -lglut32
+ *
+ * Mac OS X:
+ *
+ * export LDFLAGS="-framework GLUT"
+ * coin-config --build glut_tex glut_tex.cpp
+ */
+
+#include <Inventor/SoDB.h>
+#include <Inventor/SoInput.h>
+#include <Inventor/SoSceneManager.h>
+#include <Inventor/SoOffscreenRenderer.h>
+#include <Inventor/nodes/SoCube.h>
+#include <Inventor/nodes/SoTexture2.h>
+#include <Inventor/nodes/SoDirectionalLight.h>
+#include <Inventor/nodes/SoSeparator.h>
+#include <Inventor/nodes/SoMaterial.h>
+#include <Inventor/nodes/SoPerspectiveCamera.h>
+#include <Inventor/nodes/SoRotationXYZ.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
+#include <GL/glut.h>
+#endif
+
+// ----------------------------------------------------------------------
+
+SoSceneManager * scenemanager;
+int glutwin;
+
+static char red_cone_iv[] = {
+ "#Inventor V2.1 ascii\n\n"
+ "Separator {\n"
+ " BaseColor { rgb 0.8 0 0 }\n"
+ " Rotation { rotation 1 1 0 1.57 }\n"
+ " Cone { }\n"
+ "}\n"
+};
+
+
+// ----------------------------------------------------------------------
+
+// Redraw on scenegraph changes.
+void
+redraw_cb(void * user, SoSceneManager * manager)
+{
+ glutSetWindow(glutwin);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ scenemanager->render();
+ glutSwapBuffers();
+}
+
+// Redraw on expose events.
+void
+expose_cb(void)
+{
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ scenemanager->render();
+ glutSwapBuffers();
+}
+
+// Reconfigure on changes to window dimensions.
+void
+reshape_cb(int w, int h)
+{
+ int idx = glutGetWindow();
+
+ scenemanager->setWindowSize(SbVec2s(w, h));
+ scenemanager->setSize(SbVec2s(w, h));
+ scenemanager->setViewportRegion(SbViewportRegion(w, h));
+ scenemanager->scheduleRedraw();
+}
+
+// Process the internal Coin queues when idle. Necessary to get the
+// animation to work.
+void
+idle_cb(void)
+{
+ SoDB::getSensorManager()->processTimerQueue();
+ SoDB::getSensorManager()->processDelayQueue(TRUE);
+}
+
+// ----------------------------------------------------------------------
+
+SbBool
+generateTextureMap (SoNode *root, SoTexture2 *texture,
+ short textureWidth, short textureHeight)
+{
+ SbViewportRegion myViewport(textureWidth, textureHeight);
+ SoOffscreenRenderer::Components comp = SoOffscreenRenderer::RGB;
+
+ // Render the scene
+ SoOffscreenRenderer *myRenderer = new SoOffscreenRenderer(myViewport);
+ myRenderer->setComponents(comp);
+ myRenderer->setBackgroundColor(SbColor(0.8, 0.8, 0.0));
+ if (!myRenderer->render(root)) {
+ delete myRenderer;
+ return FALSE;
+ }
+
+ // Generate the texture
+ texture->image.setValue(SbVec2s(textureWidth, textureHeight), comp,
+ myRenderer->getBuffer());
+ delete myRenderer;
+ return TRUE;
+}
+
+SoSeparator *
+createScenegraph(void)
+{
+ SoSeparator * texroot = new SoSeparator;
+ texroot->ref();
+ SoInput in;
+ in.setBuffer(red_cone_iv, strlen(red_cone_iv));
+
+ SoSeparator * result = SoDB::readAll(&in);
+ if (result == NULL) { exit(1); }
+
+ SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
+ SoRotationXYZ *rot = new SoRotationXYZ;
+ rot->axis = SoRotationXYZ::X;
+ rot->angle = M_PI_2;
+ myCamera->position.setValue(SbVec3f(-0.2, -0.2, 2.0));
+ myCamera->scaleHeight(0.4);
+ texroot->addChild(myCamera);
+ texroot->addChild(new SoDirectionalLight);
+ texroot->addChild(rot);
+ texroot->addChild(result);
+ myCamera->viewAll(texroot, SbViewportRegion());
+
+ // Generate the texture map
+ SoTexture2 *texture = new SoTexture2;
+ texture->ref();
+ if (generateTextureMap(texroot, texture, 128, 128))
+ printf ("Successfully generated texture map\n");
+ else
+ printf ("Could not generate texture map\n");
+ texroot->unref();
+
+ // Make a scene with a cube and apply the texture to it
+ SoSeparator * root = new SoSeparator;
+ root->addChild(texture);
+ root->addChild(new SoCube);
+ return root;
+}
+
+// ----------------------------------------------------------------------
+
+#ifdef _WIN32
+
+#include <windows.h>
+#include <winbase.h>
+
+int
+WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
+ int nCmdShow)
+{
+#else // UNIX
+
+int
+main(int argc, char ** argv)
+{
+
+#endif
+
+ // initialize Coin and glut libraries
+ SoDB::init();
+
+#ifdef _WIN32
+ int argc = 1;
+ char * argv[] = { "glutiv.exe", (char *) NULL };
+ glutInit(&argc, argv);
+#else
+ glutInit(&argc, argv);
+#endif
+
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
+
+ SoSeparator * root;
+ root = new SoSeparator;
+ root->ref();
+ SoPerspectiveCamera * camera = new SoPerspectiveCamera;
+ root->addChild(camera);
+ root->addChild(new SoDirectionalLight);
+ root->addChild(createScenegraph());
+
+ scenemanager = new SoSceneManager;
+ scenemanager->setRenderCallback(redraw_cb, (void *)1);
+ scenemanager->setBackgroundColor(SbColor(0.2f, 0.2f, 0.2f));
+ scenemanager->activate();
+ camera->viewAll(root, scenemanager->getViewportRegion());
+ scenemanager->setSceneGraph(root);
+
+ glutInitWindowSize(512, 400);
+ SbString title("Offscreen Rendering");
+ glutwin = glutCreateWindow(title.getString());
+ glutDisplayFunc(expose_cb);
+ glutReshapeFunc(reshape_cb);
+
+ // start main loop processing (with an idle callback)
+
+ glutIdleFunc(idle_cb);
+ //glutMainLoop();
+
+ root->unref();
+ delete scenemanager;
+ return 0;
+}
+
+EOF
+
+g++ -I/usr/include -lGL -lGLU -lglut -lCoin -o demo demo.cpp
+echo "build: OK"
+[ -x demo ]
+xvfb-run --auth-file=a ./demo
+echo "run: OK"
diff --git a/debian/tests/build2 b/debian/tests/build2
new file mode 100755
index 0000000..2b7dd90
--- /dev/null
+++ b/debian/tests/build2
@@ -0,0 +1,325 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > demo.cpp
+/**************************************************************************\
+ * Copyright (c) Kongsberg Oil & Gas Technologies AS
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\**************************************************************************/
+
+// *************************************************************************
+
+// glxiv.cpp -- example demonstrating Coin (or Open Inventor) bound
+// directly into GLX/X11. Useful e.g. as a starting point if one wants
+// to make an X11 application that doesn't depend on SoXt.
+//
+
+// If you have Coin properly installed, you should be able to build by
+// simply doing:
+//
+// $ coin-config --build glxiv glxiv.cpp
+//
+
+// *************************************************************************
+
+// FIXME: note that there are some limitations to this example:
+//
+// * The most important one is that events are not translated from
+// native X11 events to Coin events (to be sent to the scene
+// graph). This means that for instance draggers and manipulators in
+// the scene graph will not respond to attempts at interaction.
+//
+// * The sensor queue processing is just a hack. Don't use this
+// in production code.
+//
+// 20031113 mortene.
+
+// *************************************************************************
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <GL/gl.h>
+#include <GL/glx.h>
+
+#include <Inventor/SbTime.h>
+#include <Inventor/SoDB.h>
+#include <Inventor/SoInteraction.h>
+#include <Inventor/SoSceneManager.h>
+#include <Inventor/nodekits/SoNodeKit.h>
+#include <Inventor/nodes/SoDirectionalLight.h>
+#include <Inventor/nodes/SoPerspectiveCamera.h>
+#include <Inventor/nodes/SoRotor.h>
+#include <Inventor/nodes/SoSeparator.h>
+#include <Inventor/nodes/SoText3.h>
+
+// *************************************************************************
+
+typedef struct {
+ Display * display;
+ Window window;
+ GLXContext context;
+
+ SoSceneManager * scenemanager;
+} WindowData;
+
+// *************************************************************************
+
+SbTime * starttime = NULL;
+unsigned int rendercounter = 0;
+static SoSeparator * root = NULL;
+
+static void
+draw_scene(void * userdata, SoSceneManager * scenemanager)
+{
+ if (starttime->getValue() == 0) { *starttime = SbTime::getTimeOfDay(); }
+
+ // FIXME: should set near and far planes properly before
+ // rendering. 20031113 mortene.
+
+ scenemanager->render();
+
+ WindowData * win = (WindowData *)userdata;
+ glXSwapBuffers(win->display, win->window);
+
+ rendercounter++;
+ SbTime currenttime = SbTime::getTimeOfDay();
+ SbTime interval = currenttime - *starttime;
+ if (interval > 1.0) {
+ (void)fprintf(stdout, "fps %f\n", rendercounter / interval.getValue());
+ *starttime = currenttime;
+ rendercounter = 0;
+ }
+}
+
+// *************************************************************************
+
+static void
+make_glx_window(WindowData * win,
+ int x, int y, unsigned int width, unsigned int height)
+{
+ int attrib[] = {
+ GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DEPTH_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ None
+ };
+
+
+ const int scrnum = DefaultScreen(win->display);
+ const Window rootwindow = RootWindow(win->display, scrnum);
+
+ XVisualInfo * visinfo = glXChooseVisual(win->display, scrnum, attrib);
+ if (!visinfo) {
+ (void)fprintf(stderr, "Error: couldn't get an RGB, double-buffered visual.\n");
+ exit(1);
+ }
+
+ XSetWindowAttributes attr;
+ attr.background_pixel = 0;
+ attr.border_pixel = 0;
+ attr.colormap = XCreateColormap(win->display, rootwindow, visinfo->visual, AllocNone);
+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+ unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+ win->window = XCreateWindow(win->display, rootwindow, 0, 0, width, height,
+ 0, visinfo->depth, InputOutput,
+ visinfo->visual, mask, &attr);
+
+ {
+ XSizeHints sizehints;
+ sizehints.x = x;
+ sizehints.y = y;
+ sizehints.width = width;
+ sizehints.height = height;
+ sizehints.flags = USSize | USPosition;
+ XSetNormalHints(win->display, win->window, &sizehints);
+ const char * name = "Coin in GLX";
+ XSetStandardProperties(win->display, win->window, name, name,
+ None, (char **)NULL, 0, &sizehints);
+ }
+
+ win->context = glXCreateContext(win->display, visinfo, NULL, True);
+ if (!win->context) {
+ (void)fprintf(stderr, "Error: glXCreateContext() failed.\n");
+ exit(1);
+ }
+
+ XFree(visinfo);
+}
+
+// *************************************************************************
+
+static void
+event_loop(WindowData * win)
+{
+ while (1) {
+ static long mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+ XEvent event;
+ while (XCheckWindowEvent(win->display, win->window, mask, &event)) {
+ if (event.xany.window == win->window) {
+ switch (event.type) {
+
+ case Expose:
+ draw_scene(win, win->scenemanager);
+ break;
+
+ case ConfigureNotify:
+ {
+ const int w = event.xconfigure.width;
+ const int h = event.xconfigure.height;
+
+ win->scenemanager->setWindowSize(SbVec2s(w, h));
+ win->scenemanager->setSize(SbVec2s(w, h));
+ win->scenemanager->setViewportRegion(SbViewportRegion(w, h));
+ win->scenemanager->scheduleRedraw();
+ }
+ break;
+
+ case KeyPress:
+ {
+ char buffer[1] = "";
+ (void)XLookupString(&event.xkey, buffer, sizeof(buffer), NULL, NULL);
+ if (buffer[0] == /* Esc: */ 27) { return; }
+ }
+ break;
+ }
+ }
+ }
+
+ // FIXME: should do this properly б la SoXt, to avoid using ~100%
+ // CPU. 20031113 mortene.
+ SoDB::getSensorManager()->processTimerQueue();
+ SoDB::getSensorManager()->processDelayQueue(TRUE);
+ }
+}
+
+// *************************************************************************
+
+static void
+make_coin_scenegraph(WindowData * win)
+{
+ root = new SoSeparator;
+ root->ref();
+
+ SoPerspectiveCamera * camera = new SoPerspectiveCamera;
+ root->addChild(camera);
+
+ SoDirectionalLight * light = new SoDirectionalLight;
+ light->direction.setValue(-0.5, -0.5, 1);
+ root->addChild(light);
+
+ SoDirectionalLight * l = new SoDirectionalLight;
+ l->direction = - light->direction.getValue();
+ root->addChild(l);
+
+ SoRotor * rotor = new SoRotor;
+ rotor->rotation.setValue(SbVec3f(0, 1, 0), 0.1f);
+ rotor->speed = 0.2;
+ root->addChild(rotor);
+
+ SoText3 * text3 = new SoText3;
+ text3->string = "Coin 3D";
+ text3->justification = SoText3::CENTER;
+ text3->parts = SoText3::ALL;
+ root->addChild(text3);
+
+ win->scenemanager = new SoSceneManager;
+ win->scenemanager->setRenderCallback(draw_scene, win);
+ win->scenemanager->activate();
+ win->scenemanager->setSceneGraph(root);
+
+ camera->viewAll(root, win->scenemanager->getViewportRegion());
+}
+
+// *************************************************************************
+
+int
+main(int argc, char *argv[])
+{
+ // Initialize Coin.
+ SoDB::init();
+ SoDB::setRealTimeInterval(1/120.0);
+ SoNodeKit::init();
+ SoInteraction::init();
+
+ Display * dpy = XOpenDisplay(NULL);
+ if (!dpy) {
+ (void)fprintf(stderr, "Error: couldn't open default display.\n");
+ exit(1);
+ }
+
+ WindowData win = { dpy, 0, NULL, NULL };
+ make_glx_window(&win, 100, 100, 400, 400);
+ make_coin_scenegraph(&win);
+
+ XMapWindow(win.display, win.window);
+ glXMakeCurrent(win.display, win.window, win.context);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+
+ starttime = new SbTime(0.0);
+
+ //event_loop(&win);
+
+ delete starttime;
+
+ XDestroyWindow(win.display, win.window);
+ glXDestroyContext(win.display, win.context);
+ XCloseDisplay(win.display);
+
+ win.scenemanager->setSceneGraph(NULL);
+ root->unref();
+ SoDB::finish();
+ return 0;
+}
+
+// *************************************************************************
+
+
+EOF
+
+g++ -I/usr/include -lGL -lGLU -lglut -lCoin -lX11 -o demo demo.cpp
+echo "build: OK"
+[ -x demo ]
+xvfb-run --auth-file=a ./demo
+echo "run: OK"
diff --git a/debian/tests/build3 b/debian/tests/build3
new file mode 100755
index 0000000..5dd6120
--- /dev/null
+++ b/debian/tests/build3
@@ -0,0 +1,311 @@
+#!/bin/sh
+# autopkgtest check
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > demo.cpp
+/**************************************************************************\
+ * Copyright (c) Kongsberg Oil & Gas Technologies AS
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\**************************************************************************/
+
+// glutiv.cpp -- example demonstrating Coin (or Open Inventor) bound
+// to the GLUT user interface abstraction.
+//
+
+// If you have Coin and the GLUT library properly installed, you should
+// be able to build by simply doing:
+//
+// $ coin-config --build glutiv glutiv.cpp -lglut
+//
+// (or -lglut32 if you're on MSWindows with Cygwin).
+//
+// Note that to compile on Mac OS X, you have to link against the
+// GLUT framework, like so:
+//
+// $ export LDFLAGS="-framework GLUT -lobjc"
+// $ coin-config --build-app glutiv glutiv.cpp
+
+
+// *************************************************************************
+
+// FIXME: note that there are some limitations to this example:
+//
+// * The most important one is that events are not translated from
+// native X11 events to Coin events (to be sent to the scene
+// graph). This means that for instance draggers and manipulators in
+// the scene graph will not respond to attempts at interaction.
+//
+// * The sensor queue processing is just a hack. Don't use this
+// in production code.
+//
+// 20031113 mortene.
+
+// *************************************************************************
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
+#include <GL/glut.h>
+#endif
+
+#include <Inventor/SoDB.h>
+#include <Inventor/SoInteraction.h>
+#include <Inventor/SoSceneManager.h>
+#include <Inventor/nodekits/SoNodeKit.h>
+#include <Inventor/nodes/SoCylinder.h>
+#include <Inventor/nodes/SoDirectionalLight.h>
+#include <Inventor/nodes/SoDrawStyle.h>
+#include <Inventor/nodes/SoSeparator.h>
+#include <Inventor/nodes/SoMaterial.h>
+#include <Inventor/nodes/SoPerspectiveCamera.h>
+#include <Inventor/nodes/SoRotor.h>
+#include <Inventor/nodes/SoShuttle.h>
+#include <Inventor/nodes/SoSphere.h>
+#include <Inventor/nodes/SoTransform.h>
+
+// *************************************************************************
+
+const int SCENEWINDOWS = 3;
+
+SoSceneManager * scenemanager[SCENEWINDOWS];
+int glutwin[SCENEWINDOWS];
+
+// *************************************************************************
+
+int
+winid2idx(const int winid)
+{
+ for (int i=0; i < SCENEWINDOWS; i++) {
+ if (winid == glutwin[i]) return i;
+ }
+}
+
+// Redraw on scenegraph changes.
+void
+redraw_cb(void * user, SoSceneManager * manager)
+{
+ unsigned int idx = (uintptr_t)user;
+
+ glutSetWindow(glutwin[idx]);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ scenemanager[idx]->render();
+
+ glutSwapBuffers();
+}
+
+// Redraw on expose events.
+void
+expose_cb(void)
+{
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ scenemanager[winid2idx(glutGetWindow())]->render();
+
+ glutSwapBuffers();
+}
+
+// Reconfigure on changes to window dimensions.
+void
+reshape_cb(int w, int h)
+{
+ int idx = winid2idx(glutGetWindow());
+
+ scenemanager[idx]->setWindowSize(SbVec2s(w, h));
+ scenemanager[idx]->setSize(SbVec2s(w, h));
+ scenemanager[idx]->setViewportRegion(SbViewportRegion(w, h));
+ scenemanager[idx]->scheduleRedraw();
+}
+
+// Process the internal Coin queues when idle. Necessary to get the
+// animation to work.
+void
+idle_cb(void)
+{
+ SoDB::getSensorManager()->processTimerQueue();
+ SoDB::getSensorManager()->processDelayQueue(TRUE);
+}
+
+// *************************************************************************
+
+// Make the common scenegraph. Just a little silly something to show
+// off some geometry nodes and simple animation.
+
+SoSeparator *
+commongraph(void)
+{
+ SoSeparator * root = NULL;
+
+ if (!root) {
+ root = new SoSeparator;
+
+ {
+ SoSeparator * cylsep = new SoSeparator;
+ root->addChild(cylsep);
+
+ SoRotor * rotor = new SoRotor;
+ rotor->speed.setValue(0.1f);
+ cylsep->addChild(rotor);
+
+ cylsep->addChild(new SoCylinder);
+ }
+
+ SoMaterial * material = new SoMaterial;
+ material->diffuseColor.setValue(0.0f, 0.0f, 0.0f);
+ root->addChild(material);
+
+ SoSphere * sphere = new SoSphere;
+
+ SoTransform * trans0 = new SoTransform;
+ trans0->translation.setValue(-0.5f, 0.5f, 1.0f);
+ trans0->scaleFactor.setValue(0.1f, 0.1f, 0.1f);
+ root->addChild(trans0);
+
+ root->addChild(sphere);
+
+ SoShuttle * shuttle = new SoShuttle;
+ shuttle->translation0.setValue(0.0f, 5.0f, 0.0f);
+ shuttle->translation1.setValue(0.0f, -5.0f, 0.0f);
+ shuttle->on.setValue(TRUE);
+ root->addChild(shuttle);
+
+ SoTransform * trans1 = new SoTransform;
+ trans1->translation.setValue(10.0f, 0.0f, 0.0f);
+ root->addChild(trans1);
+
+ root->addChild(sphere);
+ }
+
+ return root;
+}
+
+// *************************************************************************
+
+#ifdef _WIN32
+
+#include <windows.h>
+#include <winbase.h>
+
+int
+WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
+ int nCmdShow)
+
+#else // UNIX
+
+int
+main(int argc, char ** argv)
+
+#endif
+
+{
+ // initialize Coin and glut libraries
+
+ SoDB::init();
+ SoNodeKit::init();
+ SoInteraction::init();
+
+#ifdef _WIN32
+ int argc = 1;
+ char * argv[] = { "glutiv.exe", (char *) NULL };
+ glutInit(&argc, argv);
+#else
+ glutInit(&argc, argv);
+#endif
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
+
+ // Note: _don't_ use SoGroup, as TGS' Inventor has a bug where
+ // lightsource contribution will get accumulated over runs.
+ SoSeparator * root[SCENEWINDOWS];
+
+ for (unsigned int i=0; i < SCENEWINDOWS; i++) {
+ // set up individual parts of scenegraph
+
+ root[i] = new SoSeparator;
+ root[i]->ref();
+ SoPerspectiveCamera * camera = new SoPerspectiveCamera;
+ root[i]->addChild(camera);
+ root[i]->addChild(new SoDirectionalLight);
+ SoDrawStyle * drawstyle = new SoDrawStyle;
+ drawstyle->style.setValue(i % 3);
+ root[i]->addChild(drawstyle);
+ root[i]->addChild(commongraph());
+
+ // initialize scenemanager instance
+
+ scenemanager[i] = new SoSceneManager;
+ scenemanager[i]->setRenderCallback(redraw_cb, (void *)i);
+ scenemanager[i]->setBackgroundColor(SbColor(0.2f, 0.2f, i * 0.2f));
+ scenemanager[i]->activate();
+ camera->viewAll(root[i], scenemanager[i]->getViewportRegion());
+ scenemanager[i]->setSceneGraph(root[i]);
+
+ // glut window initialization
+
+ glutInitWindowSize(512, 400);
+ SbString title("window ");
+ title += (char)(i + 0x30);
+ glutwin[i] = glutCreateWindow(title.getString());
+ glutDisplayFunc(expose_cb);
+ glutReshapeFunc(reshape_cb);
+ }
+
+ SoDB::setRealTimeInterval(1/120.0);
+
+ // start main loop processing (with an idle callback)
+
+ glutIdleFunc(idle_cb);
+ //glutMainLoop();
+
+ // clean up Coin resource use
+
+ for (int j=0; j < SCENEWINDOWS; j++) {
+ root[j]->unref();
+ delete scenemanager[j];
+ }
+
+ return 0;
+}
+
+// *************************************************************************
+
+
+EOF
+
+g++ -I/usr/include -lGL -lGLU -lglut -lCoin -lX11 -o demo demo.cpp
+echo "build: OK"
+[ -x demo ]
+xvfb-run --auth-file=a ./demo
+echo "run: OK"
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..f3780c1
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,2 @@
+Tests: build1 build2 build3
+Depends: libcoin80-dev, build-essential, xvfb, xauth
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/coin3.git
More information about the debian-science-commits
mailing list