Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you'd be best off with the scheme you suggest towards the end — keeping the OpenGL view static and outside of the scroll view, and moving its contents so as to match the movement of the scroll view.</p> <p>Assuming you're using a <code>GLKView</code>, implement your <code>glkView:drawInRect:</code> so that it gets the <code>contentOffset</code> (and, probably, the <code>bounds</code>) properties from your scroll view and draws appropriately. E.g. (pretending you're using GLES 1.0 just because the matrix manipulation methods are so well known):</p> <pre><code>- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // displayArea will be the area the scroll view is // currently displaying; taking just the bounds would // likely be fine too CGRect displayArea; displayArea.origin = scrollView.contentOffset; displayArea.size = scrollView.bounds.size; // assuming (0, 0) in the GL view is in the centre, // we'll adjust things so that it's in the corner ala // UIKit CGPoint centre = CGPointMake( displayArea.origin.x + displayArea.size.width*0.5f, displayArea.origin.y + displayArea.size.height*0.5f); glPushMatrix(); // apply the scroll as per the scroll view // so that its centre is aligned with our centre glTranslatef(-centre.x, -centre.y, -1); /* rest of drawing here */ glPopMatrix(); } </code></pre> <p>Then connect yourself as a delegate to the scrollview and just perform:</p> <pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView { [glView setNeedsDisplay]; } </code></pre> <p>To ensure the GL redraws whenever the scroll view is scrolled.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload