Re: How to allocate my memory (texture images)

New Message Reply Date view Thread view Subject view Author view

Mario Veraart (rioj7++at++fel.tno.nl)
Wed, 19 Nov 1997 18:52:52 +0100 (MET)


>
> OK,this is what I'm trying to do...
> (I have been able to do this when I allocate all I need in a shared arena
> data pool
> arena=pfGetSharedArena();
> sd=(SharedS *)pfMalloc(sizeof(SharedS),arena);
> where the SharedS structure contain image size, and pointer to texture
> image and pfTexture pointer.
>
> The problem is that since I'm not sure if this is the correct way to do
> this, nor if it can be done in any other ways, and the fact that when
> I tried to extend this by adding a pointer to a list of "movie" objects
> (each containing an pointer to a buffer that is updated when a new frame
> from the move is ready, the pfTexture that I'm using, and the image
> sizes) then I got a NULL pointer, and I also noticed that the pointer
> value itself was changing all time (I guess that this has to do with
> a cyclic buffer that i used to give data to the APP, CULL and DRAW without
> overwriting the wrong values on the way).
>
> However, my data is a texture image, so it will only be used in the
> pfDraw phase (right before to download the new textures), and in the
> movie update process that is sproced to keep loading and updating the
> image.
>
> I have looked at face-space source code, and it seems like that code is
> using a passthrough data to do this, and I also noticed that they uses
> pfCalloc instead of pfMalloc.
>
> Here is aprox. the code that I'm trying to get to work, but it does not
> because of the
> memory-allocation-on-shared-arena-mixed-with-cyclic-buffer-swapping-feature.
>
>
> typedef struct _MovieS {
> unsigned int *image;
> int w,h;
> } MovieS;
>
> MovieS **mv;
>
> mv=(MovieS *)pfMalloc(sizeof(MovieS *)*10,arena);
> mv[0]=(MovieS *)pfMalloc(sizeof(MovieS),arena);
>
> mv[0].w=320;
> mv[0].h=240;
>
> pfChanData(sd->pf_chan,(void *)sd,sizeof(mv));
> pfChanTravFunc(sd->pf_chan,PFTRAV_DRAW,Draw);
>
> LOOP
>
> void Draw(pfChannel *c,void *d) {
> MovieS **mv;
>
> printf("Size : %ix%i\n",mv[0].w,mv[0].h);
> pfDraw();
> }
>
>
> When the program is running, it is printing
> Size : 0x0
> instead of
> Size : 320x240
> as I would like to have.

You should use the following

in the main code

MovieS *mv;
...
mv = pfAllocChanData(sd->pf_chan, sizeof(MovieS)*10);
mv[0].w=320;
mv[0].h=240;

pfChanTravFunc(sd->pf_chan,PFTRAV_DRAW,Draw);

while (1)
{
    pfFrame();

    change the values of the Movie structs

    pfPassChanData(sd->pf_chan);
}
pfExit();

void Draw(pfChannel *c,void *d) {
  MovieS *mv = (MovieS *) d;

  printf("Size : %ix%i\n",mv[0].w,mv[0].h);
  pfDraw();
}

Read the man page of pfChannel concerning passing data

Mario
=======================================================================
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:56:13 PDT

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