Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Half of the landscape mode's width only on Android

This thread is locked; no one can reply to it. rss feed Print
Half of the landscape mode's width only on Android
CRAZY CONDITIONS
Member #16,385
June 2016
avatar

Hello, I'm using the C4droid c compiler app from Play Store and its Allegro Plugin to write Android Apps on the Android phone itself.

The portrait Mode works, in the landscape mode only the left Side (half of the Display width) is used by the Allegro graphics Commands. It seems the width and height of the portrait Mode is used and Not of the landscape mode.

And: how can I geht the real device Display Resolution (real width and height of the device) with Allegro?

Elias
Member #358
May 2000

It sounds like maybe an unhandled ALLEGRO_EVENT_DISPLAY_RESIZE event? The screen size will not change until you respond to that event.

Otherwise, can you describe in more detail when this is happening? Is the phone in portrait mode and the app starts in landscape mode?

If you have some example project to reproduce that could also be helpful.

--
"Either help out or stop whining" - Evert

CRAZY CONDITIONS
Member #16,385
June 2016
avatar

After al_init() I only have:

al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS,ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE,ALLEGRO_REQUIRE);

ALLEGRO_DISPLAY__App=al_create_display(1440,720);

al_clear_to_color(al_map_rgba(0,0,63,255));

al_flip_display();

That's all.
1440*720 is my device resolution.
So, I think ist's what you mean with 'phone is in portrait mode and the app starts in landscape mode'.
The graphical result is that at start the program changes top landscape mode and then only the left half of the screen is cleared in the color.
If I change the phone to landscape mode BEFORE starting the app, landscape mode works and the whole display is cleared to the color, the right half of the display, too.

Another problem:
The function 'al_get_num_display_modes' terminates the app, regardless where I put it in the program.

Elias
Member #358
May 2000

Try adding this to the <activity> element in your AndroidManifest.xml:

android:screenOrientation="landscape"

So for example it will look like this:

<activity android:name=".MainActivity" android:screenOrientation="landscape">

This will tell Android that the app can only work in landscape mode.

(It may be a bug that al_set_new_display_option can't force the initial orientation currently.)

Also, for mobile platforms it does not make sense creating a display with a fixed size because every phone will have a different size. Instead you should create your window with ALLEGRO_FULLSCREEN_WINDOW and pass 0/0 for the width/height parameters, so for example:

al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW);
al_create_display(0, 0);

[Edit:]
al_get_num_display_modes() is not implemented on Android, you should report it as a bug.

--
"Either help out or stop whining" - Evert

CRAZY CONDITIONS
Member #16,385
June 2016
avatar

I can Not manipulate the manifest file, C4droid c compiler Managers all Android specific parts of the program, I Just write a c program in 'Allegro mode' and the Compiler does the rest to produce an installable APK.

So how can I handle the Problem with the resize in Startup alternatively?
You said handle a resize Event? How is it done in the program?

Elias
Member #358
May 2000

Yes, basically remove the ALLEGRO_SUPPORTED_ORIENTATIONS line and then react to ALLEGRO_EVENT_DISPLAY_RESIZE, like here: https://github.com/liballeg/allegro5/blob/master/examples/ex_android.c#L211

There is still some other manifest settings required by Allegro apps though, hopefully c4droid makes them for you, for example it needs to listen to some config changes:

android:configChanges="screenLayout|uiMode|orientation|screenSize"

--
"Either help out or stop whining" - Evert

CRAZY CONDITIONS
Member #16,385
June 2016
avatar

There is definately a bug in Allegro for Android.

It's simple: When starting in landscape mode (SUPPORTED ORIENTATIONS LANDSCAPE), Sometimes the width and height are correct and Sometimes wrong (al_get_display_width/al_get_display_height).
Don't know what to do. It Changes initially to landscape mode and then these two functions Return wrong width and/or height...

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

CRAZY CONDITIONS
Member #16,385
June 2016
avatar

Now it seems the width and height returned by the get display width and height are always correct (in display structure?), but the actual width and height available is still that of portrait mode...
I use Rest(2) after create display, also use Flip Display after creating Display, I continue Testing...

Okay there is No solution Allegro sucks and is of No use to me, I can Not Post anymore, too don't Know why I'm Out Here.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Relax, would ya?

Can you provide basic test code for us?

Also, Allegro is under development, that means not everything always works.

But the sooner you cooperate with us, and learn to be patient, we can help you.

By the way, you can post now.

(You can't double post on this forum, only edit and send to top)

CRAZY CONDITIONS
Member #16,385
June 2016
avatar

Thanks, I decided to restart with Allegro and I'll post my program Code and comment it, can screenshots be posted Here? That would be useful in that Case.

amarillion
Member #940
January 2001
avatar

Yes, you can post screenshots. Use the 'Drop attachments here' button in the comment form. You can embed an attached image using <img src=...>, and fill in the link to the attachment.

Go to: