Reputation: 23
In my program in SDL I must get screen size. How I can to do it? On android I cant use
error: initializer element is not constant
int height = Android_ScreenHeight;
is possible initialising it in ndk?
Upvotes: 1
Views: 566
Reputation: 492
You can get screen buffer size :
void android_main(struct android_app* state) {
...
ANativeWindow* window = state->window;
ANativeWindow_Buffer buffer;
// Try lock buffer
if (ANativeWindow_lock(window, &buffer, 0) < 0)
return;
LOGI("buffer info: width = %d height = %d", buffer.width, buffer.height);
// Unlock buffer
ANativeWindow_unlockAndPost(window);
...
}
I know you can also get screen info through other NDK stuff, but this works!
Upvotes: 1