/** * Unbind texture, ie bind 'non' texture 0 * * <p>Leaves the FBO unbound.</p> */ public final void unuse(final GL gl) { unbind(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); // don't use it }
/** * Binds this texture to the given GL context. This method is a * shorthand equivalent of the following OpenGL code: <pre> gl.glBindTexture(texture.getTarget(), texture.getTextureObject()); </pre> * * See the <a href="#perftips">performance tips</a> above for hints * on how to maximize performance when using many Texture objects. * * @param gl the current GL context * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ public void bind(final GL gl) throws GLException { validateTexID(gl, true); gl.glBindTexture(target, texID); }
/** * {@link #syncSamplingSink(GL) Synchronize the sampling sink} and bind the given {@link TextureAttachment}, if not <code>null</code>. * * <p>If using a {@link TextureAttachment} and multiple texture units, ensure you call {@link GL#glActiveTexture(int)} first!</p> * * <p>{@link #syncSamplingSink(GL)} is being called</p> * * <p>Leaves the FBO unbound!</p> * * @param gl the current GL context * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)}, * may be <code>null</code> in case no {@link TextureAttachment} is used. * @throws IllegalArgumentException */ public final void use(final GL gl, final TextureAttachment ta) throws IllegalArgumentException { syncSamplingSink(gl); if( null != ta ) { gl.glBindTexture(GL.GL_TEXTURE_2D, ta.getName()); // use it .. } }
public void bindTexture(Texture tex) { GL gl = gc.getGL(); gl.glActiveTexture(textureUnit); if (!isActive() || tex == null) { gl.glBindTexture(GL.GL_TEXTURE_2D, 0); } else { tex.bind(gl); } }
/** * Restores the texture-unit's texture-target state. * <p> * First the texture-unit is activated, then all states are restored. * </p> * @param gl current GL context's GL object */ public final void restore(final GL gl) { gl.glActiveTexture(state[0]); gl.glBindTexture(target, state[1]); gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, state[2]); gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, state[3]); gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, state[4]); gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, state[5]); }
gl.glBindTexture( GL.GL_TEXTURE_2D, textureID[0] ); gl.glTexParameteri( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP ); gl.glTexParameteri( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP );
public static DncDeviceIconAtlas xferIconAtlasToDevice( DncHostIconAtlas hAtlas, GL gl ) { int textureHandle = genTexture( gl ); gl.glBindTexture( GL_TEXTURE_2D, textureHandle ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); hAtlas.textureImage.pushToTexture( gl, GL_TEXTURE_2D ); return new DncDeviceIconAtlas( hAtlas.chunkKey, hAtlas.entries, textureHandle ); }
gl.glBindTexture( GL_TEXTURE_2D, dTextureHandle ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); gl.glBindTexture( GL_TEXTURE_2D, dTextureHandle );
@Override public boolean bind( DrawContext dc ) { GL gl = dc.getGL( ); gl.glBindTexture( GL2.GL_TEXTURE_2D, textureHandle ); // these settings make fine line drawing against a transparent background appear much more natural // but can make other rendering look too jagged/crisp gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR ); gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR ); gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP_TO_EDGE ); gl.glTexParameterf( GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP_TO_EDGE ); gl.glBlendFuncSeparate( GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA, GL2.GL_ONE, GL2.GL_ONE_MINUS_SRC_ALPHA ); gl.glEnable( GL2.GL_BLEND ); //GlimpseColor.glColor( gl, GlimpseColor.getWhite( 0.5f ) ); return true; }
gl.glBindBufferARB( GL.GL_ARRAY_BUFFER_ARB, glVCB ); gl.glTexCoordPointer( 2, GL.GL_FLOAT, 0, 0 ); gl.glBindTexture( GL.GL_TEXTURE_2D, tId ); gl.glTexParameteri( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE ); gl.glTexParameteri( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE ); gl.glTexCoordPointer( 2, GL.GL_FLOAT, 0, 0 ); gl.glBindTexture( GL.GL_TEXTURE_2D, tId ); gl.glTexParameteri( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE ); gl.glTexParameteri( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE );
private final void freeAllColorbufferImpl(final GL gl) { for(int i=0; i<maxColorAttachments; i++) { final Colorbuffer colbuf = colorbufferAttachments[i]; // shortcut, don't validate here if(null == colbuf) { return; } if( colbuf.isTextureAttachment() ) { final TextureAttachment texA = colbuf.getTextureAttachment(); if( 0 != texA.getName() ) { gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0 + i, GL.GL_TEXTURE_2D, 0, 0); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); } texA.free(gl); } else { final ColorAttachment colA = colbuf.getColorAttachment(); if( 0 != colA.getName() ) { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0 + i, GL.GL_RENDERBUFFER, 0); } colA.free(gl); } } }
gl.glBindTexture(textureTarget, texName);
gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName());
/** * Useful for external jogl based classes that need to safely set the current texture. */ public static void doTextureBind(final Texture texture, final int unit, final boolean invalidateState) { final GL gl = GLContext.getCurrentGL(); // ask for the current state record final RenderContext context = ContextManager.getCurrentContext(); final ContextCapabilities caps = context.getCapabilities(); final TextureStateRecord record = (TextureStateRecord) context.getStateRecord(StateType.Texture); if (invalidateState) { // Set this to null because no current state really matches anymore context.setCurrentState(StateType.Texture, null); } checkAndSetUnit(unit, record, caps); final int id = texture.getTextureIdForContext(context.getGlContextRep()); gl.glBindTexture(getGLType(texture.getType()), id); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1); } if (record != null) { record.units[unit].boundTexture = id; } }
gl.glBindTexture(GL.GL_TEXTURE_2D, name[0]); if( 0 < magFilter ) { gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, magFilter);
public static DncDeviceLabelAtlas xferLabelAtlasToDevice( DncHostLabelAtlas hAtlas, GL gl ) { TexturableImage textureImage = hAtlas.textureImage; int textureHandle = genTexture( gl ); gl.glBindTexture( GL_TEXTURE_2D, textureHandle ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); gl.glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); textureImage.pushToTexture( gl, GL_TEXTURE_2D ); int[] bufferHandles = new int[ 2 ]; gl.glGenBuffers( 2, bufferHandles, 0 ); int entriesAlignHandle = bufferHandles[ 0 ]; gl.glBindBuffer( GL_ARRAY_BUFFER, entriesAlignHandle ); gl.glBufferData( GL_ARRAY_BUFFER, hAtlas.entriesAlignBuf.remaining( ) * SIZEOF_FLOAT, hAtlas.entriesAlignBuf, GL_STATIC_DRAW ); int entriesBoundsHandle = bufferHandles[ 1 ]; gl.glBindBuffer( GL_ARRAY_BUFFER, entriesBoundsHandle ); gl.glBufferData( GL_ARRAY_BUFFER, hAtlas.entriesBoundsBuf.remaining( ) * SIZEOF_FLOAT, hAtlas.entriesBoundsBuf, GL_STATIC_DRAW ); return new DncDeviceLabelAtlas( hAtlas.chunkKey, textureImage.getWidth( ), textureImage.getHeight( ), entriesAlignHandle, entriesBoundsHandle, textureHandle ); }
gl.glBindTexture(texParamTarget, texID); } else { gl.glBindTexture(texTarget, texID);
GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, GL.GL_TEXTURE_2D, 0, 0); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); switch(detachAction) { case DISPOSE:
gl.glBindTexture(getGLType(type), textureId); if (Constants.stats) { StatCollector.addStat(StatType.STAT_TEXTURE_BINDS, 1);