Example usage for org.lwjgl.opengl GL11 glCallLists

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

Introduction

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

Prototype

public static void glCallLists(@NativeType("void const *") IntBuffer lists) 

Source Link

Document

Provides an efficient means for executing a number of display lists.

Usage

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

License:Open Source License

/**
 * <code>print</code> renders the specified string to a given (x,y) location. The x, y location is in terms of
 * screen coordinates. There are currently two sets of fonts supported: NORMAL and ITALICS.
 * //ww  w  . ja v  a  2s  . c  om
 * @param r
 * 
 * @param x
 *            the x screen location to start the string render.
 * @param y
 *            the y screen location to start the string render.
 * @param text
 *            the String to render.
 * @param set
 *            the mode of font: NORMAL or ITALICS.
 */
public void print(final Renderer r, final double x, final double y, final ReadOnlyVector3 scale,
        final StringBuffer text, int set) {
    final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord();
    if (set > 1) {
        set = 1;
    } else if (set < 0) {
        set = 0;
    }

    final boolean alreadyOrtho = r.isInOrthoMode();
    if (!alreadyOrtho) {
        r.setOrtho();
    } else {
        LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
    }
    GL11.glTranslated(x, y, 0);
    GL11.glScaled(scale.getX(), scale.getY(), scale.getZ());
    GL11.glListBase(base - 32 + (128 * set));

    // Put the string into a "pointer"
    if (text.length() > scratch.capacity()) {
        scratch = BufferUtils.createByteBuffer(text.length());
    } else {
        scratch.clear();
    }

    final int charLen = text.length();
    for (int z = 0; z < charLen; z++) {
        scratch.put((byte) text.charAt(z));
    }
    scratch.flip();
    GL11.glColor4f(fontColor.getRed(), fontColor.getGreen(), fontColor.getBlue(), fontColor.getAlpha());
    // call the list for each letter in the string.
    GL11.glCallLists(scratch);
    // set color back to white
    GL11.glColor4f(1, 1, 1, 1);

    if (!alreadyOrtho) {
        r.unsetOrtho();
    } else {
        LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW);
        GL11.glPopMatrix();
    }
}

From source file:net.kubin.rendering.GLFont.java

License:Apache License

/**
 * Render a text string in 2D over the scene, using the character set
 * created by this GLFont object./*from   w  ww  .  j  ava  2 s  . c o  m*/
 *
 * @see makeFont()
 */
public void print(int x, int y, String msg) {
    if (msg != null) {
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        // enable the charset texture
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        texture.bind();
        // draw the text
        GL11.glTranslatef(x, y, 0); // Position The Text (in pixel coords)
        IntBuffer buffer = BufferUtils.createIntBuffer(msg.length());

        for (int i = 0; i < msg.length(); i++) {
            buffer.put(fontListBase + (msg.charAt(i) - 32));
        }

        buffer.flip();
        GL11.glCallLists(buffer);
        GL11.glPopMatrix();

    }
}

From source file:org.craftmania.rendering.GLFont.java

License:Apache License

/**
 * Render a text string in 2D over the scene, using the character set
 * created by this GLFont object./*from ww w .j a  v a 2 s. co  m*/
 * 
 * @see makeFont()
 */
public void print(int x, int y, String msg) {
    if (msg != null) {
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        // enable the charset texture
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        texture.bind();
        // draw the text
        GL11.glTranslatef(x, y, 0); // Position The Text (in pixel coords)
        IntBuffer buffer = BufferUtils.createIntBuffer(msg.length());
        for (int i = 0; i < msg.length(); i++) {
            buffer.put(fontListBase + (msg.charAt(i) - 32));
        }
        buffer.flip();
        GL11.glCallLists(buffer);
        GL11.glPopMatrix();

    }
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glCallLists(ShortBuffer a) {
    GL11.glCallLists(a);
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glCallLists(IntBuffer a) {
    GL11.glCallLists(a);
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glCallLists(ByteBuffer a) {
    GL11.glCallLists(a);
}

From source file:yk.myengine.optiseq.states.LWJGLFont.java

/**
 * <code>print</code> renders the specified string to a given (x,y)
 * location. The x, y location is in terms of screen coordinates. There are
 * currently two sets of fonts supported: NORMAL and ITALICS.
 *
 * @param x      the x screen location to start the string render.
 * @param y      the y screen location to start the string render.
 * @param scale  scale//from   w  w  w.j av a 2 s .  c  om
 * @param text   the String to render.
 * @param italic the mode of font: NORMAL or ITALICS.
 */
public void print(final int x, final int y, final Vector3f scale, final String text, int italic) {
    //        RendererRecord matRecord = (RendererRecord) DisplaySystem.getDisplaySystem().getCurrentContext().getRendererRecord();
    if (italic > 1) {
        italic = 1;
    } else if (italic < 0) {
        italic = 0;
    }

    //        if (!alreadyOrtho){
    //todo move to outer function
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(0, Display.getDisplayMode().getWidth(), 0, Display.getDisplayMode().getHeight());
    //        }
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glTranslatef(x, y, 0);
    GL11.glScalef(scale.x, scale.y, scale.z);
    //todo: make italic by matrix, instead of additional data!! (matter of principle)
    //also it must be realized in transformation state together with scale factor!
    GL11.glListBase(base - 32 + (128 * italic));

    //Put the string into a "pointer"
    if (text.length() > scratch.capacity()) {
        scratch = BufferUtils.createByteBuffer(text.length());
    } else {
        scratch.clear();
    }

    final int charLen = text.length();
    for (int z = 0; z < charLen; z++) {
        scratch.put((byte) text.charAt(z));
    }
    scratch.flip();
    GL11.glColor4f(fontColor.x, fontColor.y, fontColor.z, fontColor.w);
    //todo move to right place
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    //call the list for each letter in the string.
    GL11.glCallLists(scratch);
    GL11.glDisable(GL11.GL_BLEND);
    //        set color back to white
    //        GL11.glColor4f(fontColor.x, fontColor.y, fontColor.z, fontColor.w);

    //        if (!alreadyOrtho) {
    //todo move to outer function
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    //        }
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
}