Example usage for org.lwjgl.opengl GL11 GL_NEAREST

List of usage examples for org.lwjgl.opengl GL11 GL_NEAREST

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 GL_NEAREST.

Prototype

int GL_NEAREST

To view the source code for org.lwjgl.opengl GL11 GL_NEAREST.

Click Source Link

Document

TextureMagFilter

Usage

From source file:a1.gui.GUI_Map.java

License:Open Source License

public void DoCreate() {
    IntBuffer tt = BufferUtils.createIntBuffer(1);
    GL11.glGenTextures(tt);/* ww  w .  java 2 s .  c om*/
    LightMap = tt.get(0);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, LightMap);
    ByteBuffer bb = BufferUtils.createByteBuffer(1024 * 1024 * 4);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, 1024, 1024, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
            bb);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    Render2D.CheckError();
}

From source file:a1.utils.TilesDebug.java

License:Open Source License

public static void ParseTilesXML(InputStream in) {
    boolean is_ext = true;

    // ?    -   ? 
    if (in == null) {
        is_ext = false;//  w w  w . j a va 2  s .  c  o  m

        in = Resource.binary.get("tiles").get_stream();
    }

    //  ? ?? ?
    for (int i = 0; i < Resource.TILES_MAX; i++) {
        Resource.tile_sets[i] = null;
    }

    // ? ?
    MapCache.Reset();

    // ? 
    try {
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(in);
        doc.getDocumentElement().normalize();

        NodeList nList = doc.getElementsByTagName("tile");
        int type;
        String texture_name;
        for (int temp = 0; temp < nList.getLength(); temp++) {

            Node nNode = nList.item(temp);
            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                Element eElement = (Element) nNode;

                type = Integer.parseInt(eElement.getAttributeNode("type").getNodeValue());
                texture_name = eElement.getAttributeNode("texture").getNodeValue();

                // ?     ?
                if (is_ext) {
                    //  ? ? 
                    File tf = new File(texture_name + ".png");
                    InputStream fin = new FileInputStream(tf);
                    Texture tex = TextureLoader.getTexture("PNG", fin, GL11.GL_NEAREST);
                    Resource.textures.put(texture_name, tex);
                }

                Resource.tile_sets[type] = new ResTile(type, texture_name, eElement);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        Log.info("ERROR: load tiles.xml");
        //  ?  -    
        Config.dev_tile_mode = false;
    }
}

From source file:betterfonts.GlyphCache.java

License:Open Source License

/**
 * Allocate a new OpenGL texture for caching pre-rendered glyph images. The new texture is initialized to fully transparent
 * white so the individual glyphs images within can have a transparent border between them. The new texture remains bound
 * after returning from the function./*from   ww w . j a  v  a 2  s  .co  m*/
 *
 * @todo use GL_ALPHA4 if anti-alias is turned off for even smaller textures
 */
private void allocateGlyphCacheTexture() {
    /* Initialize the background to all white but fully transparent. */
    glyphCacheGraphics.clearRect(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);

    /* Allocate new OpenGL texure */
    singleIntBuffer.clear();
    GL11.glGenTextures(singleIntBuffer);
    textureName = singleIntBuffer.get(0);

    /* Load imageBuffer with pixel data ready for transfer to OpenGL texture */
    updateImageBuffer(0, 0, TEXTURE_WIDTH, TEXTURE_HEIGHT);

    /*
     * Initialize texture with the now cleared BufferedImage. Using a texture with GL_ALPHA8 internal format may result in
     * faster rendering since the GPU has to only fetch 1 byte per texel instead of 4 with a regular RGBA texture.
     */
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureName);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, imageBuffer);

    /* Explicitely disable mipmap support becuase updateTexture() will only update the base 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);
}

From source file:com.ardor3d.framework.lwjgl.LwjglHeadlessCanvas.java

License:Open Source License

public void draw() {
    // bind correct fbo
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,
            _useMSAA ? _msfboID : _fboID);

    // Make sure this OpenGL context is current.
    ContextManager.switchContext(this);
    try {/*from ww w  .  ja v  a 2  s  .  c  om*/
        _buff.makeCurrent();
    } catch (final LWJGLException ex) {
        ex.printStackTrace();
    }

    // make sure camera is set
    if (Camera.getCurrentCamera() != _camera) {
        _camera.update();
    }
    _camera.apply(_renderer);

    // clear buffers
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    _renderer.clearBuffers(Renderer.BUFFER_COLOR | Renderer.BUFFER_DEPTH);

    // draw our scene
    _scene.renderUnto(_renderer);
    _renderer.flushFrame(false);

    // if we're multisampled, we need to blit to a non-multisampled fbo first
    if (_useMSAA) {
        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferBlit.GL_DRAW_FRAMEBUFFER_EXT, _fboID);
        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferBlit.GL_READ_FRAMEBUFFER_EXT, _msfboID);
        EXTFramebufferBlit.glBlitFramebufferEXT(0, 0, _settings.getWidth(), _settings.getHeight(), 0, 0,
                _settings.getWidth(), _settings.getHeight(),
                GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT,
                GL11.GL_NEAREST);

        // get ready to read non-msaa fbo
        EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _fboID);
    }

    // read data from our color buffer
    _data.rewind();
    GL11.glReadBuffer(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT);
    GL11.glReadPixels(0, 0, _settings.getWidth(), _settings.getHeight(), GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE,
            _data);

    // release our FBO.
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
}

From source file:com.ardor3d.renderer.lwjgl.LwjglTextureRenderer.java

License:Open Source License

@Override
protected void blitMSFBO() {
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferBlit.GL_READ_FRAMEBUFFER_EXT, _msfboID);
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferBlit.GL_DRAW_FRAMEBUFFER_EXT, _fboID);
    EXTFramebufferBlit.glBlitFramebufferEXT(0, 0, _width, _height, 0, 0, _width, _height,
            GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT, GL11.GL_NEAREST);

    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferBlit.GL_READ_FRAMEBUFFER_EXT, 0);
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferBlit.GL_DRAW_FRAMEBUFFER_EXT, 0);
    EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
}

From source file:com.ardor3d.scene.state.lwjgl.util.LwjglTextureUtil.java

License:Open Source License

public static int getGLMagFilter(final MagnificationFilter magFilter) {
    switch (magFilter) {
    case Bilinear:
        return GL11.GL_LINEAR;
    case NearestNeighbor:
    default:/*from  ww  w .  j  a va  2s .  c  o  m*/
        return GL11.GL_NEAREST;

    }
}

From source file:com.ardor3d.scene.state.lwjgl.util.LwjglTextureUtil.java

License:Open Source License

public static int getGLMinFilter(final MinificationFilter filter) {
    switch (filter) {
    case BilinearNoMipMaps:
        return GL11.GL_LINEAR;
    case Trilinear:
        return GL11.GL_LINEAR_MIPMAP_LINEAR;
    case BilinearNearestMipMap:
        return GL11.GL_LINEAR_MIPMAP_NEAREST;
    case NearestNeighborNoMipMaps:
        return GL11.GL_NEAREST;
    case NearestNeighborNearestMipMap:
        return GL11.GL_NEAREST_MIPMAP_NEAREST;
    case NearestNeighborLinearMipMap:
        return GL11.GL_NEAREST_MIPMAP_LINEAR;
    }//from  www .  j av a  2 s  .c  om
    throw new IllegalArgumentException("invalid MinificationFilter type: " + filter);
}

From source file:com.colonycraft.TextureStorage.java

License:Apache License

public static Texture loadTexture(String id, String format, InputStream in) throws IOException {
    Texture t = TextureLoader.getTexture(format, in, GL11.GL_NEAREST);
    map.put(id, t);//from  w w  w  .  j a  v  a2  s  . c om
    return t;
}

From source file:com.colonycraft.TextureStorage.java

License:Apache License

public static Texture loadTexture(String id, BufferedImage bi) throws IOException {
    Texture t = BufferedImageUtil.getTexture(id, bi, GL11.GL_TEXTURE_2D, // target
            GL11.GL_RGBA8, // dest pixel format
            GL11.GL_NEAREST, // min filter (unused)
            GL11.GL_NEAREST);/* w  w w.j  a v  a  2s.  co  m*/
    map.put(id, t);
    return t;
}

From source file:com.dinasgames.engine.graphics.Texture.java

public boolean create(int width, int height) {

    if (width == 0 && height == 0) {
        return false;
    }// w w  w. ja  v a2s. com

    Vector2i actualSize = new Vector2i(getValidSize(width), getValidSize(height));

    int maxSize = getMaximumSize();
    if ((actualSize.x > maxSize) || (actualSize.y > maxSize)) {
        System.out.println("Failed to create texture, its internal size is too high (" + actualSize.x + ", "
                + actualSize.y + ") maximum is (" + maxSize + ", " + maxSize + ")");
        return false;
    }

    mWidth = width;
    mHeight = height;
    mActualWidth = actualSize.x;
    mActualHeight = actualSize.y;
    mPixelsFlipped = false;

    if (mTexture <= 0) {
        mTexture = GL11.glGenTextures();
    }

    int textureEdgeClamp = GL.clampToEdge();

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, mTexture);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, mActualWidth, mActualHeight, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, 0);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
            (mRepeated ? GL11.GL_REPEAT : textureEdgeClamp));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
            (mRepeated ? GL11.GL_REPEAT : textureEdgeClamp));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,
            (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,
            (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
    mCacheId = getUniqueId();

    return true;

}