I use the -resize method within an NSOpenGLView subclass. Is there some reason you don't use an NSOpenGLSubclass ?

@implementation EBNMapOpenGLView

- (id)initWithFrame:(NSRect)frame
{
   static NSOpenGLPixelFormatAttribute attribs[] =
   {
      NSOpenGLPFANoRecovery,
      NSOpenGLPFAWindow,
      NSOpenGLPFAAccelerated,
      NSOpenGLPFADoubleBuffer,
      NSOpenGLPFAColorSize, 24,
      NSOpenGLPFAAlphaSize, 8,
      NSOpenGLPFADepthSize, 32,
      NSOpenGLPFAStencilSize, 0,
      NSOpenGLPFAAccumSize, 0,
      0
   };

   NSOpenGLPixelFormat  *pixelFormat = [[[NSOpenGLPixelFormat alloc]
      initWithAttributes:attribs] autorelease];
        
   if (nil == pixelFormat)
   {
      NSLog(@"Failed to create OpenGL pixel format");
      [self autorelease];
      self = nil;
   }
   else
   {
      self = [self initWithFrame:frame pixelFormat:pixelFormat];
      if(nil != self)
      {
          // put more init stuff here
      }
   }

   return self;
}


- (void)dealloc
{
   // clean up stuff here

   [super dealloc];
}


- (void)awakeFromNib
{
   if(nil == world)
   {
      // Add a default point light
//[[self world] addLight:[[[EBNOpenGLLight alloc] init] autorelease]];

      // Configure viewport and camera
      [self reshape];
   }

   [[self window] makeFirstResponder:self];

   // Start things running after all initialization is complete
//[self performSelector:@selector(_ebnRunStep:) withObject:nil afterDelay:0.0f];
}


- (void)reshape
{
   CGLContextObj     cgl_ctx = [[self openGLContext] CGLContextObj];
   NSRect            bounds = [self bounds];

   NSAssert(1.0f < bounds.size.height, @"Invalid height specified");
const GLdouble anAspectRatio = bounds.size.width/ bounds.size.height;

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glViewport(0, 0, bounds.size.width, bounds.size.height);

//[[[self world] camera] configurePerspectiveProjectionWithAspectRatio:anAspectRatio];
}

@end

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to