View Full Version : Scrollbar for opengl view
08-23-2012, 01:40 AM
I have implemented zoom method for my NSOpenGLView. NSOpenGLView frame size depends on zoom value (height and width values are being calculated by including zoom value). And if user zooms-in and nsopenglview frame size then gets bigger than my window I need to have scrollbar, to be able to scroll in nsopenglview. I tried adding NSOpenGLView to NSScrollView, but unsuccessfully. NSOpenGLView hasn't been scrolling. I searched in internet for info but no success too. For example this method (http://osdir.com/ml/mac-opengl/2010-09/msg00038.html) looked very nice for me, but it didn't worked.
Maby someone could suggest me solution to do it?
08-28-2012, 04:51 AM
I almost figured it out. But not fully. Right now I already have code:
visibleRect = [self visibleRect];
glViewport(0, 0, someWidth, someHeight);
glFrustum(visibleRect.origin.x, (visibleRect.origin.x + visibleRect.size.width) * zoom, visibleRect.origin.y, (visibleRect.origin.y + visibleRect.size.height) * zoom, 0.1, 100);
And it looks to be working. But there is some problems. And I guess it's caused by my zoom method. My opengl contents gets stretched when scrolling/scrolled.
When zoomed and scrolled to bottom-left corner:
When zoomed and scrolled to bottom-right corner.
As you see image is stretched. But why?
P.S. Zooming is done through glTranslatef. zoom variable in glFrustum is (-10 * zoomslider.floatValue).
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.