C++
Файл main.cpp
...
void engine_handle_cmd(struct android_app* app, int32_t cmd)
{
MySettings* pMySettings = (MySettings*)app->userData;
switch (cmd) {
case APP_CMD_INIT_WINDOW:
pMySettings->m_MyGame.OnCreateWindow(app->window);
break;
case APP_CMD_TERM_WINDOW:
pMySettings->m_MyGame.OnCloseWindow();
break;
case APP_CMD_WINDOW_RESIZED:
pMySettings->m_MyGame.OnResizeWindow(app->window);
break;
...
}
}
...
C++
Файл my_game.h
class MyGame
{
...
public: void OnResizeWindow(ANativeWindow* pWindow)
{
int w = ANativeWindow_getWidth(pWindow);
int h = ANativeWindow_getHeight(pWindow);
m_Graphic.SetViewport_WidthHeight(w, h);
}
...
}
C++
Файл graphic.cpp
...
void MyGraphic::SetViewport_WidthHeight(int w, int h)
{
glViewport(0, 0, width, height); // Функция OpenGL
m_Width = w;
m_Height = h;
}
...
C++
Файл graphic.h
class MyGraphic
{
...
public:
void SetViewport_WidthHeight(int w, int h);
...
}