Texture matrix

New Message Reply Date view Thread view Subject view Author view

From: Peter Oslej (peterO++at++vrm.sk)
Date: 10/11/2000 07:58:12


Hello all,

I would like to rotate and translate texture by texture matrix, but my
small demo does not work(texture is still static).
Could somebody tell me what is wrong ? Small demo code is bellow. When I
insert the openGL "patch" it works.

Thanks

Peter Oslej

////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////

#include <Performer/pr/pfWindow.h>
#include <Performer/pr/pfGeoSet.h>
#include <Performer/pr/pfGeoState.h>
#include <Performer/pr/pfTexture.h>

   float t = 0.0f;

int main (void)
{
   pfInit();

    pfWindow *win = new pfWindow;
    win->setOriginSize(100, 100, 500, 500);
    win->setName("Iris Performer");
    win->setWinType(PFWIN_TYPE_X);
    win->open();
    pfFrustum *frust = new pfFrustum;
    frust->apply();
    delete frust;

    pfVec3 *coords = new pfVec3[4];
    coords[0].set(-1.0f, -1.0f, -4.0f );
    coords[1].set( 1.0f, -1.0f, -4.0f );
    coords[2].set( 1.0f, 1.0f, -4.0f );
    coords[3].set(-1.0f, 1.0f, -4.0f ) ;

    pfVec4 *colors = new pfVec4;
    colors[0].set(1.0f, 1.0f, 1.0f, 1.0f);

    pfVec2 *tcoord = new pfVec2[4];
  tcoord[0].set(0.0f, 1.0f);
  tcoord[1].set(1.0f, 1.0f);
  tcoord[2].set(1.0f, 0.0f );
  tcoord[3].set(0.0f, 0.0f);

    pfGeoSet *gset = new pfGeoSet;
    gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, coords, NULL);
    gset->setAttr(PFGS_COLOR4, PFGS_PER_PRIM, colors, NULL);
    gset->setAttr(PFGS_TEXCOORD2,PFGS_PER_VERTEX,tcoord,NULL);
    gset->setPrimType(PFGS_QUADS);
    gset->setNumPrims(1);

    pfGeoState *gstate = new pfGeoState;

    pfMatrix *tmat = new pfMatrix;
    pfTexture *tex = new pfTexture;

 tex->loadFile("/usr/share/Performer/data/floor5.rgb");

 gstate->setMode(PFSTATE_CULLFACE, PFCF_OFF);
    gstate->setAttr(PFSTATE_TEXTURE,tex);
 gstate->setMode(PFSTATE_ENTEXTURE,PF_ON);

    gstate->setMode(PFSTATE_ENTEXMAT,PF_ON);
    gstate->setAttr(PFSTATE_TEXMAT,tmat);
   gset->setGState(gstate);

    pfInitClock (0.0f);

    pfVec4 clr(0.1f, 0.0f, 0.4f, 1.0f);

// glMatrixMode(GL_TEXTURE);
// glLoadIdentity();
 // glMatrixMode(GL_MODELVIEW);

    while(t < 25.0f)
 {
 t = pfGetTime();

 pfClear(PFCL_COLOR | PFCL_DEPTH, &clr);

  tmat->makeTrans(t,0,0);
  // tmat->makeEuler(0,t*2,0);
 // glMatrixMode(GL_TEXTURE);

  // glPopMatrix();
 // glPushMatrix();
 // glRotatef(t*2,0,0,1);
// glTranslatef(-0.5,-0.5,0.0); // move to center
// glMatrixMode(GL_MODELVIEW);

 gset->draw();
 win->swapBuffers();

 }

}


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Oct 11 2000 - 07:02:17 PDT

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