Exemple #1
0
    @Override
    public void render() {
      Gdx.gl.glClearColor(1, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
      sharedSpriteBatch
          .getProjectionMatrix()
          .setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
      sharedSpriteBatch.begin();
      sharedSpriteBatch.draw(
          sharedTexture, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY() - 1);
      sharedSpriteBatch.end();

      if (Gdx.input.justTouched()) {
        Lwjgl3Application app = (Lwjgl3Application) Gdx.app;
        Lwjgl3WindowConfiguration config = new Lwjgl3WindowConfiguration();
        DisplayMode mode = Gdx.graphics.getDisplayMode();
        config.setWindowPosition(
            MathUtils.random(0, mode.width - 640), MathUtils.random(0, mode.height - 480));
        config.setTitle("Child window");
        Class clazz = childWindowClasses[MathUtils.random(0, childWindowClasses.length - 1)];
        ApplicationListener listener = null;
        try {
          listener = (ApplicationListener) clazz.newInstance();
        } catch (Throwable t) {
          new GdxRuntimeException("Couldn't instantiate app listener", t);
        }
        Lwjgl3Window window = app.newWindow(listener, config);
      }
    }
 public boolean removeWindow(String id) {
   for (int i = 0; i < windows.size; i++) {
     Lwjgl3Application app = windows.get(i);
     if (app.id.equals(id)) {
       app.exit();
       return true;
     }
   }
   return false;
 }
  void initContext(Lwjgl3Application app) {
    if (app.init == false) {

      glfwMakeContextCurrent(app.graphics.window);
      app.context = GLContext.createFromCurrent();
      app.graphics.initGL();
      app.graphics.show();
      app.init = true;
    }
  }
  void initWindow(Lwjgl3Application app) {

    app.graphics.initWindow();
    if (shareContext == true && Lwjgl3Graphics.contextShare == 0) {
      Lwjgl3Graphics.contextShare = app.graphics.window;
    }
    app.initStaticVariables();

    app.input.addCallBacks();
    app.addCallBacks();
    app.windowListener = listener;
  }
  public void addWindow(final String id, final Lwjgl3Application app) {
    if (app.autoloop) // cannot have a running loop
    return;

    Thread thisThread = Thread.currentThread();

    if (thisThread == mainThread) {
      if (getWindow(id) == null) {
        app.id = id;
        queueWindows.add(app);
      }
    } else {
      Runnable run =
          new Runnable() {

            @Override
            public void run() {
              if (getWindow(id) == null) {
                app.id = id;
                queueWindows.add(app);
              }
            }
          };
      postMainRunnable(run);
    }
  }