Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
AppStoreLover
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other

Setting initial launch orientation of the app and locking it.

How can I make the app landscape only?

Please use plain text.
BlackBerry Development Advisor (Retired)
cdamus
Posts: 45
Registered: ‎10-25-2010
My Device: Bold 9700
My Carrier: Rogers

Re: Setting initial launch orientation of the app and locking it.

Hi,

Try setting the "Orientation" property on the "Application" page of the bar-descriptor.xml editor to "Landscape".

HTH,

Christian
Please use plain text.
Developer
AppStoreLover
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other

Re: Setting initial launch orientation of the app and locking it.

[ Edited ]

Where can I find the detailed documentation for all bar properties like that?

Thanks

Please use plain text.
Developer
AppStoreLover
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other

Re: Setting initial launch orientation of the app and locking it.

[ Edited ]

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?

Please use plain text.
Developer
AppStoreLover
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other

Re: Setting initial launch orientation of the app and locking it.

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?

 

Please use plain text.
Developer
LMcRae
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: Setting initial launch orientation of the app and locking it.

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.  

 

 

Please use plain text.
Developer
jheron
Posts: 188
Registered: ‎01-27-2012
My Device: playbook
My Carrier: ...

Re: Setting initial launch orientation of the app and locking it.

[ Edited ]

I have had success setting it in the blackberry-tablet.xml file with this:

 

<autoOrients>false</autoOrients>
<aspectRatio>landscape</aspectRatio>

http://docs.blackberry.com/en/developers/deliverables/23959/Configuring_your_application_1524626_11....

Good luck!

Jon

Please use plain text.
BlackBerry Development Advisor (Retired)
dtomilovskiy
Posts: 36
Registered: ‎10-26-2011
My Device: RIM Developer
My Carrier: Rogers

Re: Setting initial launch orientation of the app and locking it.

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.

 

Please use plain text.
Developer
LMcRae
Posts: 163
Registered: ‎04-16-2009
My Device: Not Specified

Re: Setting initial launch orientation of the app and locking it.

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 );
}

 

 

 

 

Please use plain text.
BlackBerry Development Advisor (Retired)
dtomilovskiy
Posts: 36
Registered: ‎10-26-2011
My Device: RIM Developer
My Carrier: Rogers

Re: Setting initial launch orientation of the app and locking it.

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.

Please use plain text.