2

I have zoom method for my NSOpenGLView. If image is zoomed in, NSOpenGLView frame size, view port and etc. is being increased. Same thing is happening if NSOpenGLView is being zoomed out (the frame size, view port and etc. is being decreased). So I need that if image is zoomed in so that, NSOpenGLView is bigger than my window, scrollbar should appear. So I thought that putting NSOpenGLView to NSScrollView would be my solution. But it doesn't. It doesn't works. How then I could do it?

hockeyman
  • 1,141
  • 6
  • 27
  • 57
  • There are many reasons why it might not work. It would be best to show us how you are adding it to the scrollview, and how you doing your resizing. Otherwise we cannot possibly help you. – sosborn Aug 23 '12 at 05:56
  • I just putted NSOpenGLView to NSScrollView in InterfaceBuilder. Thought it could work. But it doesn't. So far, i found some info, that I need to set my nsscrollview documentView size same as nsopenglview size. But I still haven't find any info how to do it. And how it doesn't works? When I scroll, NSScrollView looks to be scrolling, but NSOpenGLView stays in his position. So maby I need to use some glTranslatef whenever nsscrollview scrollbar moves? – hockeyman Aug 23 '12 at 06:04

1 Answers1

0

When you placed NSOpenGLView into NSScrollView in Interface Builder, you must redefine methods of your custom view:

  • - (void)awakeFromNib - here are OpenGL and other initialisations.
  • - (void)drawRect: (NSRect) dirtyRect - here is rendering.
  • - (void)setFrame:(NSRect)frame - here is reaction on changing of frame's size.

As viewport use visibleRect's size:

glViewport(0,
           0,
           self.visibleRect.size.width,
           self.visibleRect.size.height);

If your view is blinking, redefine method resizeWithOldSuperviewSize too:

- (void)resizeWithOldSuperviewSize:(NSSize)oldSize {
};

But it's hack and it would be better to do custom realisation of Clip view, if it's used.

If you want zoom your OpenGL view, just change its frame size.

George
  • 938
  • 3
  • 11
  • 34