1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.graphics.g3d.utils; 18 19 import com.badlogic.gdx.graphics.GLTexture; 20 import com.badlogic.gdx.graphics.Texture; 21 22 /** Responsible for binding textures, may implement a strategy to avoid binding a texture unnecessarily. A TextureBinder may decide 23 * to which texture unit it binds a texture. 24 * @author badlogic, Xoppa */ 25 public interface TextureBinder { 26 /** Prepares the binder for operation, must be matched with a call to {@link #end()}. */ begin()27 public void begin (); 28 29 /** Disables all used texture units and unbinds textures. Resets the counts. */ end()30 public void end (); 31 32 /** Binds the texture to an available unit and applies the filters in the descriptor. 33 * @param textureDescriptor the {@link TextureDescriptor} 34 * @return the unit the texture was bound to */ bind(TextureDescriptor textureDescriptor)35 public int bind (TextureDescriptor textureDescriptor); 36 37 /** Binds the texture to an available unit. 38 * @param texture the {@link Texture} 39 * @return the unit the texture was bound to */ bind(GLTexture texture)40 public int bind (GLTexture texture); 41 42 /** @return the number of binds actually executed since the last call to {@link #resetCounts()} */ getBindCount()43 public int getBindCount (); 44 45 /** @return the number of binds that could be avoided by reuse */ getReuseCount()46 public int getReuseCount (); 47 48 /** Resets the bind/reuse counts */ resetCounts()49 public void resetCounts (); 50 } 51