List of usage examples for org.lwjgl.opengl GL11 glTexImage2D
public static void glTexImage2D(@NativeType("GLenum") int target, @NativeType("GLint") int level, @NativeType("GLint") int internalformat, @NativeType("GLsizei") int width, @NativeType("GLsizei") int height, @NativeType("GLint") int border, @NativeType("GLenum") int format, @NativeType("GLenum") int type, @Nullable @NativeType("void const *") double[] pixels)
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glTexImage2D(int a, int b, int c, int d, int e, int f, int g, int h, FloatBuffer i) { GL11.glTexImage2D(a, b, c, d, e, f, g, h, i); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glTexImage2D(int a, int b, int c, int d, int e, int f, int g, int h, DoubleBuffer i) { GL11.glTexImage2D(a, b, c, d, e, f, g, h, i); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glTexImage2D(int a, int b, int c, int d, int e, int f, int g, int h, ByteBuffer i) { GL11.glTexImage2D(a, b, c, d, e, f, g, h, i); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glTexImage2D(int a, int b, int c, int d, int e, int f, int g, int h, long i) { GL11.glTexImage2D(a, b, c, d, e, f, g, h, i); }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glTexImage2D(int a, int b, int c, int d, int e, int f, int g, int h, ShortBuffer i) { GL11.glTexImage2D(a, b, c, d, e, f, g, h, i); }
From source file:v9t9.gui.client.swt.gl.TextureLoader.java
License:Open Source License
/** * Load a texture into OpenGL from a image reference on * disk.//from w w w .ja v a2 s.c om * * @param resourceName The location of the resource to load * @param target The GL target to load the texture against * @param dstPixelFormat The pixel format of the screen * @param minFilter The minimising filter * @param magFilter The magnification filter * @return The loaded texture * @throws IOException Indicates a failure to access the resource */ public Texture getTexture(String resourceName, int target, int dstPixelFormat, int minFilter, int magFilter) throws IOException { int srcPixelFormat = 0; // create the texture ID for this texture int textureID = createTextureID(); Texture texture = new Texture(target, textureID); // bind this texture GL11.glBindTexture(target, textureID); BufferedImage bufferedImage = loadImage(resourceName); texture.setWidth(bufferedImage.getWidth()); texture.setHeight(bufferedImage.getHeight()); if (bufferedImage.getColorModel().hasAlpha()) { srcPixelFormat = GL11.GL_RGBA; } else { srcPixelFormat = GL11.GL_RGB; } // convert that image into a byte buffer of texture data ByteBuffer textureBuffer = convertImageData(bufferedImage, texture); if (target == GL11.GL_TEXTURE_2D) { GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter); GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter); } // produce a texture from the byte buffer GL11.glTexImage2D(target, 0, dstPixelFormat, get2Fold(bufferedImage.getWidth()), get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer); return texture; }
From source file:wrath.client.ClientUtils.java
License:Open Source License
/** * Loads a LWJGL Texture from an image.// w w w.j a va 2 s. c o m * @param image The {@link java.awt.image.BufferedImage} version of the Texture. * @return Returns the LWJGL texture id. */ public static int getTexture(BufferedImage image) { if (image == null) return 0; int[] pixels = new int[image.getWidth() * image.getHeight()]; image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth()); ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * 4); for (int y = 0; y < image.getHeight(); y++) { for (int x = 0; x < image.getWidth(); x++) { int pixel = pixels[y * image.getWidth() + x]; buffer.put((byte) ((pixel >> 16) & 0xFF)); buffer.put((byte) ((pixel >> 8) & 0xFF)); buffer.put((byte) (pixel & 0xFF)); buffer.put((byte) ((pixel >> 24) & 0xFF)); } } buffer.flip(); int id = GL11.glGenTextures(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); 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.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); return id; }
From source file:zildo.fwk.gfx.engine.TextureEngine.java
License:Open Source License
public void generateTexture() { // 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 int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud) GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping); int filtering = GL11.GL_NEAREST; // Linear Filtering GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering); // Generate The Texture GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, textureFormat, 256, 256, 0, textureFormat, GL11.GL_UNSIGNED_BYTE, scratch);// ww w . ja v a 2 s . co m // Reset bytebuffer scratch scratch.clear(); // Store texture id textureTab[n_Texture] = buf.get(0); // Ready for next one n_Texture++; }
From source file:zildo.fwk.opengl.Utils.java
License:Open Source License
public static int generateTexture(int sizeX, int sizeY) { IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); GL11.glGenTextures(buf); // Create Texture In OpenGL int textureID = buf.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.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, adjustTexSize(sizeX), adjustTexSize(sizeY), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); return textureID; }
From source file:zildo.platform.engine.LwjglTextureEngine.java
License:Open Source License
@Override public int doGenerateTexture() { scratch.position(0);/*w w w. j a va 2 s.co m*/ // 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 int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud) GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping); int filtering = GL11.GL_NEAREST; // Linear Filtering GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering); // Generate The Texture GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, getTextureFormat(), 256, 256, 0, getTextureFormat(), GL11.GL_UNSIGNED_BYTE, scratch); return buf.get(0); }