Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Scrollbar for opengl view

  1. #1
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41

    Scrollbar for opengl view

    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 looked very nice for me, but it didn't worked.

    Maby someone could suggest me solution to do it?

  2. #2
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41
    I almost figured it out. But not fully. Right now I already have code:

    Code :
        visibleRect = [self visibleRect];
        glViewport(0, 0, someWidth, someHeight);
        glMatrixMode(GL_PROJECTION);
        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.

    Example:

    Original Image
    Click image for larger version. 

Name:	Screen Shot 2012-08-27 at 9.48.00 AM.jpg 
Views:	115 
Size:	12.1 KB 
ID:	862

    When zoomed and scrolled to bottom-left corner:
    Click image for larger version. 

Name:	Screen Shot 2012-08-28 at 2.53.31 PM.jpg 
Views:	110 
Size:	8.3 KB 
ID:	860

    When zoomed and scrolled to bottom-right corner.
    Click image for larger version. 

Name:	Screen Shot 2012-08-28 at 2.53.43 PM.jpg 
Views:	122 
Size:	10.0 KB 
ID:	861

    As you see image is stretched. But why?

    P.S. Zooming is done through glTranslatef. zoom variable in glFrustum is (-10 * zoomslider.floatValue).
    Last edited by hockeyman; 08-28-2012 at 04:58 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •