List of usage examples for org.lwjgl.opengl GL13 GL_TEXTURE0
int GL_TEXTURE0
To view the source code for org.lwjgl.opengl GL13 GL_TEXTURE0.
Click Source Link
From source file:cuchaz.jfxgl.prism.TexturedQuad.java
License:Open Source License
public void render() { // bind stuff shader.bind();//ww w . j a va 2s . com GL30.glBindVertexArray(vaoId); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); // draw it! GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_BYTE, 0); // unbind things GL30.glBindVertexArray(0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLTexture.java
License:Open Source License
public void use(int textureUnit) { if (textureUnit >= 0) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + textureUnit); GL11.glBindTexture(GL11.GL_TEXTURE_2D, getTextureId()); }// www . j ava 2s . co m }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLTextureArray.java
License:Open Source License
@Override public void use(int textureUnit) { if (textureUnit >= 0) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + textureUnit); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, getTextureId()); }/* ww w . jav a2 s.c om*/ }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLTextureArrayBuilder.java
License:Open Source License
@Override public GLTextureArray createTexture() { try {//w ww. j a v a2s .c o m int files = filePaths.length; byte[][] imageData = new byte[files][]; int totalSize = 0; int imageWidth = 0; int imageHeight = 0; // read in files for (int file = 0; file < files; file++) { InputStream inputStream = new FileInputStream(filePaths[file]); BufferedImage image = ImageIO.read(inputStream); if (file > 0) if (imageWidth != image.getWidth() | imageHeight != image.getHeight()) ML.f("Incompatible images in 3D texture..."); imageWidth = image.getWidth(); imageHeight = image.getHeight(); imageData[file] = GLPNGLoader.loadPNG(image); totalSize += imageData[file].length; } // store in consecutive buffer ByteBuffer buffer = ByteBuffer.allocateDirect(totalSize); for (int file = 0; file < files; file++) { byte[] singleImageData = imageData[file]; for (int i = 0; i < singleImageData.length; i++) buffer.put(singleImageData[i]); } buffer.flip(); int textureId = GL11.glGenTextures(); GLRenderer2Stage.errorCheck("generating texture id"); GL13.glActiveTexture(GL13.GL_TEXTURE0); GLRenderer2Stage.errorCheck("activating texture image unit"); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, textureId); GLRenderer2Stage.errorCheck("binding 2d texture array"); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GLRenderer2Stage.errorCheck("setting unpack aligment"); GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA, imageWidth, imageHeight, files, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); GLRenderer2Stage.errorCheck("storing 2d texture array data"); GL30.glGenerateMipmap(GL30.GL_TEXTURE_2D_ARRAY); GLRenderer2Stage.errorCheck("generating 2d texture array mipmaps"); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0); GLRenderer2Stage.errorCheck("unbinding 2d texture array"); return new GLTextureArray(name, textureId); } catch (Exception e) { ML.f(e); } return null; }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLTextureBuilder.java
License:Open Source License
public static GLTexture createEmptyTexture(String name, int width, int height, byte r, byte g, byte b, byte a) { try {//w w w . ja va 2 s . c om int textureId = GL11.glGenTextures(); ByteBuffer buffer = ByteBuffer.allocateDirect(width * height * 4); for (int i = 0; i < width * height; i++) { buffer.put(r); buffer.put(g); buffer.put(b); buffer.put(a); } buffer.flip(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); return new GLTexture(name, textureId); } catch (Exception e) { ML.f(e); } return null; }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLTextureBuilder.java
License:Open Source License
public static GLTexture createEmptyTexture(String name, int width, int height, float initial) { try {//from w w w . j av a 2 s . c o m int textureId = GL11.glGenTextures(); ByteBuffer buffer = ByteBuffer.allocateDirect(width * height * 4); for (int i = 0; i < width * height * 4; i++) { buffer.put((byte) 0); } buffer.flip(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, buffer); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); return new GLTexture(name, textureId); } catch (Exception e) { ML.f(e); } return null; }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLTextureBuilder.java
License:Open Source License
private int createRGBTexture(BufferedImage image, byte[] x) { ByteBuffer buffer;// www.j a v a 2s. com buffer = ByteBuffer.allocateDirect(x.length); for (int i = 0; i < x.length; i++) { buffer.put(x[i]); } buffer.flip(); int textureId = GL11.glGenTextures(); GLRenderer2Stage.errorCheck("generating texture id"); GL13.glActiveTexture(GL13.GL_TEXTURE0); GLRenderer2Stage.errorCheck("activating texture image unit"); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GLRenderer2Stage.errorCheck("binding 2d texture"); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); GLRenderer2Stage.errorCheck("setting unpack aligment"); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); GLRenderer2Stage.errorCheck("storing 2d texture data"); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); GLRenderer2Stage.errorCheck("generating 2d texture array mipmaps"); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GLRenderer2Stage.errorCheck("unbinding 2d texture array"); return textureId; }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLTextureBuilder.java
License:Open Source License
private int createGrayscaleTexture(BufferedImage image, byte[] x) { ShortBuffer buffer;/*from ww w .ja v a 2 s. com*/ buffer = BufferUtils.createShortBuffer(image.getHeight() * image.getWidth()); for (int i = 0; i < x.length; i += 2) { short val = (short) (fromByte(x[i]) + (fromByte(x[i + 1]) << 8)); buffer.put(val); } buffer.flip(); int textureId = GL11.glGenTextures(); GLRenderer2Stage.errorCheck("generating texture id"); GL13.glActiveTexture(GL13.GL_TEXTURE0); GLRenderer2Stage.errorCheck("activating texture image unit"); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GLRenderer2Stage.errorCheck("binding 2d texture"); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 2); GLRenderer2Stage.errorCheck("setting unpack aligment"); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL30.GL_R16, image.getWidth(), image.getHeight(), 0, GL11.GL_RED, GL11.GL_UNSIGNED_SHORT, buffer); GLRenderer2Stage.errorCheck("storing 2d texture data"); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); GLRenderer2Stage.errorCheck("generating 2d texture array mipmaps"); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GLRenderer2Stage.errorCheck("unbinding 2d texture array"); return textureId; }
From source file:engine.render.TexturedQuad.java
public void renderQuad() { int shaderID = shader.getProgramID(); GL20.glUseProgram(shaderID);/*from w w w . j a va 2 s. co m*/ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID()); GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboiId); glUniform2f(glGetUniformLocation(shaderID, "scale"), scale.x, scale.y); glUniform2f(glGetUniformLocation(shaderID, "translation"), translation.x, translation.y); glUniform2f(glGetUniformLocation(shaderID, "cameraOffset"), cameraOffset.x, cameraOffset.y); glUniform1f(glGetUniformLocation(shaderID, "rotation"), rotation); glUniform2f(glGetUniformLocation(shaderID, "resolution"), resolution.x, resolution.y); GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL20.glDisableVertexAttribArray(2); GL30.glBindVertexArray(0); glDisable(GL_BLEND); GL20.glUseProgram(0); }
From source file:eu.over9000.veya.rendering.Scene.java
License:Open Source License
public Scene(final long seed) { this.alive = new AtomicBoolean(true); this.world = new World(seed, "Keaysea"); this.texture_handle = TextureLoader.loadBlockTexture(GL13.GL_TEXTURE0); this.shadow = new Shadow(); this.light = new Light(-200, 400, -40, 0.9f, 0.9f, 0.45f, 0.33f, 0.33f, 0.33f); final Runnable displayedChunkUpdater = () -> { while (Scene.this.alive.get()) { synchronized (Scene.this.lock) { try { while (!Scene.this.camPosChanged) { Scene.this.lock.wait(); }/*www . j av a2s .c om*/ } catch (final InterruptedException e) { if (!Scene.this.alive.get()) { return; } e.printStackTrace(); } Scene.this.camPosChanged = false; } Scene.this.updateDisplayedChunks(); world.clearCache(centerChunk, SCENE_CHUNK_CACHE_RANGE); } }; final Runnable offRenderChunkUpdater = () -> { while (Scene.this.alive.get()) { try { final Chunk toUpdate = toUpdateOffRender.take(); ChunkVAO chunkVAO = new ChunkVAO(toUpdate); updatedUpdateOffRender.add(new ChunkChunkVAOPair(toUpdate, chunkVAO)); chunkUpdateCounterOffRender.incrementAndGet(); } catch (InterruptedException e) { if (!Scene.this.alive.get()) { return; } e.printStackTrace(); } } }; this.displayedChunkUpdaterThread = new Thread(displayedChunkUpdater, "DisplayedChunkUpdater"); this.displayedChunkUpdaterThread.start(); this.chunkVAOUpdateOffRenderThread = new Thread(offRenderChunkUpdater, "OffRenderChunkUpdater"); this.chunkVAOUpdateOffRenderThread.start(); }