From: Dan Johnston (dan.johnston++at++nrc.ca)
Date: 12/17/2001 05:00:01
Group;
I had a couple of questions on this post, so
here is more information;
1. Compiled and run on IRIX, 6.5.13m with
Performer 2.4 dev and 2.4.2 runtime. Used
SGI compiler for C++.
2. Why don't I call pfConfig? I dodn't think
I had to here. There will not be any drawing
in this code, not multi-processing, no need
for a graphics pipe. The program is just
supposed to create the shared memory
file and fill it with a geoset and then leave
it for a separate drawing program to find
(it will be using much-more-complicated
geosets as fluxed geometry).
3. What happens with PFNFYLEVEL set
to a higher level? Here I use '7' (but with
host names changed in messages).
my_prompt% ./write_2poly.debug
863010 PF Notice: level Internal Debug (7) set by environment
variable PFNFYLEVEL
863010 PF Debug/Resource: pfDataPool::create() - pid 863010 - 131072
bytes at 0x415c000 succeeded for /usr/tmp/dpoolForSharedData.pfdpool
863010 PF Debug: pfOpenWSConnection - opening shared display
(REMOTE_COMPUTER):0.0=0x10017Dan Johnston wrote:
....
4. So what was the problem again?
In the run above, the temp.
datapool file already exists, so I should
not re-create one but exist with an
'already exists' message.
Thanks again for your input!
Dan.Johnston++at++nrc.ca
Dan Johnston wrote:
> Still working with pfDataPool...
>
> The attached C++ code snippet is supposed to check for
> the existance of a shared memory file, and skip out
> if it exists.
>
> What I get;
> The temporary file does NOT esist
> The value of 'shared' after the 'attach' is NULL
> We go on to create the data pool (and file) and
> allocate block of memory in it to store stuff.
> (run the code again)
> the temporary file DOES exist
> the value of 'shared' after the attach is still NULL
> We re-create the data pool and file
> ...
>
> What is the silly thing that I'm doing wrong?
> The C-language code found in
> /usr/share/Performer/src/lib/libpfutil/shmem.c
> supposedly works, and I thought I used the
> same logic.
>
> Thank for your help!
>
> Dan
>
--
___|__ |
/ | \ ||\ Daniel (Dan) Johnston
/___|___\ || \ Dan.Johnston++at++nrc.ca
_____|____ || \ National Research Council of Canada, London, ON
| | | || \ Integrated Manufacturing Technologies Institute
\___| | | ||____\ Tel: (519) 430-7081 Fax: (519) 430-7090
\_o_\___|____|_|______\_ Inst: http://www.nrc.ca/imti
\ o / These opinions are my own! Not those of NRC.
\________________/ Virtual Reality:
http://www.nrc.ca/imti/vetc/home.html
More Tall Ships - Fewer Computers!
// // write_2poly.C: create a simple 2 triangle poly and save // in shared memory for another process to draw. // // $Revision: 1.10 $ // $Date: 2000/10/06 21:26:42 $ // //
#include <Performer/pr/pfGeoSet.h> #include <Performer/pr/pfDataPool.h> #include <Performer/pr/pfGeoState.h> #include <iostream.h>
#define PROGRAM "write_2poly" #define MEM_FILE "dpoolForSharedData"
static long DPoolSize = 1 << 17; /* 128K bytes */
int main (void) { // Initialize Performer pfInit();
// try to attach to an existing shared memory data pool pfDataPool *shared = pfDataPool::attach(MEM_FILE); if ( shared != NULL ) { cerr << PROGRAM << "create error;" << MEM_FILE << "already exists\n"; exit(1); }
// create the shared memory data pool if ( (shared = pfDataPool::create(DPoolSize,MEM_FILE)) == NULL ) { cerr << PROGRAM << " unable to open" << MEM_FILE << "for data pool\n"; exit(1); }
// Set up a geoset with 5 parts - vertex, index, colors, gset, gstate pfVec3 *coords = (pfVec3 *)shared->alloc(4*sizeof(pfVec3), 101); coords[0].set(-1.0f, -1.0f, 0.0f ); coords[1].set( 1.0f, -1.0f, 0.0f ); coords[2].set( 1.0f, 1.0f, 0.0f ); coords[3].set(-1.0f, 1.0f, 0.0f );
// dummy index for now ushort *index = (ushort *)shared->alloc(12*sizeof(ushort), 102);
pfVec4 *colors = (pfVec4 *)shared->alloc(4*sizeof(pfVec4), 103); colors[0].set(1.0f, 1.0f, 1.0f, 1.0f); colors[1].set(0.0f, 0.0f, 1.0f, 1.0f); colors[2].set(1.0f, 0.0f, 0.0f, 1.0f); colors[3].set(0.0f, 1.0f, 0.0f, 1.0f);
pfGeoSet *gset = (pfGeoSet *)shared->alloc(sizeof(pfGeoSet), 100); pfGeoSet *temp = new pfGeoSet(); pfMemory::copy(temp,gset); delete temp; gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, coords, NULL); gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX, colors, NULL); gset->setPrimType(PFGS_QUADS); gset->setNumPrims(1);
// Set up a geostate, backface removal turned off pfGeoState *gstate = (pfGeoState *)shared->alloc(sizeof(pfGeoState), 104); pfGeoState *temp2 = new pfGeoState(); pfMemory::copy(temp,gstate); delete temp2; gstate->setMode(PFSTATE_CULLFACE, PFCF_OFF); gset->setGState(gstate);
// the GeoSet is now stored in shared memory // do NOT delete it, i.e. it will be cleaned by the // drawing process }
This archive was generated by hypermail 2b29 : Mon Dec 17 2001 - 05:06:23 PST