Package thegame.gui.toolkit

Source Code of thegame.gui.toolkit.TextureTK

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package thegame.gui.toolkit;

import net.sf.jiga.xtended.JXAException;
import net.sf.jiga.xtended.impl.Sprite;
import net.sf.jiga.xtended.impl.game.gl.GLHandler;
import net.sf.jiga.xtended.impl.game.gl.Sf3Texture;
import net.sf.jiga.xtended.impl.game.gl.SpriteGLHandler;
import net.sf.jiga.xtended.impl.game.gl.ThreadBlock;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.Util;

/**
*
* @author www.b23prodtm.info
*/
public class TextureTK {

    public final static TextureTK _do = new TextureTK();

    private TextureTK() {
    }
    private ThreadBlock bindings = new ThreadBlock();

    /**
     *
     */
    public void bindTex(SpriteGLHandler spgl) {
        if (GLHandler._GLisTiledTexture(spgl.getTexHash())) {
            throw new JXAException(JXAException.LEVEL.SYSTEM, "This Texture " + spgl + "is tiled in " + spgl.sTex.getTextureTilesCount(spgl.getTexHash()));
        }
        int spLogoName = GLHandler.sTex.getTextureName(spgl.getTexHash()).get(spgl.getTexHash());
        GL11.glBindTexture(Sf3Texture._EXTtex, spLogoName);
        bindings.begin();
        Util.checkGLError();
    }

    /**
     *
     */
    public void unbindTex() {
        bindings.end();
        GL11.glBindTexture(Sf3Texture._EXTtex, 0);
        /**/
    }

    /**
     * change filtering original openGL constants : GL_LINEAR, GL_INTERPOLATE,
     * etc.
     */
    public void changeFiltering(SpriteGLHandler spgl, int glFiltering) {
        assert bindings.isOn() : "not a bound texture";
        GL11.glTexParameteri(Sf3Texture._EXTtex, GL11.GL_TEXTURE_MIN_FILTER, glFiltering);
        GL11.glTexParameteri(Sf3Texture._EXTtex, GL11.GL_TEXTURE_MAG_FILTER, glFiltering);
        Util.checkGLError();
    }
}
TOP

Related Classes of thegame.gui.toolkit.TextureTK

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.