Re: odd problems with NSData / OpenGL
Re: odd problems with NSData / OpenGL
- Subject: Re: odd problems with NSData / OpenGL
- From: "Sean McBride" <email@hidden>
- Date: Tue, 8 Dec 2009 19:05:38 -0500
- Organization: Rogue Research Inc.
On 12/9/09 1:52 AM, Henri Häkkinen said:
>I was under the impression that automatic garbage collection was used in
>Mac OS X 10.5 and over, so retaining and releasing objects was handled
>automatically?
Mostly automatic. :)
>This is the initializer method of my Mesh class (I'm using OpenCTM
>library for importing triangle meshes):
>
>- (id)initWithContentsOfFile:(NSString *)path
>{
> self = [super init];
> if (self) {
> // Create an OpenCTM context and load the mesh from disk.
> CTMcontext context = ctmNewContext(CTM_IMPORT);
> ctmLoad(context, [path UTF8String]);
>
> // Check OpenCTM errors.
> CTMenum error = ctmGetError(context);
> if (error != CTM_NONE) {
> NSLog(@"OpenCTM error while opening %@: %s (%d)", path, ctmErrorString
>(error), error);
> ctmFreeContext(context);
> [self dealloc];
> return nil;
> }
>
> // Store the geometry arrays.
> _vertices = [NSData dataWithBytes:ctmGetFloatArray(context, CTM_VERTICES)
> length:ctmGetInteger(context, CTM_VERTEX_COUNT) * sizeof
>(CTMfloat[3])];
>
> _indices = [NSData dataWithBytes:ctmGetIntegerArray(context, CTM_INDICES)
> length:ctmGetInteger(context, CTM_TRIANGLE_COUNT) * sizeof
>(CTMuint[3])];
And these are ivars I guess? If so, they should live as long as 'self' does.
Do you use the 'bytes' method? Are you aware of the issues with it under GC?
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden