# ifndef USE_IPHONE
[NSOpenGLContext clearCurrentContext];
# endif // !USE_IPHONE
+
+ clear_gl_error(); // This hack is defunct, don't let this linger.
}
}
+#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;
# 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);
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) animateOneFrame
{
+# ifdef USE_IPHONE
UIGraphicsPushContext (backbuffer);
+#endif
+
[self render_x11];
+
+# ifdef USE_IPHONE
UIGraphicsPopContext();
+#endif
}
// 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
+ NSRect f = [self bounds];
backbuffer_size.width = (int) (s * f.size.width);
backbuffer_size.height = (int) (s * f.size.height);
CGColorSpaceRelease (cs);
}
}
-
-
-- (void) swapBuffers
-{
- glBindRenderbufferOES (GL_RENDERBUFFER_OES, gl_renderbuffer);
- [ogl_ctx presentRenderbuffer:GL_RENDERBUFFER_OES];
-}
# endif // USE_IPHONE
*/
-// redefine these now since they don't work when not inside an ObjC method.
+// redefine NSAssert, etc. here since they don't work when not inside
+// an ObjC method.
#undef NSAssert
#undef NSAssert1
#undef NSAssert2
-#define NSAssert(CC,S) do { if (!(CC)) { NSLog(S); abort();}} while(0)
-#define NSAssert1(CC,S,A) do { if (!(CC)) { NSLog(S,A); abort();}} while(0)
-#define NSAssert2(CC,S,A,B) do { if (!(CC)) { NSLog(S,A,B);abort();}} while(0)
+#define NSASS(S) \
+ jwxyz_abort ("%s", [(S) cStringUsingEncoding:NSUTF8StringEncoding])
+#define NSAssert(CC,S) do { if (!(CC)) { NSASS((S)); }} while(0)
+#define NSAssert1(CC,S,A) do { if (!(CC)) { \
+ NSASS(([NSString stringWithFormat: S, A])); }} while(0)
+#define NSAssert2(CC,S,A,B) do { if (!(CC)) { \
+ NSASS(([NSString stringWithFormat: S, A, B])); }} while(0)
/* Called by OpenGL savers using the XLockmore API.