List of usage examples for org.lwjgl.opengl GL11 glGenTextures
public static void glGenTextures(@NativeType("GLuint *") int[] textures)
From source file:im.bci.jnuit.lwjgl.LwjglNuitFont.java
License:Open Source License
public static int loadImage(BufferedImage bufferedImage) { short width = (short) bufferedImage.getWidth(); short height = (short) bufferedImage.getHeight(); // textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? // (byte)32 : (byte)24; int bpp = (byte) bufferedImage.getColorModel().getPixelSize(); ByteBuffer byteBuffer;//from w w w .ja va 2s.co m DataBuffer db = bufferedImage.getData().getDataBuffer(); if (db instanceof DataBufferInt) { int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData(); byte newI[] = new byte[intI.length * 4]; for (int i = 0; i < intI.length; i++) { byte b[] = intToByteArray(intI[i]); int newIndex = i * 4; newI[newIndex] = b[1]; newI[newIndex + 1] = b[2]; newI[newIndex + 2] = b[3]; newI[newIndex + 3] = b[0]; } byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) .put(newI); } else { byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData()); } byteBuffer.flip(); int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA; IntBuffer textureId = BufferUtils.createIntBuffer(1); GL11.glGenTextures(textureId); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0)); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer); return textureId.get(0); }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glGenTextures(IntBuffer ids) { GL11.glGenTextures(ids); }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glGenTextures(int n, IntBuffer textures) { GL11.glGenTextures(textures); }
From source file:ion2d.INTexture2D.java
License:Open Source License
/** * Creates the actual OpenGL texture to memory *//*from w ww . ja v a2 s . com*/ protected void createTexture() { this.convertToPowerOfTwo(); if (this.texture != null) { IntBuffer tmp = BufferUtils.createIntBuffer(1); GL11.glGenTextures(tmp); this.id = tmp.get(0); this.bind(); int src = GL11.GL_RGBA; if (!this.image.getBufferedImage().getColorModel().hasAlpha()) { src = GL11.GL_RGB; } GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); this.setAntiAlias(); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, src, this.width, this.height, 0, src, GL11.GL_UNSIGNED_BYTE, this.texture); } }
From source file:map.GameMap.java
License:Open Source License
private void renderMinimap() { int size = MINIMAP_SIZE; Texture tex = new Texture("ground"); miniMap = new Material(name + "_minimap"); int[] viewport = GLUtils.getViewport(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity();/*from ww w. j av a 2 s. c o m*/ GL11.glOrtho(0, size, size, 0, -10, 10); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glViewport(0, 0, size, size); GL11.glClearColor(0.0f, 0, 0, 1.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glScalef(size / tiles.length, size / tiles.length, size / tiles.length); GLUtils.glLightPos(1.0f, 1.0f, 1.0f); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_CULL_FACE); draw(null); GL11.glEnable(GL11.GL_CULL_FACE); IntBuffer addr = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); GL11.glGenTextures(addr); tex.setID(addr.get(0)); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getID()); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, 0, 0, size, size, 0); miniMap.setTexture(0, tex); GL11.glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); }
From source file:mwisbest.openbase.opengl.TextureLoader.java
License:Open Source License
/** * Create a new texture ID; will increase the value for getTextureCount. * /*from ww w .jav a 2s.c o m*/ * @return A new texture ID */ public static int createTextureID() { IntBuffer tmp = createIntBuffer(1); GL11.glGenTextures(tmp); textureCount++; return tmp.get(0); }
From source file:net.neilcsmith.praxis.video.opengl.internal.Texture.java
License:Apache License
private static int createGLHandle() { buffer.position(0); buffer.limit(buffer.capacity()); GL11.glGenTextures(buffer); return buffer.get(0); }
From source file:net.smert.frameworkgl.opengl.helpers.TextureHelper.java
License:Apache License
public void create(IntBuffer textureIDs) { GL11.glGenTextures(textureIDs); }
From source file:org.jmangos.tools.openGL.TextureLoader.java
License:Open Source License
/** * Create a new texture ID//from www. j av a2 s. co m * * @return A new texture ID */ private int createTextureID() { final IntBuffer tmp = createIntBuffer(1); try { GL11.glGenTextures(tmp); } catch (final NullPointerException e) { // e.printStackTrace(); Sys.alert("Error", "Your system is not capable of running this game.\nPlease make sure your video drivers are current."); System.exit(0); } return tmp.get(0); }
From source file:org.jtrfp.mtmx.internal.TextureLoader.java
License:Open Source License
private int createTextureId() { IntBuffer textureId = BufferUtils.createIntBuffer(1); GL11.glGenTextures(textureId); return textureId.get(); }