Ejemplo n.º 1
0
 private void prepareTexturedModel(TexturedModel model) {
   RawModel rawModel = model.getRawModel();
   GL30.glBindVertexArray(rawModel.getVaoID());
   GL20.glEnableVertexAttribArray(0);
   GL20.glEnableVertexAttribArray(1);
   GL20.glEnableVertexAttribArray(2);
   ModelTexture texture = model.getTexture();
   shader.loadNumberOfRows(texture.getNumberOfRows());
   if (texture.isHasTransparency()) {
     MasterRenderer.disableCulling();
   }
   shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());
   GL13.glActiveTexture(GL13.GL_TEXTURE0);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID());
   shader.loadUseSpecularMap(texture.hasSpecularMap());
   if (texture.hasSpecularMap()) {
     GL13.glActiveTexture(GL13.GL_TEXTURE1);
     GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getSpecularMap());
   }
 }
Ejemplo n.º 2
0
 public void render(Map<TexturedModel, List<Entity>> entities, Matrix4f toShadowMap) {
   shader.loadToShadowSpaceMatrix(toShadowMap);
   for (TexturedModel model : entities.keySet()) {
     prepareTexturedModel(model);
     List<Entity> batch = entities.get(model);
     for (Entity entity : batch) {
       if (entity.isRenderable()) {
         prepareInstance(entity);
         if (SettingHolder.get("cg_debug_polygons").getValueB()) {
           GL11.glDrawElements(
               GL11.GL_LINE_STRIP, model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
         } else {
           GL11.glDrawElements(
               GL11.GL_TRIANGLES, model.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
         }
       }
     }
     unbindTexturedModel();
   }
 }
Ejemplo n.º 3
0
  public void render(Camera camera) {
    shader.start();
    shader.loadViewMatrix(camera);
    GL30.glBindVertexArray(sun.getRawModel().getVaoID());
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    shader.loadBlendFactor();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, redSunTexture);
    billboardRotation(camera);
    GL11.glDrawElements(
        GL11.GL_TRIANGLES, sun.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);

    GL11.glDisable(GL11.GL_BLEND);
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL30.glBindVertexArray(0);
    shader.stop();
  }