projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.22.tar.gz
[xscreensaver]
/
OSX
/
XScreenSaverGLView.m
diff --git
a/OSX/XScreenSaverGLView.m
b/OSX/XScreenSaverGLView.m
index 58144ee1c342b1645749d37571d6770c4cd46233..7ec10090624b18cb61f76bb24c018ffb38c5ab23 100644
(file)
--- a/
OSX/XScreenSaverGLView.m
+++ b/
OSX/XScreenSaverGLView.m
@@
-1,4
+1,4
@@
-/* xscreensaver, Copyright (c) 2006-201
2
Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 2006-201
3
Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@
-82,6
+82,16
@@
extern void check_gl_error (const char *type);
}
}
+#ifdef USE_IPHONE
+/* With GL programs, drawing at full resolution isn't a problem.
+ */
+- (CGFloat) hackedContentScaleFactor
+{
+ return [self contentScaleFactor];
+}
+#endif // USE_IPHONE
+
+
- (void) setOglContext: (NSOpenGLContext *) ctx
{
ogl_ctx = ctx;
- (void) setOglContext: (NSOpenGLContext *) ctx
{
ogl_ctx = ctx;
@@
-89,9
+99,9
@@
extern void check_gl_error (const char *type);
# ifdef USE_IPHONE
[EAGLContext setCurrentContext: ogl_ctx];
# ifdef USE_IPHONE
[EAGLContext setCurrentContext: ogl_ctx];
- double s =
self.contentScaleFactor
;
- int w = s * [self
frame
].size.width;
- int h = s * [self
frame
].size.height;
+ double s =
[self hackedContentScaleFactor]
;
+ int w = s * [self
bounds
].size.width;
+ int h = s * [self
bounds
].size.height;
if (gl_framebuffer) glDeleteFramebuffersOES (1, &gl_framebuffer);
if (gl_renderbuffer) glDeleteRenderbuffersOES (1, &gl_renderbuffer);
if (gl_framebuffer) glDeleteFramebuffersOES (1, &gl_framebuffer);
if (gl_renderbuffer) glDeleteRenderbuffersOES (1, &gl_renderbuffer);
@@
-173,11
+183,21
@@
extern void check_gl_error (const char *type);
return [CAEAGLLayer class];
}
return [CAEAGLLayer class];
}
+- (void) swapBuffers
+{
+ glBindRenderbufferOES (GL_RENDERBUFFER_OES, gl_renderbuffer);
+ [ogl_ctx presentRenderbuffer:GL_RENDERBUFFER_OES];
+}
+#endif // USE_IPHONE
+
+
+#ifdef USE_BACKBUFFER
+
+- (void) initLayer
+{
+ // Do nothing.
+}
-/* On MacOS: drawRect does nothing, and animateOneFrame renders.
- On iOS GL: drawRect does nothing, and animateOneFrame renders.
- On iOS X11: drawRect renders, and animateOneFrame marks the view dirty.
- */
- (void)drawRect:(NSRect)rect
{
}
- (void)drawRect:(NSRect)rect
{
}
@@
-185,9
+205,15
@@
extern void check_gl_error (const char *type);
- (void) animateOneFrame
{
- (void) animateOneFrame
{
+# ifdef USE_IPHONE
UIGraphicsPushContext (backbuffer);
UIGraphicsPushContext (backbuffer);
+# endif
+
[self render_x11];
[self render_x11];
+
+# ifdef USE_IPHONE
UIGraphicsPopContext();
UIGraphicsPopContext();
+# endif
}
}
@@
-202,8
+228,13
@@
extern void check_gl_error (const char *type);
// Don't resize the X11 window to match rotation.
// Rotation and scaling are handled in GL.
//
// Don't resize the X11 window to match rotation.
// Rotation and scaling are handled in GL.
//
- NSRect f = [self frame];
- double s = self.contentScaleFactor;
+# ifdef USE_IPHONE
+ double s = [self hackedContentScaleFactor];
+# else
+ double s = 1;
+# endif
+ // Store a realistic size in backbuffer_size, though the buffer is minimal.
+ NSRect f = [self bounds];
backbuffer_size.width = (int) (s * f.size.width);
backbuffer_size.height = (int) (s * f.size.height);
backbuffer_size.width = (int) (s * f.size.width);
backbuffer_size.height = (int) (s * f.size.height);
@@
-217,14
+248,7
@@
extern void check_gl_error (const char *type);
CGColorSpaceRelease (cs);
}
}
CGColorSpaceRelease (cs);
}
}
-
-
-- (void) swapBuffers
-{
- glBindRenderbufferOES (GL_RENDERBUFFER_OES, gl_renderbuffer);
- [ogl_ctx presentRenderbuffer:GL_RENDERBUFFER_OES];
-}
-# endif // USE_IPHONE
+# endif // USE_BACKBUFFER
- (void)dealloc {
- (void)dealloc {
@@
-315,6
+339,7
@@
init_GL (ModeInfo *mi)
NSAssert (pixfmt, @"unable to create NSOpenGLPixelFormat");
NSAssert (pixfmt, @"unable to create NSOpenGLPixelFormat");
+ // #### Analyze says: "Potential leak of an object stored into pixfmt"
ctx = [[NSOpenGLContext alloc]
initWithFormat:pixfmt
shareContext:nil];
ctx = [[NSOpenGLContext alloc]
initWithFormat:pixfmt
shareContext:nil];
@@
-326,9
+351,8
@@
init_GL (ModeInfo *mi)
[ctx setValues:&r forParameter:NSOpenGLCPSwapInterval];
// check_gl_error ("NSOpenGLCPSwapInterval"); // SEGV sometimes. Too early?
[ctx setValues:&r forParameter:NSOpenGLCPSwapInterval];
// check_gl_error ("NSOpenGLCPSwapInterval"); // SEGV sometimes. Too early?
- // #### "Build and Analyze" says that ctx leaks, because it doesn't
- // seem to realize that makeCurrentContext retains it (right?)
- // Not sure what to do to make this warning go away.
+ // #### Analyze says: "Potential leak of an object stored into "ctx"
+ // But makeCurrentContext retains it (right?)
[ctx makeCurrentContext];
check_gl_error ("makeCurrentContext");
[ctx makeCurrentContext];
check_gl_error ("makeCurrentContext");
@@
-374,9
+398,9
@@
init_GL (ModeInfo *mi)
eagl_layer.opaque = TRUE;
eagl_layer.drawableProperties =
[NSDictionary dictionaryWithObjectsAndKeys:
eagl_layer.opaque = TRUE;
eagl_layer.drawableProperties =
[NSDictionary dictionaryWithObjectsAndKeys:
- kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
- [NSNumber numberWithBool:!dbuf_p], kEAGLDrawablePropertyRetainedBacking,
- nil];
+
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
+
[NSNumber numberWithBool:!dbuf_p], kEAGLDrawablePropertyRetainedBacking,
+
nil];
// Without this, the GL frame buffer is half the screen resolution!
eagl_layer.contentsScale = [UIScreen mainScreen].scale;
// Without this, the GL frame buffer is half the screen resolution!
eagl_layer.contentsScale = [UIScreen mainScreen].scale;
@@
-387,6
+411,7
@@
init_GL (ModeInfo *mi)
if (!ogl_ctx)
return 0;
[view setOglContext:ogl_ctx];
if (!ogl_ctx)
return 0;
[view setOglContext:ogl_ctx];
+ // #### Analyze says "Potential leak of an object stored into ogl_ctx"
check_gl_error ("OES_init");
check_gl_error ("OES_init");