Open/Close of Multiple Windows

New Message Reply Date view Thread view Subject view Author view

tmartin++at++metricsys.com
Mon, 28 Dec 1998 17:37:08 -0600 (CST)


To whom it may concern:
        I am having problems opening and closing multiple windows with
Performer 2.2. I have attached a small C++ program and Makefile that works
fine when compiled under Performer 2.1. But has multiple errors if compiled
under Performer 2.2. The platform I'm running on is an Octane running IRIX
6.4 with dual processors. When it is run with the call
        pfMultiprocess( PMFP_DEFAULT);
I get 8 pfMemory::unrefGetRef() Attempt to unreference memory with 0
reference count. Then tons of pfMemory::copy() 0x645f6300 is not a pfMemory *.

        When this program is run with the call:
        pfMultiprocess(PMFP_APPCULLDRAW);
I just get 8 pfMemory::unrefGetRef() Attempt to unreference memory with 0
reference count.

I need to be able to use Performer multiprocessing ability. If anyone knows
how to open and close multiple pipewindow with multiple channels, while
multiprocessing please let me know what i'm doing wrong.

Thanks

//
// Copyright 1995, Silicon Graphics, Inc.
// ALL RIGHTS RESERVED
//
// UNPUBLISHED -- Rights reserved under the copyright laws of the United
// States. Use of a copyright notice is precautionary only and does not
// imply publication or disclosure.
//
// U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
// Use, duplication or disclosure by the Government is subject to restrictions
// as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
// in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
// in similar or successor clauses in the FAR, or the DOD or NASA FAR
// Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
// 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
//
// Permission to use, copy, modify, distribute, and sell this software
// and its documentation for any purpose is hereby granted without
// fee, provided that (i) the above copyright notices and this
// permission notice appear in all copies of the software and related
// documentation, and (ii) the name of Silicon Graphics may not be
// used in any advertising or publicity relating to the software
// without the specific, prior written permission of Silicon Graphics.
//
// THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
// EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
// WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
//
// IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
// INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
// DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
// WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY
// THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
// OR PERFORMANCE OF THIS SOFTWARE.
//
//
// multiwinC.C: Performer program to demonstrate multiple windows
// in one pipe. Derived from simple.c
//
// $Revision: 1.10 $
// $Date: 1995/11/22 14:35:15 $
//
//

#include <stdlib.h>

#include <Performer/pf/pfChannel.h>
#include <Performer/pf/pfScene.h>
#include <Performer/pf/pfLightSource.h>
#include <Performer/pr/pfLight.h>

#include <Performer/pfdu.h>

static void OpenPipeWin(pfPipeWindow *pw);
static void ClosePipeWin(pfPipeWindow *pw);

//
// Usage() -- print usage advice and exit. This
// procedure is executed in the application process.
//
static void
Usage (void)
{
    pfNotify(PFNFY_FATAL, PFNFY_USAGE, "Usage: multiwinC file.ext ...\n");
    exit(1);
}

int
main (int argc, char *argv[])
{
    float t = 0.0f;
    pfPipeWindow *pwin[16];
    pfChannel *chan[16];
    int loop;
    int NumWins = 4;
    char str[PF_MAXSTRING];
    double ot, ct;
    int winopen = 1;
     
    if (argc < 2)
        Usage();
     
    // Initialize Performer
    pfInit();
     
    // Use default multiprocessing mode based on number of
    // processors.
    //
    pfMultiprocess( PFMP_DEFAULT );
    //pfMultiprocess( PFMP_APPCULLDRAW );
     
    // Load all loader DSO's before pfConfig() forks
    pfdInitConverter(argv[1]);

    // Configure multiprocessing mode and start parallel
    // processes.
    //
    pfConfig();
     
    // Append to PFPATH additional standard directories where
    // geometry and textures exist
    //
    pfFilePath(".:/usr/share/Performer/data");
     
    // Read a single file, of any known type.
    pfNode *root = pfdLoadFile(argv[1]);
    if (root == NULL)
    {
        pfExit();
        exit(-1);
    }
     
     
    // Attach loaded file to a pfScene.
    pfScene *scene = new pfScene;
    scene->addChild(root);
     
    // determine extent of scene's geometry
    pfSphere bsphere;
    scene->getBound(&bsphere);
     
    // Create a pfLightSource and attach it to scene.
    scene->addChild(new pfLightSource);
     
    // Configure and open GL window
    pfPipe *p = pfGetPipe(0);
    for (loop=0; loop < NumWins; loop++)
    {
        pwin[loop] = new pfPipeWindow(p);
        sprintf(str, "IRIS Performer - Win %d", loop);
        pwin[loop]->setName(str);
        pwin[loop]->setOriginSize((loop&0x1)*315, ((loop&0x2)>>1)*340,
                                  300, 300);
        pwin[loop]->setConfigFunc(OpenPipeWin);
        pwin[loop]->config();
        ot = pfGetTime();
    }
     
    // Create and configure a pfChannel.
    for (loop=0; loop < NumWins; loop++)
    {
        chan[loop] = new pfChannel(p);
        pwin[loop]->addChan(chan[loop]);
        chan[loop]->setScene(scene);
        chan[loop]->setNearFar(1.0f, 10.0f * bsphere.radius);
        chan[loop]->setFOV(45.0f, 0.0f);
    }
     
    // Simulate for twenty seconds.
    while (1)
    {
        float s, c;
        pfCoord view;
         
        // Go to sleep until next frame time.
        pfSync();
         
        // Compute new view position.
        t = pfGetTime();
        pfSinCos(45.0f*t, &s, &c);
        view.hpr.set(45.0f*t, -10.0f, 0);
        view.xyz.set(2.0f * bsphere.radius * s,
                     -2.0f * bsphere.radius *c,
                     0.5f * bsphere.radius);
         
        for (loop=0; loop < NumWins; loop++)
            chan[loop]->setView(view.xyz, view.hpr);
         
        if (pfGetTime() - ot >= 10.0f && winopen )
                {
                pwin[NumWins-1]->close();
                fprintf(stdout,"CLOSE\n");
                winopen = 0;
                ct = pfGetTime();
                }
        if (pfGetTime() - ct >= 10.0f && !winopen )
                {
                pwin[NumWins-1]->config();
                fprintf(stdout,"OPEN\n");
                winopen = 1;
                ot = pfGetTime();
                }

        // Initiate cull/draw for this frame.
        pfFrame();
    }
     
    // Terminate parallel processes and exit.
    pfExit();
     
    return 0;
}

//
// OpenPipeWin() -- create a GL window: set up the
// window system, IRIS GL, and IRIS Performer. This
// procedure is executed for each window in the draw process
// for that pfPipe.
//

static void
OpenPipeWin(pfPipeWindow *pw)
{
    //pfPipe *p = pw->getPipe();
     
    // share GL objects with all the windows on the pipe
    pw->open();
     
    // create a light source in the "south-west" (QIII)
    pfLight *Sun = new pfLight;
    Sun->setPos(-0.3f, -0.3f, 1.0f, 0.0f);
}

#!smake

include $(ROOT)/usr/include/make/commondefs

TARGETS = multiwin
CFILES = multiwin.C

LLDLIBS = -lpfdu_ogl -lpfui -lpfutil_ogl -lpf_ogl -limage -lm

default all:
        $(MAKE) -f $(MAKEFILE) -u $(TARGETS)

include $(COMMONRULES)

multiwin: multiwin.C
        $(C++) $(CFLAGS) -g -o $++at++ $(CFILES) $(LDFLAGS)

Tammy C. Martin
tmartin++at++metricsys.com
Metric Systems Corporation
749 N.W. Beal Parkway
Fort Walton Beach, Florida 32547-3076
850-302-3785


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Dec 28 1998 - 15:37:16 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.