Java tutorial
/* * Copyright (C) 2013 Clemens-Alexander Brust IT-Dienstleistungen * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package de.ikosa.mars.viewer.glviewer.engine; import de.ikosa.mars.util.ML; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import org.lwjgl.opengl.GL13; import org.lwjgl.opengl.GL30; public class GLTextureArray extends GLTexture { public GLTextureArray(String name, int textureId) { super(name, textureId); } @Override public void use(int textureUnit) { if (textureUnit >= 0) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + textureUnit); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, getTextureId()); } } @Override public int getSizeX() { use(0); return GL11.glGetTexLevelParameteri(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_TEXTURE_WIDTH); } @Override public int getSizeY() { use(0); return GL11.glGetTexLevelParameteri(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_TEXTURE_HEIGHT); } public int getSizeZ() { use(0); return GL11.glGetTexLevelParameteri(GL12.GL_TEXTURE_3D, 0, GL12.GL_TEXTURE_DEPTH); } @Override public float[][] toHeightMap(int samplesX, int samplesY) { ML.f("Cannot convert 3D texture to height map!"); return null; } }