pfIsTexLoaded question

New Message Reply Date view Thread view Subject view Author view

AnitaKishore (kishore++at++electrogig.com)
Tue, 5 Sep 1995 15:19:26 -0700


I am trying to test out the texture downloading mechanisms as described
in /usr/share/Performer/src/pguide/libpf/examples/download.doc. When I
use the function pfIsTexLoaded in the draw process before using
pfuDownloadTexList, it always returns TRUE, even the first time when the
draw callback is invoked. It returns TRUE even in the main routine, just
after registering the draw callback. Am I not using these APIs correctly?
Any help will be greatly appreciated. I am including the source code for
anybody interested in having a look at it. It is very small :-)

thanks in advance

-anita

---------------------------------------------------------------------------
Anita Kishore
kishore++at++electrogig.com
---------------------------------------------------------------------------

#include <stdlib.h>
#include <stdio.h>
#include <Performer/pf.h>
#include <Performer/pfutil.h>

extern "C" {
extern pfNode* pfdLoadFile (char *fileName);
}
void DrawChannel(pfChannel *chan, void *data);

typedef struct _SharedData
{
    pfList *texList;
} SharedData;

SharedData *shData;

int main(int argc, char *argv[])
{

        pfScene *scene;
        pfPipe *p;
        pfChannel *chan;
        pfGroup *root;
        pfCoord view;

        if (argc<2)
        {
                printf("Input data file....\n");
                exit(1);
        }

        pfInit();
        shData = (SharedData *) pfMalloc(sizeof(SharedData),
                                         pfGetSharedArena());

        pfConfig();
        pfuInitUtil();
        scene = pfNewScene();

        if (pfGetFilePath() == NULL)
                pfFilePath(".:/disk4/people/kishore/performer/data");

        if ((root = (pfGroup *)pfdLoadFile(argv[1])) == NULL)
        {
                printf("Unable to create scene data base....\n");
                pfExit();
                exit(-1);
        }

        pfAddChild(scene, root);
        shData->texList = pfuMakeTexList((pfNode *)root);

        p = pfGetPipe(0);
        chan = pfNewChan(p);
        pfChanScene(chan, scene);
        pfChanNearFar(chan, 1, 10000);
        pfChanAspect(chan, PFFRUST_CALC_VERT, 1.3333);
        pfChanFOV(chan, 140, -1);
        pfSetVec3(view.hpr, 0, 0, 0);
        pfSetVec3(view.xyz, 0, -50, 60);
        pfChanView(chan, view.xyz, view.hpr);

        pfFrameRate(60.0f);
        pfPhase(PFPHASE_LOCK);
        pfChanTravFunc(chan, PFTRAV_DRAW, DrawChannel);

        const pfTexture *tex = (pfTexture *) pfGet(shData->texList, 0);
        if (pfIsTexLoaded(tex))
            printf("main : Texture already loaded\n");

        for (;;)
        {
                pfSync();
                pfFrame();
        }

}

void DrawChannel(pfChannel *chan, void *data)
{

        (chan, data);

        pfClearChan(chan);

        const pfTexture *tex = (pfTexture *) pfGet(shData->texList, 0);
        if (pfIsTexLoaded(tex))
            printf("Texture already loaded\n");
        else
        {
            printf("Loading Texture\n");
            pfuDownloadTexList(shData->texList, PFUTEX_APPLY);
        }

        pfDraw();

}


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:52 PDT

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