Texture Problems

New Message Reply Date view Thread view Subject view Author view

Talal Nehme (talal++at++pdq.net)
Fri, 23 Apr 1999 11:06:30 -0500


I am trying to display a texture using the code from the texture.c example
the texture is loaded but when i try to display it, the program crashes
I tried to fix it, but i am fairly new in this,
the example by itself is working, but when i include it in my
program and try to add the geode
to "MY" scene (which is working fine) it bombs when it tries to display the
texture, this is part of the code

-----------------------------------

arena = (M.arena);
tex = pfNewTex(arena);
    mat = (pfMatrix *) pfMalloc(sizeof(pfMatrix), arena);

    pfMakeScaleMat(*mat,4,4,4);
    pfTexFilter(tex, PFTEX_MINFILTER, PFTEX_BILINEAR);

  gstate = pfNewGState (arena);
    if (pfLoadTexFile (tex, texImagefile))
      {
        uint *i;
        int nc, sx, sy, sz;
        pfGetTexImage(tex, &i, &nc, &sx, &sy, &sz);
        /* if have alpha channel, enable transparency */
                if (nc != 3)
                    pfGStateMode (gstate, PFSTATE_TRANSPARENCY, PFTR_FAST);
        /* set alpha function to block pixels of 0 alpha for
           transparent textures */
                pfGStateMode (gstate, PFSTATE_ALPHAFUNC, PFAF_NOTEQUAL);
                pfGStateVal (gstate, PFSTATE_ALPHAREF, 0.0f);
                pfGStateAttr (gstate, PFSTATE_TEXTURE, tex);
                pfGStateAttr (gstate, PFSTATE_TEXMAT, mat);
                pfGStateMode (gstate, PFSTATE_ENTEXTURE, 1);
                pfGStateMode (gstate, PFSTATE_ENTEXMAT, 1);
                pfGStateMode (gstate, PFSTATE_ENLIGHTING, 0);
                pfGStateMode (gstate, PFSTATE_CULLFACE, PFCF_OFF);
        tev = pfNewTEnv (arena);

        pfTEnvMode(tev, PFTE_BLEND);
        pfTEnvBlendColor(tev, 0.0f, 0.0f, 0.0f, 1.0f);

        pfGStateAttr (gstate, PFSTATE_TEXENV, tev);

        numTextures++;
    }
 gset = pfNewGSet(arena);
        pfGSetAttr(gset, PFGS_COORD3, PFGS_PER_VERTEX, coords, vertexlist);
        pfGSetAttr(gset, PFGS_TEXCOORD2, PFGS_PER_VERTEX, texcoords, texlist);
        pfGSetAttr(gset, PFGS_COLOR4, PFGS_PER_VERTEX, colors, colorlist);
        pfGSetPrimType(gset, PFGS_QUADS);
        pfGSetNumPrims(gset, 1);

  pfGSetGState (gset, gstate);
    /* set up scene graph */
    geode1 = pfNewGeode();
    pfAddGSet(geode1, gset);
    dcs1 = pfNewDCS();
    pfDCSTrans (dcs1, -2.0f, 0.1f, 0.5f);
    pfAddChild(dcs1, geode1);
    root = pfNewGroup();
    pfAddChild(root, dcs1);
    pfAddChild(M.H1->scene, root);

-------------------------------------
I appreciate any help,
Talal Nehme
Tnehme++at++Bayou.UH.EDU

Talal++at++pdq.net


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Fri Apr 23 1999 - 09:06:39 PDT

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