natiny_window_set_orientation
void natiny_window_set_orientation(NatinyWindow id, uint32_t allowed);
Sets the screen orientations that an Android device may use for the window.
Parameters
| Name | Type | Description |
|---|---|---|
id |
NatinyWindow |
Window handle from natiny_window_create |
allowed |
uint32_t |
Nonzero mask of the orientation constants below, combined with bitwise OR (|) |
Orientations
| Constant | Value | Meaning |
|---|---|---|
NATINY_ORIENTATION_PORTRAIT |
1 |
Portrait with the device in its natural orientation |
NATINY_ORIENTATION_PORTRAIT_FLIPPED |
2 |
Reverse portrait |
NATINY_ORIENTATION_LANDSCAPE |
4 |
Landscape with the device in its natural rotation |
NATINY_ORIENTATION_LANDSCAPE_FLIPPED |
8 |
Reverse landscape |
NATINY_ORIENTATION_ANY |
15 |
Any portrait or landscape orientation |
One constant locks the screen to one orientation. Combining constants allows
the device to rotate between them. After a rotation,
natiny_window_get_width and
natiny_window_get_height report the new dimensions.
Example
NatinyWindow win = natiny_window_create("My Game", 1280, 720);
/* Allow both landscape orientations, but no portrait orientation. */
natiny_window_set_orientation(win, NATINY_ORIENTATION_LANDSCAPE |
NATINY_ORIENTATION_LANDSCAPE_FLIPPED);
Notes
- The call has no effect on desktop or web builds.
- A zero mask or a mask containing bits outside
NATINY_ORIENTATION_ANYis rejected with a message onstderrand changes nothing. - Android cannot represent combinations such as portrait plus one landscape orientation. Natiny maps such combinations to all four orientations.
- The Android system rotation lock can prevent an allowed rotation.
natiny_window_get_orientationreturns the current orientation, not theallowedmask.- The APK manifest controls the initial orientation. This call changes the
policy after
mainstarts. - Rotating recreates the Android drawable and swapchain, but existing Natiny handles remain valid.