예제 #1
0
  private void initShader() throws Exception {
    String vertexShaderSource =
        ResourceUtil.getResourceFileAsString("/shader/screenQuadVert.glsl", this.getClass());
    String fragmentShaderSource =
        ResourceUtil.getResourceFileAsString("/shader/screenQuadFrag.glsl", this.getClass());
    uiShader = ShaderProgram.buildProgram(vertexShaderSource, fragmentShaderSource);

    GLHelper.checkAndThrow();
  }
예제 #2
0
  public void onDraw(double elapsedMillis, GameArena arena, Level gameLevel) {
    glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_ENABLE_BIT);
    glDisable(GL_DEPTH_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    drawPlayerIcons(gameLevel.getPlayer(), elapsedMillis);

    drawLabels(elapsedMillis, arena, gameLevel);

    GLHelper.checkAndThrow();

    glPopAttrib();
  }
예제 #3
0
  public void init() {
    try {
      initVertexBuffer();
      initShader();
      initTextures();

      font = new TrueTypeFont("font/computer_pixel-7.ttf", 42f);
      fontBig = new TrueTypeFont("font/computer_pixel-7.ttf", 80f);
      font.init();
      fontBig.init();
    } catch (Exception e) {
      log.error("Initialization failed!", e);
    }

    GLHelper.checkAndThrow();
  }
예제 #4
0
  private void initVertexBuffer() {
    float[] position = {
      // Left bottom triangle
      -1f,
      1f,
      0f,
      -1f,
      -1f,
      0f,
      1f,
      -1f,
      0f,
      // Right top triangle
      1f,
      -1f,
      0f,
      1f,
      1f,
      0f,
      -1f,
      1f,
      0f
    };

    float[] texCoord = {
      // Left bottom triangle
      0f, 1f,
      0f, 0f,
      1f, 0f,
      // Right top triangle
      1f, 0f,
      1f, 1f,
      0f, 1f
    };
    VertexBufferObject quadPosVbo = VertexBufferObject.create(position);
    quadPosVbo.addAttribBinding(new VertexAttribBinding(VertexAttribBinding.POSITION_INDEX, 3));

    VertexBufferObject quadTexVbo = VertexBufferObject.create(texCoord);
    quadTexVbo.addAttribBinding(new VertexAttribBinding(VertexAttribBinding.TEX_COORD_INDEX, 2));

    quadVao = VertexArrayObject.create(Arrays.asList(quadPosVbo, quadTexVbo));

    GLHelper.checkAndThrow();
  }
예제 #5
0
  private void initTextures() throws Exception {
    textureCache = new TextureCache();
    playerTexture = textureCache.get("/textures/ufoBlue.png");

    GLHelper.checkAndThrow();
  }