02-08-2012 09:10 PM
How can I make the app landscape only?
02-09-2012 09:34 AM
02-09-2012 04:08 PM - edited 02-09-2012 04:08 PM
Where can I find the detailed documentation for all bar properties like that?
Thanks
02-09-2012 04:45 PM - edited 02-09-2012 05:21 PM
UPDATE: OS is correctly launching the app as landscape (checked with a splash screen).
However, the OpenGL system drawing happens in Portrait mode. How can I prevent this?
I tried changing it to landscape..
bbutil_init_egl(screen_cxt, GL_ES_1, LANDSCAPE);
But no difference
Any ideas?
02-09-2012 05:38 PM
I did some further testing OpenGL thinks it's in portrait even though the app's Orientation set to Landscape
AND EGL initialization is set to landscape:
bbutil_init_egl(screen_cxt, GL_ES_1, LANDSCAPE);
//Query width and height of the window surface created by utility code
eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width);
eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height);
width = (float) surface_width;
height = (float) surface_height;
printf("Screen dimensions: %f,%f\n",width, height);
//When app is launched while PlayBook is in portrait mode
//600.000000,1024.000000 -- THIS IS WRONG!
//When app is launched from landscape orientation, it's correct:
//Screen dimensions: 1024.000000,600.000000
How to fix?
02-22-2012 03:46 PM
This could be a race condition. If you're holding the device so that it's in portrait then when you init your app, you might be getting this behaviour because the OS hasn't finished orienting the screen to landscape. The original BB Java stuff has the same issues.
02-23-2012 07:46 AM - edited 02-23-2012 07:49 AM
I have had success setting it in the blackberry-tablet.xml file with this:
<autoOrients>false</autoOrients> <aspectRatio>landscape</aspectRatio>
Good luck!
Jon
02-27-2012 12:19 PM
Have you looked at the GoodCitizen or HelloWorld NDK Samples? GoodCitizen handles orientation changes while HelloWorld locks orientation to lanscape on startup. Depending on what you are trying to achive, you might need to use a combination of techniques outlined in these samples.
The reason your EGLsizes come out wrong is that you dont initialize your libscreen window properly. Please note that libscreen and navigator are two different entities that are responsible for different things. Namely, navigator is responsible for placing you gestures to correct places while libscreen "controls" where (0,0) and your axis are placed in GL.
Take a look at bbutil_init_egl and bbutil_rotate_screen_surface.
Let me know if you have further issues with this.
PS We should have a tutorial on this topic posted some time this week.
02-27-2012 12:36 PM
From my experience this is not exactly correct. I have found it to be a race condition. If your app never caches the screen dimensions and orientation then your good. For example if your app is able to and does respond to all the size and orientation changes by forcing a new layout, then you're likely good.
The games I make are all nailed to one orientation and screen/window size and this information needs to be determined before I proceed in the creation and loading of the game. If you set your Orientation in the bar-descriptor to say landcscape but the user started your app in portrait, then all your dimensions will expressed in Portrait. The Java BB stuff eas the EXACT same, You could call set orientation but you still have to wait for the new orientation to complete. Below is how I'm handling now. I'm to lazy to clean it up but it will give you the gist.
void QnxApp::delayStartupUntilOriented()
{
Properties& config = m_Game.getConfig();
//------------------------------------------------ ----------------------------------------------
// Initialized the bare minimum needed.
//------------------------------------------------ ----------------------------------------------
bps_initialize();
bps_set_verbosity( 1 );
screen_create_context( &m_ScreenContext, 0 );
screen_create_event( &m_ScreenEvent );
navigator_request_events( 0 );
//------------------------------------------------ ----------------------------------------------
// Get the first Display attached.
//------------------------------------------------ ----------------------------------------------
int count = 0;
screen_get_context_property_iv( m_ScreenContext, SCREEN_PROPERTY_DISPLAY_COUNT, &count );
screen_display_t* pScreenDisplays = (screen_display_t*)calloc( count, sizeof(screen_display_t) );
screen_get_context_property_pv( m_ScreenContext, SCREEN_PROPERTY_DISPLAYS, (void**)pScreenDisplays );
m_ScreenDisplay = pScreenDisplays[0];
free( pScreenDisplays );
//------------------------------------------------ ----------------------------------------------
// Wait until we have achieved our desired orientation.
//------------------------------------------------ ----------------------------------------------
int desiredOrient = config.getInteger( Game::CONFIG_DISPLAY_ORIENTATION );
int displayAngle;
screen_get_display_property_iv( m_ScreenDisplay, SCREEN_PROPERTY_ROTATION, &displayAngle );
while( desiredOrient != QnxDisplay::ToOrientation( displayAngle ) )
{
bps_event_t* event = NULL;
bps_get_event( &event, -1 );
screen_get_display_property_iv( m_ScreenDisplay, SCREEN_PROPERTY_ROTATION, &displayAngle );
}
navigator_rotation_lock( true );
}
02-27-2012 12:46 PM
I'd have to check the exact logic you are using, but I guess this is one way to do this.
The way I am forcing landscape in HelloWorld is this :
1. Get current display size
2. Query ORIENTATION env variable (it tells me which orientation I should be in, navigator sets it based on deployment setting)
3. Flip buffer size if I have to
4. Pass ORIENTATION value to libscreen
Note that this approach works in a general case, i.e all devices and deployment rules.