RE: What's wrong

New Message Reply Date view Thread view Subject view Author view

Tawfek Mukhtar (tawfek++at++media1.rndtm.com.my)
Sun, 10 Mar 1996 11:49:09 -0800


This may be trivial, anyway I still don't know the answer. I've modified the
program
/usr/src/Performer/src/pguide/libpr/examples/colorcube.c
into 2 slightly different program called cubenoerror.c and cubewitherror.c
(both are attached with this mail). The different is the sequence of
declaration of geometric data for the cube. Both compiled without problem yet
only cubenoerror.c display the color cube. Why ? I suspect that the sequence
mustbe the cause but I don't see why.
I really appreciate if anyone can provide me with logically correct
explaination.

thanks

/*How to make a cube*/

#include <Performer/pf.h>

#define CUBE_SIZE 1.0f

int main(void)
{
    pfChannel * chan;
    pfPipe * pipe;
    pfScene * scene;
    pfGeode * geode;
    pfCoord view;
    float time;
    float maxTime = 5.0f;
    pfGeoSet *gset;
    pfGeoState *gst;
    void *arena;

    /* These data arrays are static so that they will exist after
     * this routine exits.
     */
    static pfVec4 scolors[] ={{1.0f, 0.0f, 0.0f, 0.5f},
                                       {0.0f, 1.0f, 0.0f, 0.5f},
                                       {0.0f, 0.0f, 1.0f, 0.5f},
                                       {1.0f, 1.0f, 1.0f, 0.5f}};
     
    static pfVec3 snorms[] ={{ 0.0f, 0.0f, 1.0f},
                                      { 0.0f, 0.0f,-1.0f},
                                      { 0.0f, 1.0f, 0.0f},
                                      { 0.0f,-1.0f, 0.0f},
                                      { 1.0f, 0.0f, 0.0f},
                                      {-1.0f, 0.0f, 0.0f}};

    static pfVec3 scoords[] ={{-CUBE_SIZE,-CUBE_SIZE, CUBE_SIZE},
                                       { CUBE_SIZE,-CUBE_SIZE, CUBE_SIZE},
                                       { CUBE_SIZE, CUBE_SIZE, CUBE_SIZE},
                                       {-CUBE_SIZE, CUBE_SIZE, CUBE_SIZE},
                                       {-CUBE_SIZE,-CUBE_SIZE, -CUBE_SIZE},
                                       { CUBE_SIZE,-CUBE_SIZE, -CUBE_SIZE},
                                       { CUBE_SIZE, CUBE_SIZE, -CUBE_SIZE},
                                       {-CUBE_SIZE, CUBE_SIZE, -CUBE_SIZE}};
     
    static ushort snindex[] ={0, 5, 1, 4, 2, 3};

    static ushort svindex[] ={0, 1, 2, 3, /* front */
                                      0, 3, 7, 4, /* left */
                                      4, 7, 6, 5, /* back */
                                      1, 5, 6, 2, /* right */
                                      3, 2, 6, 7, /* top */
                                      0, 4, 5, 1}; /* bottom */

    static ushort scindex[] ={0, 1, 2, 3,
                                      0, 1, 2, 3,
                                      0, 1, 2, 3,
                                      0, 1, 2, 3,
                                      0, 1, 2, 3,
                                      0, 1, 2, 3};
     
     
      
      
    pfInit();
    pfConfig();
     
    pipe = pfGetPipe(0);
    chan = pfNewChan(pipe);
     
    pfInitPipe(pipe, NULL);
    geode = pfNewGeode();
    scene = pfNewScene();
     
    
    arena = pfGetSharedArena();
    gset = pfNewGSet(arena);

    /*
     * set the coordinate, normal and color arrays
     * and their cooresponding index arrays
     */
    pfGSetAttr(gset, PFGS_COORD3, PFGS_PER_VERTEX, scoords, svindex);
    pfGSetAttr(gset, PFGS_NORMAL3, PFGS_PER_PRIM, snorms, snindex);
    pfGSetAttr(gset, PFGS_COLOR4, PFGS_PER_VERTEX, scolors, scindex);
    pfGSetPrimType(gset, PFGS_QUADS);
    pfGSetNumPrims(gset, 6);
     
    /*
     * create a new geostate from shared memory,
     * disable texturing and enable transparency
     */
    gst = pfNewGState(arena);
    pfGStateMode(gst, PFSTATE_ENTEXTURE, 0);
    pfGStateMode(gst, PFSTATE_TRANSPARENCY, 1);

    pfGSetGState(gset, gst);

    
    pfAddGSet(geode,gset);
    pfAddChild(scene, geode);
    pfChanScene(chan, scene);
     
    pfSetVec3(view.xyz, 10.0f, -10.0f, 10.0f);
    pfSetVec3(view.hpr, 45.0f, -30.0f, 0.0f);
     
    pfChanView(chan, view.xyz, view.hpr);
     
    pfInitClock(0.0f);
     
    while (time < maxTime){
        pfSync();
        time = pfGetTime();
        pfFrame();
    }
     
    pfExit();
    exit(0);
}

#include <Performer/pf.h>

#define CUBE_SIZE 1.0f

     

int main(void)
{
    pfChannel * chan;
    pfPipe * pipe;
    pfScene * scene;
    pfGeode * geode;
    pfCoord view;
    float time;
    float maxTime = 5.0f;
    pfGeoSet *gset;
    pfGeoState *gst;
    void *arena;

     /* These data arrays are static so that they will exist after
     * this routine exits.
     */
    static pfVec3 scoords[] ={{-CUBE_SIZE,-CUBE_SIZE, CUBE_SIZE},
                                       { CUBE_SIZE,-CUBE_SIZE, CUBE_SIZE},
                                       { CUBE_SIZE, CUBE_SIZE, CUBE_SIZE},
                                       {-CUBE_SIZE, CUBE_SIZE, CUBE_SIZE},
                                       {-CUBE_SIZE,-CUBE_SIZE, -CUBE_SIZE},
                                       { CUBE_SIZE,-CUBE_SIZE, -CUBE_SIZE},
                                       { CUBE_SIZE, CUBE_SIZE, -CUBE_SIZE},
                                       {-CUBE_SIZE, CUBE_SIZE, -CUBE_SIZE}};

    static ushort svindex[] ={0, 1, 2, 3, /* front */
                                      0, 3, 7, 4, /* left */
                                      4, 7, 6, 5, /* back */
                                      1, 5, 6, 2, /* right */
                                      3, 2, 6, 7, /* top */
                                      0, 4, 5, 1}; /* bottom */

    static pfVec3 snorms[] ={{ 0.0f, 0.0f, 1.0f},
                                      { 0.0f, 0.0f,-1.0f},
                                      { 0.0f, 1.0f, 0.0f},
                                      { 0.0f,-1.0f, 0.0f},
                                      { 1.0f, 0.0f, 0.0f},
                                      {-1.0f, 0.0f, 0.0f}};

    static ushort snindex[] = { 0, 5, 1, 4, 2, 3};
                    
    static pfVec4 scolors[] ={{1.0f, 0.0f, 0.0f, 0.5f},
                                       {0.0f, 1.0f, 0.0f, 0.5f},
                                       {0.0f, 0.0f, 1.0f, 0.5f},
                                       {1.0f, 1.0f, 1.0f, 0.5f}};
                                 
    static ushort scindex[] ={0, 1, 2, 3,
                                      0, 1, 2, 3,
                                      0, 1, 2, 3,
                                      0, 1, 2, 3,
                                      0, 1, 2, 3,
                                      0, 1, 2, 3};
  
    pfInit();
    pfConfig();
     
    pipe = pfGetPipe(0);
    chan = pfNewChan(pipe);

    pfInitPipe(pipe, NULL);
    geode = pfNewGeode();
    scene = pfNewScene();

    arena = pfGetSharedArena();
    gset = pfNewGSet(arena);

    /*
     * set the coordinate, normal and color arrays
     * and their cooresponding index arrays
     */
    pfGSetAttr(gset, PFGS_COORD3, PFGS_PER_VERTEX, scoords, svindex);
    pfGSetAttr(gset, PFGS_NORMAL3, PFGS_PER_PRIM, snorms, snindex);
    pfGSetAttr(gset, PFGS_COLOR4, PFGS_PER_VERTEX, scolors, scindex);
    pfGSetPrimType(gset, PFGS_QUADS);
    pfGSetNumPrims(gset, 6);
      
    /*
     * create a new geostate from shared memory,
     * disable texturing and enable transparency
     */
    gst = pfNewGState(arena);
    pfGStateMode(gst, PFSTATE_ENTEXTURE, 0);
    pfGStateMode(gst, PFSTATE_TRANSPARENCY, 1);
     
    pfGSetGState(gset, gst);
     
     
    pfAddGSet(geode, gset);
    pfAddChild(scene, geode);
    pfChanScene(chan, scene);
  
    pfSetVec3(view.xyz, 10.0, -10.0, 10.0);
    pfSetVec3(view.hpr, 45.0, -10.0, 0.0);
    
    pfInitClock(0.0f);
     
    while(time < maxTime){
        pfSync();
        pfChanView(chan, view.xyz, view.hpr);
        time = pfGetTime();
        pfFrame();
    }
     
    pfExit();
    exit(0);
}

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


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:53:33 PDT

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