Re: Sampling

New Message Reply Date view Thread view Subject view Author view

Brian Furtaw (brian++at++clubfed.sgi.com)
Thu, 27 May 1999 14:33:51 -0400


A couple of options you can do here, make a separate process which uses a loop,

while( running ) {

        /* code to save flight data */
        /* to shared memory segement */

        /* sleep for half a second */
        sginap(50 /* 50 * 10ms = 500ms = 0.5s */);
}

or you can record the start time then increment it every time you hit the next
record time,

    float trigger = 0.0f
    static int doOnce = 1;

    /* Application main loop */
    while (!SimDone())
    {
        /* Sleep until next frame */
        pfSync();

        if(doOnce) {
            doOnce = 0;
            trigger = pfGetTime(); /* get the initial time sync'd with
                                                 vertical retrace */
            trigger += 0.5f;
        }

        if(pfGetTime() >= trigger ) {
            /* save flight data */
            trigger += 0.5f;
        }

        /*
         * Should do all latency critical processing inbetween pfSync()
         * and pfFrame(). Typically this is viewing position update.
         */
        PreFrame();

        /* Trigger cull and draw processing for this frame. */
        pfFrame();

        /* Perform non-latency critical simulation updates. */
        PostFrame();
    }

On May 27, 4:46pm, Devrim Erdem wrote:
> Subject: Sampling
> Hi,
>
> I have a pf application where I store the position of an aircraft in a
> list of 200
> items.
>
> I want to add a new entry to my list every 0.5 seconds. For the app is
> pretty
> complex I can not use timer callbacks. Getting the simulation time as a
> floating
> point number and doing (% 0.5) does not work, because the result of this
> will be the
> same for 0.5 seconds after it is true for the first time.
>
> Adding a counter didn't seem to be a great idea for performance. Any
> suggestions ?
>
> devrim
>
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
>-- End of excerpt from Devrim Erdem

-- 
    ----oOOo----    ----oOOo----    ----oOOo----    ----oOOo----

Brian Furtaw (brian++at++sgi.com) Graphics Guru Office:(301)572-3293 Fax: (301)872-3293 12200-G Plum Orchard Drive OpenGL/Performer/OpenInventor/ImageVision Silver Spring, Maryland 20904 Optimizer/React/PCI Device Drivers


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Thu May 27 1999 - 09:59:37 PDT

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