示例#1
0
文件: Tile.java 项目: joaogl/LD29
  public void render(int x, int y, float extra) {
    setExtraLevel(extra);
    glPushMatrix();
    shader.bind();
    glBindVertexArray(vao);
    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
    {
      glTranslatef(x, y, 0);
      glActiveTexture(GL_TEXTURE1);
      glBindTexture(GL_TEXTURE_2D, texture);
      glActiveTexture(GL_TEXTURE2);
      glBindTexture(GL_TEXTURE_2D, Texture.Lava);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vio);
      glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
      glActiveTexture(GL_TEXTURE1);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
      glBindTexture(GL_TEXTURE_2D, 0);

      /*
       * glTranslatef(x, y, 0); glBindTexture(GL_TEXTURE_2D, texture); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vio); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindTexture(GL_TEXTURE_2D, 0);
       */
    }
    glDisableVertexAttribArray(1);
    glDisableVertexAttribArray(0);
    glBindVertexArray(0);
    shader.release();
    glPopMatrix();
  }
示例#2
0
  @Override
  public void flush() {
    if (vertexOffset == 0) {
      return;
    }
    ctx.checkGLError("Shader.flush");

    vertexData.position(0);
    glBufferData(GL_ARRAY_BUFFER, vertexData, GL_STREAM_DRAW);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementData, GL_STREAM_DRAW);
    ctx.checkGLError("Shader.flush BufferData");

    glDrawElements(GL_TRIANGLES, elementOffset, GL_UNSIGNED_SHORT, 0);
    vertexOffset = elementOffset = 0;
    ctx.checkGLError("Shader.flush DrawElements");
  }
示例#3
0
文件: Player.java 项目: joaogl/LD29
 public void render() {
   glPushMatrix();
   glEnable(GL_BLEND);
   shader.bind();
   glBindVertexArray(vao);
   glEnableVertexAttribArray(0);
   glEnableVertexAttribArray(1);
   {
     glTranslatef(x, y, 0);
     glActiveTexture(GL_TEXTURE1);
     glBindTexture(GL_TEXTURE_2D, texture);
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vio);
     glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     glBindTexture(GL_TEXTURE_2D, 0);
   }
   glDisableVertexAttribArray(1);
   glDisableVertexAttribArray(0);
   glBindVertexArray(0);
   shader.release();
   glDisable(GL_BLEND);
   glPopMatrix();
 }