From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / OSX / XScreenSaverGLView.m
index 989f8eb9258f36a3a7193bc902f629b4b25e93b2..d61964f8d3b3fd0dad5fd909ecc3938c5b6be79b 100644 (file)
@@ -121,7 +121,7 @@ extern void check_gl_error (const char *type);
   BOOL was_initted_p = initted_p;
   [super render_x11];
 
-  if (! was_initted_p)
+  if (! was_initted_p && xdpy)
     _suppressRotationAnimation =
       get_boolean_resource (xdpy,
                             "suppressRotationAnimation",
@@ -262,6 +262,31 @@ extern void check_gl_error (const char *type);
   return kCAGravityCenter;
 }
 
+- (void) startAnimation
+{
+  [super startAnimation];
+  if (ogl_ctx) /* Almost always true. */
+    _glesState = jwzgles_make_state ();
+}
+
+- (void) stopAnimation
+{
+  [super stopAnimation];
+#ifdef USE_IPHONE
+  if (_glesState) {
+    [EAGLContext setCurrentContext:ogl_ctx];
+    jwzgles_make_current (_glesState);
+    jwzgles_free_state ();
+  }
+#endif
+}
+
+- (void) prepareContext
+{
+  [super prepareContext];
+  jwzgles_make_current (_glesState);
+}
+
 #endif // !USE_IPHONE
 
 
@@ -307,10 +332,6 @@ init_GL (ModeInfo *mi)
 
   // OpenGL initialization is in [XScreenSaverView startAnimation].
 
-# ifdef USE_IPHONE
-  jwzgles_reset ();
-# endif // USE_IPHONE
-
   // I don't know why this is necessary, but it beats randomly having some
   // textures be upside down.
   //