@Override protected void preNextTextureImpl(final GL gl) { psm.setUnpackAlignment(gl, 1); // RGBA ? 4 : 1 gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); }
public static void checkAndSetUnit(final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final GL gl = GLContext.getCurrentGL(); // No need to worry about valid record, since invalidate sets record's // currentUnit to -1. if (record.currentUnit != unit) { if (unit >= caps.getNumberOfTotalTextureUnits() || !caps.isMultitextureSupported() || unit < 0) { // ignore this request as it is not valid for the user's hardware. return; } gl.glActiveTexture(GL.GL_TEXTURE0 + unit); record.currentUnit = unit; } }
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); } }
/** * @param gl * @param textures * @param shaderProgram */ private void disableTextureStates( GL gl, List<FragmentTexture> textures, ShaderProgram shaderProgram ) { // reset non-standard OpenGL states if ( textures != null && textures.size() > 0 ) { for ( int i = textures.size() - 1; i >= 0; --i ) { int textureUnitId = JOGLUtils.getTextureUnitConst( i ); gl.glClientActiveTexture( textureUnitId ); gl.glActiveTexture( textureUnitId ); gl.glDisable( GL.GL_TEXTURE_2D ); gl.glDisableClientState( GL.GL_TEXTURE_COORD_ARRAY ); } // gl.glActiveTexture( GL.GL_TEXTURE0 ); // gl.glClientActiveTexture( GL.GL_TEXTURE0 ); } // rb: shader program can not be null. shaderProgram.disable( 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]); }
private final void swapFBOImpl(final GLContext glc) { final GL gl = glc.getGL(); fbos[fboIBack].markUnbound(); // fast path, use(gl,..) is called below if(DEBUG) { final int _fboIFront = ( fboIFront + 1 ) % fbos.length; if(_fboIFront != fboIBack) { throw new InternalError("XXX: "+_fboIFront+"!="+fboIBack); } } fboIFront = fboIBack; fboIBack = ( fboIBack + 1 ) % fbos.length; final Colorbuffer colorbuffer = samples > 0 ? fbos[fboIFront].getSamplingSink() : fbos[fboIFront].getColorbuffer(0); if(null == colorbuffer) { throw new GLException("Front colorbuffer is null: samples "+samples+", "+this); } final TextureAttachment texAttachment; if( colorbuffer.isTextureAttachment() ) { texAttachment = colorbuffer.getTextureAttachment(); gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit); } else { texAttachment = null; } fbos[fboIFront].use(gl, texAttachment); /* Included in above use command: gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, fbos[fboIBack].getDrawFramebuffer()); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbos[fboIFront].getReadFramebuffer()); } */ if(DEBUG_SWAP) { System.err.println("Post FBO swap(X): fboI back "+fboIBack+", front "+fboIFront+", num "+fbos.length); } }
@Override public final void ppBegin(final GL gl) { if( null == sp ) { throw new IllegalStateException("Not initialized"); } if( 0 == frameStart ) { throw new IllegalStateException("beginFrame not called"); } final GL2ES2 gl2es2 = gl.getGL2ES2(); gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glActiveTexture(GL.GL_TEXTURE0 + getTextureUnit()); gl2es2.glDisable(GL.GL_CULL_FACE); gl2es2.glDisable(GL.GL_DEPTH_TEST); gl2es2.glDisable(GL.GL_BLEND); if( !gl2es2.isGLcore() ) { gl2es2.glEnable(GL.GL_TEXTURE_2D); } sp.useProgram(gl2es2, true); gl2es2.glUniform(texUnit0); }
gl.glActiveTexture( GL.GL_TEXTURE0 ); gl.glEnable( GL.GL_TEXTURE_2D ); gl.glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY ); int textureUnitId = JOGLUtils.getTextureUnitConst( i ); gl.glClientActiveTexture( textureUnitId ); gl.glActiveTexture( textureUnitId ); gl.glEnable( GL.GL_TEXTURE_2D ); gl.glEnableClientState( GL.GL_TEXTURE_COORD_ARRAY );
throw new RuntimeException("TextureName "+toHexString(texName)+" invalid."); gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); gl.glBindTexture(textureTarget, texName);
gl.glActiveTexture(fboTexUnit); fboTexState = new TextureState(gl, fboTexUnit, GL.GL_TEXTURE_2D); } else {