List of usage examples for org.lwjgl.opengl GL11 glBindTexture
public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture)
From source file:cuchaz.jfxgl.prism.TexturedQuad.java
License:Open Source License
public void render() { // bind stuff shader.bind();// w ww. j a va2s. c o m 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:dataAccess.lwjgl.VAO_Loader.java
public static int loadCubeMap(String... textureFiles) { int texID = GL11.glGenTextures(); GL13.glActiveTexture(texID);//from w w w . ja va2 s. co m GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texID); for (int i = 0; i < textureFiles.length; i++) { TextureData data = dataAccess.fileLoaders.TextureLoader .decodeTextureFile("res/textures/skybox/" + textureFiles[i] + ".png"); GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data.getBuffer()); } GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); textureMap.put("cubeMap", texID); return texID; }
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()); }/*w w w . j a v a 2 s . 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()); }/* w ww. j av a2 s . c o m*/ }
From source file:de.ikosa.mars.viewer.glviewer.engine.GLTextureArrayBuilder.java
License:Open Source License
@Override public GLTextureArray createTexture() { try {// w w w. j ava 2 s. c om 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 {//from w w w . j a v a 2 s.c o m 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 a v a 2s. 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;//from w w w. j a v a 2 s . co m 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;// www . ja va2s. co m 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:de.sanandrew.mods.turretmod.client.shader.ShaderItemAlphaOverride.java
License:Creative Commons License
public void call(int shader) { TextureManager texMgr = Minecraft.getMinecraft().renderEngine; int alphaUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "alpha"); int imageUniform = ARBShaderObjects.glGetUniformLocationARB(shader, "image"); OpenGlHelper.setActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texMgr.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).getGlTextureId()); ARBShaderObjects.glUniform1iARB(imageUniform, 0); ARBShaderObjects.glUniform1fARB(alphaUniform, this.alphaMulti); }