Beispiel #1
0
  @Override
  public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    Log.v("SDL", "onWindowFocusChanged(): " + hasFocus);

    SDLActivity.mHasFocus = hasFocus;
    if (hasFocus) {
      SDLActivity.handleResume();
    }
  }
Beispiel #2
0
  @Override
  protected void onResume() {
    Log.v("SDL", "onResume()");
    super.onResume();

    if (SDLActivity.mBrokenLibraries) {
      return;
    }

    SDLActivity.handleResume();
  }
Beispiel #3
0
  @Override
  public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    Log.v("SDL", "onWindowFocusChanged(): " + hasFocus);

    if (SDLActivity.mBrokenLibraries) {
      return;
    }

    SDLActivity.mHasFocus = hasFocus;
    if (hasFocus) {
      SDLActivity.handleResume();
    }
  }
Beispiel #4
0
 @Override
 protected void onResume() {
   Log.v("SDL", "onResume()");
   super.onResume();
   SDLActivity.handleResume();
 }
Beispiel #5
0
  // Called when the surface is resized
  @Override
  public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    Log.v("SDL", "surfaceChanged()");

    int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default
    switch (format) {
      case PixelFormat.A_8:
        Log.v("SDL", "pixel format A_8");
        break;
      case PixelFormat.LA_88:
        Log.v("SDL", "pixel format LA_88");
        break;
      case PixelFormat.L_8:
        Log.v("SDL", "pixel format L_8");
        break;
      case PixelFormat.RGBA_4444:
        Log.v("SDL", "pixel format RGBA_4444");
        sdlFormat = 0x15421002; // SDL_PIXELFORMAT_RGBA4444
        break;
      case PixelFormat.RGBA_5551:
        Log.v("SDL", "pixel format RGBA_5551");
        sdlFormat = 0x15441002; // SDL_PIXELFORMAT_RGBA5551
        break;
      case PixelFormat.RGBA_8888:
        Log.v("SDL", "pixel format RGBA_8888");
        sdlFormat = 0x16462004; // SDL_PIXELFORMAT_RGBA8888
        break;
      case PixelFormat.RGBX_8888:
        Log.v("SDL", "pixel format RGBX_8888");
        sdlFormat = 0x16261804; // SDL_PIXELFORMAT_RGBX8888
        break;
      case PixelFormat.RGB_332:
        Log.v("SDL", "pixel format RGB_332");
        sdlFormat = 0x14110801; // SDL_PIXELFORMAT_RGB332
        break;
      case PixelFormat.RGB_565:
        Log.v("SDL", "pixel format RGB_565");
        sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565
        break;
      case PixelFormat.RGB_888:
        Log.v("SDL", "pixel format RGB_888");
        // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead?
        sdlFormat = 0x16161804; // SDL_PIXELFORMAT_RGB888
        break;
      default:
        Log.v("SDL", "pixel format unknown " + format);
        break;
    }

    mWidth = width;
    mHeight = height;
    SDLActivity.onNativeResize(width, height, sdlFormat);
    Log.v("SDL", "Window size:" + width + "x" + height);

    // Set mIsSurfaceReady to 'true' *before* making a call to handleResume
    SDLActivity.mIsSurfaceReady = true;

    if (SDLActivity.mSDLThread == null) {
      // This is the entry point to the C app.
      // Start up the C app thread and enable sensor input for the first time

      SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread");
      enableSensor(Sensor.TYPE_ACCELEROMETER, true);
      SDLActivity.mSDLThread.start();
    } else {
      // The app already exists, we resume via handleResume
      // Multiple sequential calls to surfaceChanged are handled internally by handleResume

      SDLActivity.handleResume();
    }
  }