1 /* xscreensaver, Copyright (c) 1991-2015 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
12 #ifndef __JWXYZ_COCOA_H__
13 #define __JWXYZ_COCOA_H__
15 #import "XScreenSaverView.h"
18 # import <UIKit/UIKit.h>
19 # define NSView UIView
20 # define NSOpenGLContext EAGLContext
25 struct jwxyz_Drawable {
26 enum { WINDOW, PIXMAP } type;
32 XScreenSaverView *view;
33 int last_mouse_x, last_mouse_y;
37 void *cgc_buffer; // the bits to which CGContextRef renders
42 #elif defined JWXYZ_GL
44 struct jwxyz_Drawable {
45 enum { WINDOW, PIXMAP } type;
46 /* OS X: Contexts are unique for each pixmap, 'cause life is hectic. (OS X
47 appears to dislike it when you attach different pbuffers to the
48 same context one after the other, apparently.) The Window has this
49 CFRetained because of garbage collection. For both Pixmaps and
50 Windows, CFRelease this when done.
51 iOS: ogl_ctx here is set to either XScreenSaverView.ogl_ctx or
52 XRootWindow()->window.ogl_ctx_pixmap. No garbage collection antics
53 here, so no need to CFRetain anything. Plus, if a screenhack leaks
54 a Pixmap (and they do that all the time), ogl_ctx_pixmap will also
55 get leaked if a Pixmap CFRetains this.
57 NSOpenGLContext *ogl_ctx; // OpenGL rendering context (OS X)
59 // TODO: Also on OS X as extensions.
60 GLuint gl_framebuffer, gl_renderbuffer;
66 XScreenSaverView *view;
67 int last_mouse_x, last_mouse_y;
68 struct jwxyz_Drawable *current_drawable;
70 NSOpenGLPixelFormat *pixfmt;
73 NSOpenGLContext *ogl_ctx_pixmap;
79 NSOpenGLPixelBuffer *gl_pbuffer;
80 // GLuint blit_texture; // TODO: For blitting from Pbuffers
89 extern void create_framebuffer (GLuint *gl_framebuffer,
90 GLuint *gl_renderbuffer);
91 extern void check_framebuffer_status (void);
94 #define jwxyz_window_view(w) ((w)->window.view)