List of usage examples for org.lwjgl.opengl GL11 glGenTextures
@NativeType("void") public static int glGenTextures()
From source file:com.redthirddivision.quad.utils.managers.TextureManager.java
License:Apache License
public TextureManager() { this.id = GL11.glGenTextures(); }
From source file:com.samrj.devil.gl.Texture.java
License:Open Source License
Texture(int target, int binding) { DGL.checkState(); id = GL11.glGenTextures(); this.target = target; this.binding = binding; }
From source file:com.savoycraft.gui.help.Slide.java
License:Open Source License
/** * Load the image and put it on a texture. Can be expensive. *///from w w w .j a v a2 s.c o m public void prepareToShow() { if (!textureLoaded) { texture = GL11.glGenTextures(); Minecraft.getMinecraft().renderEngine.setupTexture(getImage(), texture); textureLoaded = true; } }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private int bindTexture(Node node, String imageData) { int textureId = GL11.glGenTextures(); byte[] bitmap = Base64.decodeBase64(imageData); try {/*from w w w . j a v a 2s.c o m*/ PNGDecoder decoder = new PNGDecoder(new ByteArrayInputStream(bitmap)); int width = decoder.getWidth(); int height = decoder.getHeight(); ByteBuffer buffer = ByteBuffer.allocateDirect(4 * width * height); decoder.decode(buffer, width * 4, Format.RGBA); buffer.flip(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); } catch (IOException e) { e.printStackTrace(); } return textureId; }
From source file:com.telinc1.rpjg.texture.Texture.java
License:Apache License
/** * Creates a blank (transparent black) texture with the given width and height. * //ww w .j a v a2 s . c o m * @param width The width of the texture to generate * @param height The height of the texture to generate * @param minFilter The minification filter to use * @param magFilter The magnification filter to use * @param wrap The wrap mode for the texture. */ protected Texture(int width, int height, int minFilter, int magFilter, int wrap) { GL11.glEnable(this.getTarget()); this.setID(GL11.glGenTextures()); this.setWidth(width); this.setHeight(height); this.bind(); this.setFilter(minFilter, magFilter); this.setWrap(wrap); ByteBuffer buffer = BufferUtils.createByteBuffer(this.getWidth() * this.getHeight() * 4); this.upload(GL11.GL_RGBA, buffer); }
From source file:com.telinc1.rpjg.texture.Texture.java
License:Apache License
/** * Creates a texture out of the given URL. * /*from w w w . j a va 2 s . com*/ * @param image - The location of the image to use. * @param minFilter - The minification filter to use. * @param magFilter - The magnification filter to use. * @param wrap - The wrap mode to use. */ protected Texture(URL image, int minFilter, int magFilter, int wrap) { InputStream input = null; try { input = image.openStream(); PNGDecoder decoder = new PNGDecoder(input); this.setWidth(decoder.getWidth()); this.setHeight(decoder.getHeight()); ByteBuffer buffer = BufferUtils.createByteBuffer(this.getWidth() * this.getHeight() * 4); decoder.decode(buffer, this.getWidth() * 4, PNGDecoder.RGBA); buffer.flip(); GL11.glEnable(this.getTarget()); this.setID(GL11.glGenTextures()); this.bind(); this.setFilter(minFilter, magFilter); this.setWrap(wrap); this.upload(GL11.GL_RGBA, buffer); } catch (IOException e) { e.printStackTrace(); } finally { if (input != null) { try { input.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:com.voxelplugineering.voxelsniper.util.TextureUtilities.java
License:Open Source License
public static int loadPNGTexture(File file, int textureUnit) { ByteBuffer buf = null;// www.ja v a2 s . c o m int tWidth = 0; int tHeight = 0; try { BufferedImage image = ImageIO.read(file); tWidth = image.getWidth(); tHeight = image.getHeight(); buf = imageToRGBABuffer(image); } catch (IOException e) { e.printStackTrace(); if (file.getName().endsWith("debug.png")) { System.exit(-1); } else { return debugTexture; } } // Create a new texture object in memory and bind it int texId = GL11.glGenTextures(); GL13.glActiveTexture(textureUnit); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); // All RGB bytes are aligned to each other and each component is 1 byte GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); // Upload the texture data and generate mip maps (for scaling) GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tWidth, tHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf); GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); // Setup the ST coordinate system GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); // Setup what to do when the texture has to be scaled GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST); OpenGLUtilities.checkGLError("loadPNGTexture"); if (file.getName().endsWith("debug.png")) { debugTexture = texId; } return texId; }
From source file:com.xrbpowered.gl.res.buffers.MultisampleBuffers.java
License:Open Source License
protected void create(int w, int h, int samples, boolean depthBuffer, boolean hdr) { colorMSTexId = GL11.glGenTextures(); GL11.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, colorMSTexId); GL32.glTexImage2DMultisample(GL32.GL_TEXTURE_2D_MULTISAMPLE, samples, hdr ? GL30.GL_RGB16F : GL11.GL_RGB, w, h, false);/* ww w.j a v a 2 s . co m*/ GL11.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, 0); GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, colorMSTexId, 0); depthMSTexId = 0; if (depthBuffer) { depthMSTexId = GL11.glGenTextures(); GL11.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, depthMSTexId); GL32.glTexImage2DMultisample(GL32.GL_TEXTURE_2D_MULTISAMPLE, samples, GL30.GL_DEPTH24_STENCIL8, w, h, false); GL11.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, 0); GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, depthMSTexId, 0); } checkStatus(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); }
From source file:com.xrbpowered.gl.res.buffers.OffscreenBuffers.java
License:Open Source License
protected void create(int w, int h, boolean depthBuffer, boolean hdr) { colorTexId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, colorTexId); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, hdr ? GL30.GL_RGB16F : GL11.GL_RGB, w, h, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, colorTexId, 0);// www . j av a 2s. c o m depthTexId = 0; if (depthBuffer) { depthTexId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTexId); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT16, w, h, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, depthTexId, 0); } checkStatus(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); }
From source file:com.xrbpowered.gl.res.textures.ArrayTexture.java
License:Open Source License
public ArrayTexture(int w, int h, int layers) { this.width = w; this.height = h; this.layers = layers; texId = GL11.glGenTextures(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, texId); intBuffer = ByteBuffer.allocateDirect(4 * w * h * layers).order(ByteOrder.nativeOrder()).asIntBuffer(); }