From: <tr...@us...> - 2011-08-23 13:50:11
|
Revision: 14987 http://alleg.svn.sourceforge.net/alleg/?rev=14987&view=rev Author: trentg Date: 2011-08-23 13:50:00 +0000 (Tue, 23 Aug 2011) Log Message: ----------- Add some extra logging in iphone code. Clean up some formatting. Modified Paths: -------------- allegro/branches/5.1/src/iphone/EAGLView.m allegro/branches/5.1/src/iphone/allegroAppDelegate.m allegro/branches/5.1/src/iphone/iphone_display.c Modified: allegro/branches/5.1/src/iphone/EAGLView.m =================================================================== --- allegro/branches/5.1/src/iphone/EAGLView.m 2011-08-23 06:12:17 UTC (rev 14986) +++ allegro/branches/5.1/src/iphone/EAGLView.m 2011-08-23 13:50:00 UTC (rev 14987) @@ -72,17 +72,23 @@ color_format, kEAGLDrawablePropertyColorFormat, nil]; if (display->flags & ALLEGRO_USE_PROGRAMMABLE_PIPELINE) { + ALLEGRO_INFO("Attempting to create ES2 context\n"); context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; if (context == nil) { + ALLEGRO_WARN("ES2 context could not be created. Attempting to create ES1 context instead.\n"); display->flags &= ~ ALLEGRO_USE_PROGRAMMABLE_PIPELINE; context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; } } else { + ALLEGRO_INFO("Attempting to create ES1 context.\n"); context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; } + + ALLEGRO_INFO("Context is %p\n", context); if (!context || ![EAGLContext setCurrentContext:context]) { + ALLEGRO_ERROR("context is nil or setCurrentContext failed.\n"); [self release]; return; } @@ -234,23 +240,19 @@ -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { (void)event; - //UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer]; // TODO: handle double-clicks (send two events?) - // NSUInteger numTaps = [[touches anyObject] tapCount]; - // Enumerate through all the touch objects. + // NSUInteger numTaps = [[touches anyObject] tapCount]; + // Enumerate through all the touch objects. - for (UITouch *nativeTouch in touches) { - + for (UITouch *nativeTouch in touches) { /* Create new touch_t and associate ID with UITouch. */ touch_t* touch = al_malloc(sizeof(touch_t)); - + touch->touch = nativeTouch; if ([touch_id_set count] != 0) { - touch->id = [touch_id_set firstIndex]; - [touch_id_set removeIndex:touch->id]; } else @@ -264,42 +266,32 @@ if (NULL == primary_touch) primary_touch = nativeTouch; - - _al_iphone_touch_input_handle_begin(touch->id, al_get_time(), - p.x, p.y, primary_touch == nativeTouch, allegro_display); - //_al_iphone_generate_mouse_event(ALLEGRO_EVENT_MOUSE_BUTTON_DOWN, - // p.x, p.y, touch->id, allegro_display); - // _al_iphone_generate_mouse_event(ALLEGRO_EVENT_MOUSE_AXES, - // p.x, p.y, touch->id, allegro_display); - } + _al_iphone_touch_input_handle_begin(touch->id, al_get_time(), + p.x, p.y, primary_touch == nativeTouch, allegro_display); + } } // Handles the continuation of a touch. -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - (void)event; + (void)event; touch_t* touch; - //double now = al_get_time(); - - // Enumerates through all touch objects - for (UITouch *nativeTouch in touches) { - + // Enumerates through all touch objects + for (UITouch *nativeTouch in touches) { if ((touch = find_touch(touch_list, nativeTouch))) { - + CGPoint p = [nativeTouch locationInView:self]; p.x *= al_iphone_get_screen_scale(); p.y *= al_iphone_get_screen_scale(); - + _al_iphone_touch_input_handle_move(touch->id, al_get_time(), - p.x, p.y, primary_touch == nativeTouch, allegro_display); - - //_al_iphone_generate_mouse_event(ALLEGRO_EVENT_MOUSE_AXES, - // p.x, p.y, touch->id, allegro_display); + p.x, p.y, primary_touch == nativeTouch, allegro_display); + } - } + } } // Handles the end of a touch event. @@ -309,33 +301,25 @@ touch_t* touch; - // double now = al_get_time(); - - // Enumerates through all touch objects - for (UITouch *nativeTouch in touches) { - + // Enumerates through all touch objects + for (UITouch *nativeTouch in touches) { if ((touch = find_touch(touch_list, nativeTouch))) { - + CGPoint p = [nativeTouch locationInView:self]; p.x *= al_iphone_get_screen_scale(); p.y *= al_iphone_get_screen_scale(); - - + + _al_iphone_touch_input_handle_end(touch->id, al_get_time(), p.x, p.y, primary_touch == nativeTouch, allegro_display); - -// _al_iphone_generate_mouse_event(ALLEGRO_EVENT_MOUSE_AXES, -// p.x, p.y, touch->id, allegro_display); -// _al_iphone_generate_mouse_event(ALLEGRO_EVENT_MOUSE_BUTTON_UP, -// p.x, p.y, touch->id, allegro_display); - + [touch_id_set addIndex:touch->id]; _al_list_remove(touch_list, touch); - + if (primary_touch == nativeTouch) primary_touch = NULL; } - } + } } // Qooting Apple docs: @@ -343,33 +327,28 @@ // puts the device to his or her face." -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - (void)event; + (void)event; touch_t* touch; - //double now = al_get_time(); - - // Enumerates through all touch objects - for (UITouch *nativeTouch in touches) { - + // Enumerates through all touch objects + for (UITouch *nativeTouch in touches) { if ((touch = find_touch(touch_list, nativeTouch))) { - CGPoint p = [nativeTouch locationInView:self]; + CGPoint p = [nativeTouch locationInView:self]; p.x *= al_iphone_get_screen_scale(); p.y *= al_iphone_get_screen_scale(); - //_al_iphone_generate_mouse_event(ALLEGRO_EVENT_MOUSE_BUTTON_UP, - // p.x, p.y, touch->id, allegro_display); _al_iphone_touch_input_handle_cancel(touch->id, al_get_time(), - p.x, p.y, primary_touch == nativeTouch, allegro_display); - + p.x, p.y, primary_touch == nativeTouch, allegro_display); + if (primary_touch == nativeTouch) - primary_touch = NULL; - + primary_touch = NULL; + [touch_id_set addIndex:touch->id]; _al_list_remove(touch_list, touch); } - } + } } -(BOOL)canBecomeFirstResponder { Modified: allegro/branches/5.1/src/iphone/allegroAppDelegate.m =================================================================== --- allegro/branches/5.1/src/iphone/allegroAppDelegate.m 2011-08-23 06:12:17 UTC (rev 14986) +++ allegro/branches/5.1/src/iphone/allegroAppDelegate.m 2011-08-23 13:50:00 UTC (rev 14987) @@ -91,13 +91,21 @@ */ float al_iphone_get_screen_scale(void) { + float ret = 0.0; + if (scale_override > 0.0) { - return scale_override; + ret = scale_override; } - if ([[UIScreen mainScreen] respondsToSelector:NSSelectorFromString(@"scale")]) { - return [[UIScreen mainScreen] scale]; + else if ([[UIScreen mainScreen] respondsToSelector:NSSelectorFromString(@"scale")]) { + ret = [[UIScreen mainScreen] scale]; } - return 1.0f; + else { + ret = 1.0f; + } + + ALLEGRO_INFO("Screen scale is %f\n", ret); + + return ret; } /* Function: al_iphone_override_screen_scale @@ -105,6 +113,8 @@ void al_iphone_override_screen_scale(float scale) { scale_override = scale; + + ALLEGRO_INFO("Scale overridden. New scale: %f\n", scale); } /* Function: al_iphone_set_statusbar_orientation @@ -251,6 +261,9 @@ splashview = [[UIImageView alloc] initWithImage:img]; [window addSubview:splashview]; } + else { + ALLEGRO_WARN("img is nil in display_splash_screen.\n") + } [window makeKeyAndVisible]; } Modified: allegro/branches/5.1/src/iphone/iphone_display.c =================================================================== --- allegro/branches/5.1/src/iphone/iphone_display.c 2011-08-23 06:12:17 UTC (rev 14986) +++ allegro/branches/5.1/src/iphone/iphone_display.c 2011-08-23 13:50:00 UTC (rev 14987) @@ -15,64 +15,20 @@ void _al_iphone_setup_opengl_view(ALLEGRO_DISPLAY *d) { - int w, h; + int w, h; - //_al_iphone_get_screen_size(&w, &h); + w = d->w; + h = d->h; - w = d->w; - h = d->h; + _al_iphone_reset_framebuffer(); + glViewport(0, 0, w, h); - _al_iphone_reset_framebuffer(); - glViewport(0, 0, w, h); + _screen_w = w; + _screen_h = h; - _screen_w = w; - _screen_h = h; + al_identity_transform(&d->proj_transform); + al_ortho_transform(&d->proj_transform, 0, d->w, d->h, 0, -1, 1); - al_identity_transform(&d->proj_transform); - al_ortho_transform(&d->proj_transform, 0, d->w, d->h, 0, -1, 1); - -#if 0 - /* We automatically adjust the view if the user doesn't use 320x480. Users - * of the iphone port are adviced to provide a 320x480 mode and do their - * own adjustment - but for the sake of allowing ports without knowing - * any OpenGL and not having to change a single character in your - * application - here you go. - */ - if (d->w != w || d->h != h) { - /* FIXME: The transformation is not working 100% correctly ATM */ - double scale = 1, xoff = 0, yoff = 0; - if (d->w >= d->h) { - if (d->w * w > d->h * h) { - scale = h * 1.0 / d->w; - xoff = (w - d->h * scale) * 0.5; - _screen_y = 0.5 * (d->h - w / scale); - } - else { - scale = w * 1.0 / d->h; - yoff = (h - d->w * scale) * 0.5; - _screen_x = 0.5 * (d->w - h / scale); - } - - al_scale_transform(&d->proj_transform, scale, scale); - al_rotate_transform(&d->proj_transform, -M_PI/2); - } - else { - // TODO - } - - if (!_screen_hack) { - _screen_hack = true; - _screen_scale = scale; - _screen_iscale = 1.0 / _screen_scale; - - ALLEGRO_INFO("Auto-scaling/rotating %dx%d display to %.fx%.f screen.\n", - d->w, d->h, _screen_w, _screen_h); - ALLEGRO_DEBUG("x-off:%.f y-off:%.f scale:%.2f\n", _screen_x, - _screen_y, _screen_scale); - } - } -#endif - al_identity_transform(&d->view_transform); if (!(d->flags & ALLEGRO_USE_PROGRAMMABLE_PIPELINE)) { @@ -188,7 +144,7 @@ return; } - system->visuals = al_calloc(VISUALS_COUNT, sizeof(*system->visuals)); + system->visuals = al_calloc(1, VISUALS_COUNT * sizeof(*system->visuals)); system->visuals_count = VISUALS_COUNT; for (int i = 0; i < VISUALS_COUNT; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |