List of usage examples for org.lwjgl.opengl GL11 glTexParameteri
public static void glTexParameteri(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLint") int param)
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Texture.java
License:MIT License
@Override public void setFilters(FilterMode minFilter, FilterMode magFilter) { checkCreated();/*from w ww.ja va2 s. com*/ if (minFilter == null) { throw new IllegalArgumentException("Min filter cannot be null"); } if (magFilter == null) { throw new IllegalArgumentException("Mag filter cannot be null"); } if (magFilter.needsMipMaps()) { throw new IllegalArgumentException("Mag filter cannot require mipmaps"); } this.minFilter = minFilter; // Bind the texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); // Set the min and max texture filters GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, minFilter.getGLConstant()); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, magFilter.getGLConstant()); // Unbind the texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Texture.java
License:MIT License
@Override public void setCompareMode(CompareMode compareMode) { checkCreated();/*w w w. j a va 2 s.c om*/ if (compareMode == null) { throw new IllegalArgumentException("Compare mode cannot be null"); } // Bind the texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); // Note: GL14.GL_COMPARE_R_TO_TEXTURE and GL30.GL_COMPARE_REF_TO_TEXTURE are the same, just a different name // No need for a different call in the GL30 implementation GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_COMPARE_MODE, GL14.GL_COMPARE_R_TO_TEXTURE); // Set the compare mode GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_COMPARE_FUNC, compareMode.getGLConstant()); // Unbind the texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.foudroyantfactotum.mod.fousarchive.midi.generation.MidiTexture.java
License:Open Source License
@Override public void loadTexture(IResourceManager resourceManager) throws IOException { final int xSize = getSmallTextureSize(); final int ySize = 88; byte[] res = null; try (final InputStream io = resourceManager.getResource(rl).getInputStream()) { res = getMidiTrack(io, xSize, ySize); } catch (InvalidMidiDataException e) { e.printStackTrace();/* w w w. jav a 2 s. co m*/ } if (res != null) { this.deleteGlTexture(); GlStateManager.bindTexture(this.getGlTextureId()); final ByteBuffer bb = (ByteBuffer) BufferUtils.createByteBuffer(res.length).put(res).flip(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0); 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.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0f); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, 0.0f); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0f); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, xSize, ySize, 0, GL11.GL_RGB, GL11.GL_BYTE, bb); } }
From source file:com.github.begla.blockmania.world.horizon.Skysphere.java
License:Apache License
private void loadStarTextures() { int internalFormat = GL11.GL_RGBA8, format = GL12.GL_BGRA; GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, _textureIds.get(0)); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL12.GL_TEXTURE_WRAP_R, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); for (int i = 0; i < 6; i++) { byte[] data = TextureManager.getInstance().getTexture("stars" + (i + 1)).getTextureData(); ByteBuffer byteBuffer = BufferUtils.createByteBuffer(data.length); byteBuffer.put(data);/*from w ww .ja v a 2 s . com*/ byteBuffer.flip(); GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internalFormat, 256, 256, 0, format, GL11.GL_UNSIGNED_BYTE, byteBuffer); } }
From source file:com.github.kajdreef.mazerunnermvn.Object.GameObject.java
protected void setTextureUnit(Texture texture, int textureUnit) { // Create a new texture object in memory and bind it texId = GL11.glGenTextures();/* w w w . j a v a2s.c o m*/ 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, texture.getWidth(), texture.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, texture.getTexBuffer()); 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_LINEAR_MIPMAP_LINEAR); }
From source file:com.golden.gamedev.engine.lwjgl.TextureLoader.java
License:Open Source License
/** * Load a texture into OpenGL from a image reference on disk. * /*from w ww. j a v a 2 s. com*/ * @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(BufferedImage image, int target, int dstPixelFormat, int minFilter, int magFilter) { int srcPixelFormat = 0; // create the texture ID for this texture int textureID = this.createTextureID(); Texture texture = new Texture(target, textureID); // bind this texture GL11.glBindTexture(target, textureID); texture.setWidth(image.getWidth()); texture.setHeight(image.getHeight()); srcPixelFormat = (image.getColorModel().hasAlpha()) ? GL11.GL_RGBA : GL11.GL_RGB; // convert that image into a byte buffer of texture data ByteBuffer textureBuffer = this.convertImageData(image, 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, this.get2Fold(image.getWidth()), this.get2Fold(image.getHeight()), 0, srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer); return texture; }
From source file:com.golemgame.properties.fengGUI.AppearanceDisplayer.java
License:Open Source License
private void drawScaledTintedImage(Graphics g, IOpenGL gl, ITexture texture, ColorRGBA color, int x, int y, int width, int height) { x += g.getTranslation().getX();//ww w . java 2 s . c o m y += g.getTranslation().getY(); gl.enableTexture2D(true); { //gl.setTexEnvModeModulate(); } colorBuffer.clear(); colorBuffer.put(color.r).put(color.g).put(color.b).put(color.a); colorBuffer.rewind(); texture.bind(); GL11.glTexEnv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, colorBuffer); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);//inform gl that no mipmaps are being used. // GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_BLEND); // GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, // GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL); gl.startQuads(); float startY = 0.0f; // top float startX = 0.0f; // left float endY = 1.0f; // bottom float endX = 1.0f; // right int rWidth = width; int rHeight = height; // fit into clip - both the polygon to render (x,y,x+w,y+h) AND the // texture (0,0->1,1) Rectangle clipSpace = g.getClipSpace(); if (x < clipSpace.getX()) { rWidth -= clipSpace.getX() - x; startX = (float) (clipSpace.getX() - x) / (float) width; x = clipSpace.getX(); } if (x + rWidth > clipSpace.getX() + clipSpace.getWidth()) { rWidth = clipSpace.getX() + clipSpace.getWidth() - x; endX = (float) rWidth / (float) width; } if (y < clipSpace.getY()) { rHeight -= clipSpace.getY() - y; endY = (float) rHeight / (float) height; y = clipSpace.getY(); } if (y + rHeight > clipSpace.getY() + clipSpace.getHeight()) { rHeight = clipSpace.getY() + clipSpace.getHeight() - y; startY = (float) (height - rHeight) / (float) height; } gl.texCoord(startX, endY); gl.vertex(x, y); gl.texCoord(startX, startY); gl.vertex(x, rHeight + y); gl.texCoord(endX, startY); gl.vertex(rWidth + x, rHeight + y); gl.texCoord(endX, endY); gl.vertex(rWidth + x, y); gl.end(); gl.enableTexture2D(false); }
From source file:com.google.gapid.glviewer.gl.Texture.java
License:Apache License
public Texture setMinMagFilter(int min, int mag) { bind();//from w w w . j a va 2 s . c om GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, min); GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, mag); return this; }
From source file:com.google.gapid.glviewer.gl.Texture.java
License:Apache License
public Texture setWrapMode(int wrapS, int wrapT) { bind();//from w w w . j a v a 2 s .com GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, wrapS); GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, wrapT); return this; }
From source file:com.grillecube.client.opengl.GLTexture.java
public final void parameteri(int target, int pname, int param) { GL11.glTexParameteri(target, pname, param); }