Пример #1
0
 public void render(Map<TexturedModel, List<Entity>> entities) {
   for (TexturedModel model : entities.keySet()) {
     prepareTexturedModel(model);
     List<Entity> batch = entities.get(model);
     for (Entity entity : batch) {
       prepareInstance(entity);
       GL11.glDrawElements(
           GL11.GL_TRIANGLES, model.getModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
     }
     unbindTexturedModel();
   }
 }
Пример #2
0
  private void prepareTexturedModel(TexturedModel model) {
    RawModel rawModel = model.getModel();
    GL30.glBindVertexArray(rawModel.getVaoID());
    GL20.glEnableVertexAttribArray(0); // vertices array
    GL20.glEnableVertexAttribArray(1); // textures array
    GL20.glEnableVertexAttribArray(2); // normals array

    { // Load Texture and shine
      ModelTexture texture = model.getTexture();
      shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());

      GL13.glActiveTexture(GL13.GL_TEXTURE0);
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureID());
    }
  }