List of usage examples for org.lwjgl.opengl GL11 glGenTextures
public static void glGenTextures(@NativeType("GLuint *") int[] textures)
From source file:com.github.begla.blockmania.world.horizon.Skysphere.java
License:Apache License
private void initTextures() { if (_textureIds == null) { _textureIds = BufferUtils.createIntBuffer(2); GL11.glGenTextures(_textureIds); } }
From source file:com.golden.gamedev.engine.lwjgl.TextureLoader.java
License:Open Source License
/** * Create a new texture ID/*from w ww .ja va 2 s .c o m*/ * * @return A new texture ID */ private int createTextureID() { GL11.glGenTextures(this.textureIDBuffer); return this.textureIDBuffer.get(0); }
From source file:com.grillecube.client.opengl.GLH.java
/** create opengl textures ID */ public static GLTexture glhGenTexture() { IntBuffer buffer = BufferUtils.createIntBuffer(1); GL11.glGenTextures(buffer); GLTexture texture = new GLTexture(buffer.get()); GLH.glhAddObject(texture);/*from w w w . j a va 2s.c o m*/ return (texture); }
From source file:com.owens.oobjloader.lwjgl.TextureLoader.java
License:BSD License
public int convertToTexture(BufferedImage img) { int[] pixels = new int[img.getWidth() * img.getHeight()]; PixelGrabber grabber = new PixelGrabber(img, 0, 0, img.getWidth(), img.getHeight(), pixels, 0, img.getWidth());//from w w w . j av a 2 s. co m try { grabber.grabPixels(); } catch (InterruptedException e) { log.log(SEVERE, "InterruptedException while trying to grab pixels, e=" + e); e.printStackTrace(); return -1; } int bufLen = 0; bufLen = pixels.length * 4; ByteBuffer oglPixelBuf = BufferUtils.createByteBuffer(bufLen); for (int y = img.getHeight() - 1; y >= 0; y--) { for (int x = 0; x < img.getWidth(); x++) { int pixel = pixels[y * img.getWidth() + x]; oglPixelBuf.put((byte) ((pixel >> 16) & 0xFF)); oglPixelBuf.put((byte) ((pixel >> 8) & 0xFF)); oglPixelBuf.put((byte) ((pixel >> 0) & 0xFF)); oglPixelBuf.put((byte) ((pixel >> 24) & 0xFF)); } } oglPixelBuf.flip(); ByteBuffer temp = ByteBuffer.allocateDirect(4); temp.order(ByteOrder.nativeOrder()); IntBuffer textBuf = temp.asIntBuffer(); GL11.glGenTextures(textBuf); int textureID = textBuf.get(0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); 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.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.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, TEXTURE_LEVEL, GL11.GL_RGBA8, img.getWidth(), img.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, oglPixelBuf); return textureID; }
From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.image.TextureHandler.java
License:Apache License
private Integer generateTextureId() { textureIdBuffer.clear();//from w w w . j a va 2 s. c om GL11.glGenTextures(textureIdBuffer); System.out.println("Generating texture id: " + textureIdBuffer.get(0)); return new Integer(textureIdBuffer.get()); }
From source file:espresso3d.engine.fileloaders.E3DImageLoader.java
License:Open Source License
public static E3DTexture loadImageIntoGL(E3DEngine engine, String textureName, Image image) { // Extract The Image BufferedImage tex = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_3BYTE_BGR); Graphics2D g = (Graphics2D) tex.getGraphics(); g.drawImage(image, null, null);// www.j av a 2 s.c om g.dispose(); // Flip Image AffineTransform tx = AffineTransform.getScaleInstance(1, -1); tx.translate(0, -image.getHeight(null)); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); tex = op.filter(tex, null); // Put Image In Memory ByteBuffer scratch = ByteBuffer.allocateDirect(4 * tex.getWidth() * tex.getHeight()); byte data[] = (byte[]) tex.getRaster().getDataElements(0, 0, tex.getWidth(), tex.getHeight(), null); scratch.clear(); scratch.put(data); scratch.rewind(); // Create A IntBuffer For Image Address In Memory IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); GL11.glGenTextures(buf); // Create Texture In OpenGL GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0)); // Typical Texture Generation Using Data From The Image // Linear Filtering GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); // Linear Filtering GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); // Generate The Texture GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, 3, tex.getWidth(), tex.getHeight(), GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch); // GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tex.getWidth(), tex.getHeight(), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch); E3DTexture texture = new E3DTexture(engine, textureName, buf.get(0)); texture.setWidth(image.getWidth(null)); texture.setHeight(image.getHeight(null)); return texture; // Return Image Address In Memory }
From source file:fi.conf.ae.gl.texture.GLTextureRoutines.java
License:LGPL
/** * Request unused OpenGL texture ID's./*from w w w. j a v a2 s . co m*/ * * @param count - How many texture IDs are being requested. * @return Requested texture ID's as integer array. */ public static int[] allocateGLTextureIDs(int count) { if (count > textureIDbuffer.capacity()) { allocateNewTextureIDBuffer(count); } textureIDbuffer.clear(); textureIDbuffer.limit(count); GL11.glGenTextures(textureIDbuffer); int[] textureIDs = new int[count]; for (int i = 0; i < count; i++) { if (!textureIDbuffer.hasRemaining()) break; textureIDs[i] = textureIDbuffer.get(); // preset this texture's minification and magnification filter int prevTextureID = bindTexture(textureIDs[i]); // 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.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_NEAREST); bindTexture(prevTextureID); } return textureIDs; }
From source file:fi.conf.prograts.ar.gl.GLTextureRoutines.java
License:LGPL
/** * Request unused OpenGL texture ID's.//w w w . j a va 2 s . c om * * @param count - How many texture IDs are being requested. * @return Requested texture ID's as integer array. */ public static int[] allocateGLTextureIDs(int count) { if (count > textureIDbuffer.capacity()) { allocateNewTextureIDBuffer(count); } textureIDbuffer.clear(); textureIDbuffer.limit(count); GL11.glGenTextures(textureIDbuffer); int[] textureIDs = new int[count]; for (int i = 0; i < count; i++) { if (!textureIDbuffer.hasRemaining()) break; textureIDs[i] = textureIDbuffer.get(); // preset this texture's minification and magnification filter int prevTextureID = bindTexture(textureIDs[i]); // 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.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); bindTexture(prevTextureID); } return textureIDs; }
From source file:illarion.graphics.lwjgl.TextureAtlasLWJGL.java
License:Open Source License
/** * Get a new texture ID from the OpenGL system. This also registers the * texture in the openGL environment, so it can be used right away. * // ww w . j a va 2 s . c o m * @return the generated openGL texture ID */ private static int getNewTextureID() { texIDBuffer.rewind(); GL11.glGenTextures(texIDBuffer); return texIDBuffer.get(0); }
From source file:im.bci.jnuit.lwjgl.animation.NanimationImage.java
License:Open Source License
public NanimationImage(boolean alpha) { ByteBuffer temp = ByteBuffer.allocateDirect(4); temp.order(ByteOrder.nativeOrder()); IntBuffer intBuffer = temp.asIntBuffer(); GL11.glGenTextures(intBuffer); id = intBuffer.get(0);/*from w w w . j a v a 2s.c om*/ this.alpha = alpha; }