【发布时间】:2015-05-22 08:31:05
【问题描述】:
在我的 SDL 程序中,我必须获取屏幕尺寸。 我该怎么做? 在安卓上我无法使用
error: initializer element is not constant
int height = Android_ScreenHeight;
可以在ndk中初始化吗?
【问题讨论】:
标签: android c android-ndk sdl-2
在我的 SDL 程序中,我必须获取屏幕尺寸。 我该怎么做? 在安卓上我无法使用
error: initializer element is not constant
int height = Android_ScreenHeight;
可以在ndk中初始化吗?
【问题讨论】:
标签: android c android-ndk sdl-2
您可以获得屏幕缓冲区大小:
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);
...
}
我知道你也可以通过其他 NDK 的东西来获取屏幕信息,但这很有效!
【讨论】: