Re: Textured geosets in multiple windows

New Message Reply Date view Thread view Subject view Author view

Sharon Fischler (srf++at++rose)
Thu, 16 Jun 1994 02:30:58 -0700


+>---- On Jun 16, 9:54am, AST wrote:
> Subject: Textured geosets in multiple windows
->
->I seem unable to draw one textured geoset in 2 separate windows created by winopen. The call to
->pfDrawGSet in the 1st window gives a correct result, but I get no texture in the 2nd window.
->Any ideas ?
No problem. You simply need a separate pfState for each window
and select corresponding state for the current window (pfSelectState).
A full working test program (adapted from your test case) is
included below.

->
->Here is one simple code that reproduces this bug:

FYI: your test case also did have one bad typo:

-> pfGStateAttr(gset_state, PFSTATE_TEXTURE, tex);
-> pfGStateAttr(gset_state, PFSTATE_TEXTURE, tex_env);
                                ^^^^^^^^^^^^^^
                                should be PFSTATE_TEXENV

#include "Performer/pr.h"

pfVec3 coords[] ={ {-1.0f, -1.0f, -5.0f },
                                { 1.0f, -1.0f, -5.0f },
                                { 1.0f, 1.0f, -5.0f },
                                {-1.0f, 1.0f, -5.0f } };

pfVec4 colors[] ={ {1.0f, 1.0f, 1.0f, 1.0f},
                                {0.0f, 0.0f, 1.0f, 1.0f},
                                {1.0f, 0.0f, 0.0f, 1.0f},
                                {0.0f, 1.0f, 0.0f, 1.0f} };
                                 
pfVec2 texcoords[]={ {0.0f, 0.0f},
                                {1.0f, 0.0f},
                                {1.0f, 1.0f},
                                {0.0f, 1.0f} };

long Wid1, Wid2;

static void init_windows(void);
static pfGeoSet *build_gset(void);

long main( int argc, char *argv[] )
{
    pfGeoSet *gset;
    pfGeoState *gset_state;
    pfTexture *tex;
    pfTexEnv *tex_env;
    pfState *s1, *s2;
     

    /* ----------------------------
        Initialization of Performer
       ---------------------------- */
     
    pfInitState(NULL);
    s1 = pfNewState();
    s2 = pfNewState();

    /* -----------------------
        Creation of one geoset
       ----------------------- */
    gset = build_gset();
    gset_state = pfNewGState(NULL);
    pfGSetGState (gset, gset_state);
    pfGStateMode(gset_state, PFSTATE_ENTEXTURE, PFTR_ON);

    /* --------------------------------------------
        Creation of one pfTexture and one pfTexEnv
       -------------------------------------------- */
    tex = pfNewTex(NULL);
    tex_env = pfNewTEnv(NULL);
    pfLoadTexFile(tex, "brick.rgba");
     
    pfGStateAttr(gset_state, PFSTATE_TEXTURE, tex);
    pfGStateAttr(gset_state, PFSTATE_TEXENV, tex_env);

    /* ------------------------------------
        Creation of 2 windows with winopen
       ------------------------------------ */
    init_windows();

    winset(Wid1);
    pfSelectState(s1);
    pfDrawGSet(gset);
  
    sleep(1);

    winset(Wid2);
    pfSelectState(s2);
    pfDrawGSet(gset);

    sleep(10);
    return 0;
}

static void
init_windows(void)
{
    long xs, ys;

    foreground();
    prefposition(0, 400, 0, 400);
    Wid1 = winopen("Performer cubes");
    RGBmode();
    gconfig();
    mmode(MVIEWING);
    lsetdepth(getgdesc(GD_ZMIN), getgdesc(GD_ZMAX));
    subpixel(TRUE);
    backface(FALSE);
    getsize(&xs, &ys);
    ortho(-1, 1, -1, 1, 1, 10);
     
    prefposition(0, 400, 400, 800);
    foreground();
    Wid2 = winopen("Performer cubes");
    RGBmode();
    gconfig();
    mmode(MVIEWING);
    lsetdepth(getgdesc(GD_ZMIN), getgdesc(GD_ZMAX));
    subpixel(TRUE);
    backface(FALSE);
    getsize(&xs, &ys);
    ortho(-1, 1, -1, 1, 1, 10);
}

pfGeoSet*
build_gset(void)
{
    pfGeoSet *gset;
     
    gset = pfNewGSet(NULL);
    pfGSetAttr(gset, PFGS_COORD3, PFGS_PER_VERTEX, coords, NULL);
    pfGSetAttr(gset, PFGS_TEXCOORD2, PFGS_PER_VERTEX, texcoords, NULL);
    pfGSetAttr(gset, PFGS_COLOR4, PFGS_PER_VERTEX, colors, NULL);
    pfGSetPrimType(gset, PFGS_QUADS);
    pfGSetNumPrims(gset, 1);
    return gset;
}

-- 
-----{-----{---++at++   -----{----{---++at++   -----{----{---++at++   -----{----{---++at++
Sharon Rose Fischler - Silicon Graphics, Advanced Graphics Development
srf++at++sgi.com  (415) 390 - 1002  FAX: (415) 965 - 2658  MS 8U-590
-----{-----{---++at++   -----{----{---++at++   -----{----{---++at++   -----{----{---++at++

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:50:20 PDT

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