示例#1
0
文件: Tile.java 项目: joaogl/LD29
  protected void compile() {
    vao = glGenVertexArrays();
    glBindVertexArray(vao);
    {
      vbo = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vbo);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createFloatBuffer(vertices), GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);

      vio = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vio);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createByteBuffer(indices), GL_STATIC_DRAW);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);

      vto = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vto);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createByteBuffer(texCoords), GL_STATIC_DRAW);
        glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, false, 0, 1);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
    glBindVertexArray(0);
  }
示例#2
0
文件: Player.java 项目: joaogl/LD29
  protected void compile() {
    vao = glGenVertexArrays();
    glBindVertexArray(vao);
    {
      vbo = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vbo);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createFloatBuffer(vertices), GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);

      vio = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vio);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createByteBuffer(indices), GL_STATIC_DRAW);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);

      vto = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vto);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createByteBuffer(texCoords), GL_STATIC_DRAW);
        glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, false, 0, 1);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
    glBindVertexArray(0);

    glActiveTexture(GL_TEXTURE1);
    shader.bind();
    int uniform = glGetUniformLocation(shader.getID(), "texture");
    glUniform1i(uniform, 1);
    shader.release();
  }
示例#3
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");
  }