From 33c56918d64641675025d5c00a84cf4d08ef1464 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 24 Apr 2009 00:16:08 +0000 Subject: [PATCH] still tweaking --- panda/src/iphone/Sources.pp | 6 ------ panda/src/iphone/eaglView.mm | 6 ++++++ panda/src/iphone/pview_delegate.mm | 30 +++++++++++++++++++++++++++++- panda/src/iphone/viewController.h | 2 ++ panda/src/iphone/viewController.mm | 2 ++ 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/panda/src/iphone/Sources.pp b/panda/src/iphone/Sources.pp index 326a0609b9..a55e5514fd 100644 --- a/panda/src/iphone/Sources.pp +++ b/panda/src/iphone/Sources.pp @@ -27,9 +27,3 @@ main.mm #end bin_target - -//#begin bin_target -// #define TARGET iphone_pview -// #define SOURCES main.mm -//#end bin_target - diff --git a/panda/src/iphone/eaglView.mm b/panda/src/iphone/eaglView.mm index 3056bc74dd..880a4927bc 100644 --- a/panda/src/iphone/eaglView.mm +++ b/panda/src/iphone/eaglView.mm @@ -100,6 +100,12 @@ NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); return NO; } + + // Make sure the buffer is initially cleared, so we don't look at + // whatever happened to be in the framebuffer. + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + [context presentRenderbuffer:GL_RENDERBUFFER_OES]; return YES; } diff --git a/panda/src/iphone/pview_delegate.mm b/panda/src/iphone/pview_delegate.mm index c0a06bcd9b..e2930e06ed 100644 --- a/panda/src/iphone/pview_delegate.mm +++ b/panda/src/iphone/pview_delegate.mm @@ -30,7 +30,31 @@ PandaFramework framework; int argc = 0; char **argv = NULL; -- (void)applicationDidFinishLaunching:(UIApplication *)application { +void +signal_handler(int i) { + nout << "Caught signal " << i << "\n"; + exit(1); +} + +- (void)applicationDidFinishLaunching: (UIApplication *)application { + ConfigVariableBool pview_trap_signals("pview-trap-signals", false); + if (pview_trap_signals) { + // Set up a signal handler on every signal, so we can report this to + // the log. + struct sigaction sa; + sa.sa_handler = signal_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + for (int i = 1; i < 32; ++i) { + if (sigaction(i, &sa, NULL) < 0) { + ostringstream strm; + strm << "sigaction(" << i << ")"; + perror(strm.str().c_str()); + } + } + } + + // Parse the "command-line arguments" provided in the Config file. ConfigVariableString pview_args("pview-args", ""); argc = pview_args.get_num_words() + 1; typedef char *charp; @@ -49,6 +73,10 @@ char **argv = NULL; [self startAnimation]; } +- (void)applicationDidReceiveMemoryWarning: (UIApplication *)application { + nout << "applicationDidReceiveMemoryWarning\n"; +} + - (void)startAnimation { self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; } diff --git a/panda/src/iphone/viewController.h b/panda/src/iphone/viewController.h index 12b149dc2d..6ad1819dda 100644 --- a/panda/src/iphone/viewController.h +++ b/panda/src/iphone/viewController.h @@ -12,6 +12,8 @@ // //////////////////////////////////////////////////////////////////// +#include "pandabase.h" + #import #import diff --git a/panda/src/iphone/viewController.mm b/panda/src/iphone/viewController.mm index 7666ebdfb3..d79f0cb640 100644 --- a/panda/src/iphone/viewController.mm +++ b/panda/src/iphone/viewController.mm @@ -13,6 +13,7 @@ //////////////////////////////////////////////////////////////////// #import "viewController.h" +#include "pnotify.h" @implementation ControllerDemoViewController @@ -65,6 +66,7 @@ - (void)didReceiveMemoryWarning { [ super didReceiveMemoryWarning ]; /* Add custom low-memory code here */ + nout << "low-memory handler in view controller\n"; } - (void)dealloc {