Some help with ptex libaries.

79 views
Skip to first unread message

Daniel Seddon

unread,
May 6, 2011, 6:59:48 PM5/6/11
to ptex
Hi

I'm trying to make use of the ptex libaries in conjunction with some
tools I'm writing - I'm not coming at this from a heavy programming
background and have hit, what I hope, to be some minor issues. Here it
is what I'm trying in essence:

Code-

#include "Ptexture.h"
#include "PtexReader.h"

main(){

PtexTexture *ptex;
Ptex::String perr;

char const *ptxPath = "/jobs/vfx_clash2/sequences/rnd/rnd002/images/
textures/testPtex2.ptx";

ptex->open( ptxPath, perr, true);

int nF = ptex->numFaces();

}

Compile line-

g++ -o testPtex -I/home/dseddon/latestCode/code2/src/ptex/ -L/home/
dseddon/latestCode/code2/src/ptex/ -lPtex testPtex.cpp

Result-

./testPtex
Segmentation fault....


The .ptx has been saved out of 3Dcoat. But, I assume it's something
I'm doing wrong - as I say, I'm not a hardcore programmer. I'm hoping
I've just done something obviously wrong....

Thanks

Dan

brentb

unread,
May 6, 2011, 7:18:17 PM5/6/11
to ptex
On May 6, 3:59 pm, Daniel Seddon <dansed...@gmail.com> wrote:
> #include "Ptexture.h"
> #include "PtexReader.h"

You should only need to include Ptexture.h. PtexReader is an internal
header.

>         ptex->open( ptxPath, perr, true);

open is a static method, meaning that it doesn't need an object to
call it. The bigger problem though, and the reason for your crash, is
that you're never setting the value of ptex. Try this instead:

ptex = PtexTexture::open( ... )

In the end you'll also need to release the texture by calling ptex-
>release(). You can use PtexPtr to do this automatically. See the
PtexPtr docs and reply back if you want more info. You can also take
a look at rtest.cpp or ptxinfo.cpp for samples of how to use the api.

Good luck!

Brent

brentb

unread,
May 6, 2011, 7:28:07 PM5/6/11
to ptex
Unfortunate line split. That should have read (fingers crossed as I
hit "Send"):

Daniel Seddon

unread,
May 6, 2011, 7:33:05 PM5/6/11
to ptex
Wow Brent - You've just broken the record for speed of response on any
support I've ever had. I barely had time to make a cup of tea and it's
all working :)

Thanks for your help

Dan
Reply all
Reply to author
Forward
0 new messages