Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package game.skybox.lwjgl; import dataAccess.lwjgl.VAO_Loader; import game.entity.models.RawModel; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL30; import org.lwjgl.util.vector.Matrix4f; /** * * @author Blackened */ public class SkyboxRenderer extends SkyboxShader { //<editor-fold defaultstate="collapsed" desc="Static Properties"> private static final float SIZE = 500f; private static final float[] VERTICES = { -SIZE, SIZE, -SIZE, -SIZE, -SIZE, -SIZE, SIZE, -SIZE, -SIZE, SIZE, -SIZE, -SIZE, SIZE, SIZE, -SIZE, -SIZE, SIZE, -SIZE, -SIZE, -SIZE, SIZE, -SIZE, -SIZE, -SIZE, -SIZE, SIZE, -SIZE, -SIZE, SIZE, -SIZE, -SIZE, SIZE, SIZE, -SIZE, -SIZE, SIZE, SIZE, -SIZE, -SIZE, SIZE, -SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, -SIZE, SIZE, -SIZE, -SIZE, -SIZE, -SIZE, SIZE, -SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, -SIZE, SIZE, -SIZE, -SIZE, SIZE, -SIZE, SIZE, -SIZE, SIZE, SIZE, -SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, SIZE, -SIZE, SIZE, SIZE, -SIZE, SIZE, -SIZE, -SIZE, -SIZE, -SIZE, -SIZE, -SIZE, SIZE, SIZE, -SIZE, -SIZE, SIZE, -SIZE, -SIZE, -SIZE, -SIZE, SIZE, SIZE, -SIZE, SIZE }; private static String[] TEXTURE_FILES = { "right", "left", "top", "bottom", "back", "front" }; //</editor-fold> private Matrix4f projectionMatrix; private RawModel cube; private int texture; public SkyboxRenderer(Matrix4f projectionMatrix) { this.projectionMatrix = projectionMatrix; cube = VAO_Loader.loadToVAO(VERTICES, 3); texture = VAO_Loader.loadCubeMap(TEXTURE_FILES); this.start(); this.loadUniformMatrix("projectionMatrix", this.projectionMatrix); this.stop(); } public void render() { GL30.glBindVertexArray(cube.getVaoID()); GL20.glEnableVertexAttribArray(0); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texture); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, cube.getVertexCount()); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); } }