O'Reilly logo

Android NDK Beginner's Guide - Second Edition by Sylvain Ratabouil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – adapting resolution with off-screen rendering

Let's render the game scene off-screen:

  1. Change jni/GraphicsManager.hpp, followed by these steps:
    • Define new getter methods for the screen width and height with their corresponding member variables
    • Create a new function initializeRenderBuffer(), which creates an off-screen buffer to render the scene:
      ...
      class GraphicsManager {
      public:
          ...
          int32_t getRenderWidth() { return mRenderWidth; }s
          int32_t getRenderHeight() { return mRenderHeight; }
          int32_t getScreenWidth() { return mScreenWidth; }
          int32_t getScreenHeight() { return mScreenHeight; }
          GLfloat* getProjectionMatrix() { return mProjectionMatrix[0]; }
      
      ...
  2. While still being in the same file, follow these steps:
    • Declare a new RenderVertex ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required