From: Angus Dorbie (dorbie++at++sgi.com)
Date: 02/05/2001 17:52:54
Could the problem be that the image is tightly packed, and you address
array as type int, you are incrementing in sizeof(int) which will be 4.
Since the data has only 3 components you overrun the array.
Try:
printf("%d%d%d\n",((char *)image)[(j*3)], ((char *)image)[(j*3)+1],
((char *)image)[(j*3)+2]);
Cheers,ANgus.
Desmond Rivet wrote:
>
> Hi all,
>
> How exactly does one use pfGetTexImage? I tried to write a VERY SIMPLE AND
> SMALL program:
>
> #include <Performer/pf.h>
> #include <Performer/pfdu.h>
>
> int main(int argc, char *argv[])
> {
> int j, comp, sx, sy, sz;
> unsigned int* image;
> pfTexture *tex;
>
> pfInit();
>
> tex = pfNewTex(pfGetSharedArena());
>
> pfLoadTexFile(tex, "road.pfi");
> pfGetTexImage(tex, &image, &comp, &sx, &sy, &sz);
>
> printf("comp=%d, sx=%d, sy=%d, sz=%d\n", comp, sx, sy, sz);
> for(j = 0; j < sx*sy; j++)
> {
> printf("%d\n",image[j]);
> }
>
> return 0;
> }
>
> road.pfi is a proper pfi file (it is a texture in the standard Performer
> town demo) and is located in the same directory as the program itself.
>
> The output is:
>
> comp=3, sx=512, sy=64, sz=1
> 1261846347
> 1061893695
> 910116915
> 1311982929
> .....
>
> The program SEG FAULTS, at some point when outputing the array, though for
> the life of me I can't figure out why.
>
> Am I using the functions properly?
>
> Thanks for your time...
>
> ----------------------------------------------
> Desmond Rivet rivet++at++ecf.utoronto.ca
> Eng Sci 0T0 + PEY rivet_d++at++hotmail.com
>
> You live and learn, or you don't live long
>
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
-- For Performer+OpenGL tutorials http://www.dorbie.com/"In the middle of difficulty lies opportunity." --Albert Einstein
This archive was generated by hypermail 2b29 : Mon Feb 05 2001 - 17:53:24 PST