• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting a resize window event?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting a resize window event?


  • Subject: Re: Detecting a resize window event?
  • From: Erik Buck <email@hidden>
  • Date: Sun, 25 May 2008 21:16:04 -0400

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 (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


  • Prev by Date: CoreData
  • Next by Date: Re: File's Owner
  • Previous by thread: Re: Detecting a resize window event?
  • Next by thread: CoreData
  • Index(es):
    • Date
    • Thread