List of usage examples for org.lwjgl.opengl GL11 GL_CLAMP
int GL_CLAMP
To view the source code for org.lwjgl.opengl GL11 GL_CLAMP.
Click Source Link
From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java
License:Open Source License
public static int getGLWrap(final WrapMode wrap, final ContextCapabilities caps) { switch (wrap) { case Repeat:/*from w ww .ja v a 2s. co m*/ return GL11.GL_REPEAT; case MirroredRepeat: if (caps.isTextureMirroredRepeatSupported()) { return ARBTextureMirroredRepeat.GL_MIRRORED_REPEAT_ARB; } else { return GL11.GL_REPEAT; } case MirrorClamp: if (caps.isTextureMirrorClampSupported()) { return EXTTextureMirrorClamp.GL_MIRROR_CLAMP_EXT; } // FALLS THROUGH case Clamp: return GL11.GL_CLAMP; case MirrorBorderClamp: if (caps.isTextureMirrorBorderClampSupported()) { return EXTTextureMirrorClamp.GL_MIRROR_CLAMP_TO_BORDER_EXT; } // FALLS THROUGH case BorderClamp: if (caps.isTextureBorderClampSupported()) { return ARBTextureBorderClamp.GL_CLAMP_TO_BORDER_ARB; } else { return GL11.GL_CLAMP; } case MirrorEdgeClamp: if (caps.isTextureMirrorEdgeClampSupported()) { return EXTTextureMirrorClamp.GL_MIRROR_CLAMP_TO_EDGE_EXT; } // FALLS THROUGH case EdgeClamp: if (caps.isTextureEdgeClampSupported()) { return GL12.GL_CLAMP_TO_EDGE; } else { return GL11.GL_CLAMP; } } throw new IllegalArgumentException("invalid WrapMode type: " + wrap); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glTexParameterf(int target, int pname, float param) { // LwjglGraphics.major is should to be 1 if we are in LwjglGL10. if (LwjglGraphics.minor < 2 && param == GL12.GL_CLAMP_TO_EDGE) param = GL11.GL_CLAMP; GL11.glTexParameterf(target, pname, param); }
From source file:com.badlogic.gdx.backends.lwjgl.swt.LwjglGL10.java
License:Apache License
public final void glTexParameterf(int target, int pname, float param) { // LwjglGraphics.major is should to be 1 if we are in LwjglGL10. if (SwtLwjglGraphics.minor < 2 && param == GL12.GL_CLAMP_TO_EDGE) param = GL11.GL_CLAMP; GL11.glTexParameterf(target, pname, param); }
From source file:com.damagedearth.Utilities.Components.TrueTypeFont.java
License:Open Source License
public static int loadImage(BufferedImage bufferedImage) { try {//from w ww. java 2 s. c o m 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; 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); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } return -1; }
From source file:com.dinasgames.engine.graphics.GL.java
public static int clampToEdge() { if (version >= 12) { return GL12.GL_CLAMP_TO_EDGE; }//www . j a v a 2s .c o m if (version >= 11) { return GL11.GL_CLAMP; } return -1; }
From source file:com.dyonovan.tcnodetracker.lib.truetyper.TrueTypeFont.java
License:Open Source License
public static int loadImage(BufferedImage bufferedImage) { try {//from w w w . j a v a2 s. c o m 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; 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_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_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_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST); 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); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } return -1; }
From source file:com.kauridev.lunarfever.graphics.TextureLoader.java
License:Open Source License
public static Texture loadTexture(String file) { Texture texture = cache.get(file);/*from w w w . j ava2 s .co m*/ if (texture != null && texture.getTexture().valid()) { return texture; } BufferedImage image = loadImage(file); GL11.glEnable(GL11.GL_TEXTURE_2D); int id = GL11.glGenTextures(); // bind GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); // set filter 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); // set wrap 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); // set unpack alignment GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); // send data to gpu GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, loadBuffer(image)); // Create texture texture = new Texture(id, image.getWidth(), image.getHeight()); cache.put(file, texture); return texture; }
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. jav a 2 s . 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:game.engine.gfx.Texture.java
License:Open Source License
/** * Constructor.// w w w .ja va2s . co m * * Note that this constructor changes the currently active texture unit * to GL_TEXTURE_2D to set the texture parameters. * * @param slickTexture the wrapped Slick texture */ public Texture(final org.newdawn.slick.opengl.Texture slickTexture) { this.slickTexture = slickTexture; glBindTexture(); 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_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); }
From source file:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
/** * Sets the texture parameters, assuming that the texture was just created and is bound. */// w ww .j a v a 2 s.c o m private void setTextureParameters() { 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_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f); // prevent writing of transparent pixels to z buffer }