Example usage for org.lwjgl.opengl GL11 glVertex2f

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

Introduction

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

Prototype

public static native void glVertex2f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y);

Source Link

Document

Specifies a single vertex between #glBegin Begin and #glEnd End by giving its coordinates in two dimensions.

Usage

From source file:org.ajgl.graphics.Immediate.java

License:Open Source License

/**
 * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. 
 * Note that {@code colorValues} should have four values per vertex.
 * @param beginMode - OpenGL begin mode/*from   www  .ja va 2s . c o  m*/
 * @param textureID - The texture id to be used
 * @param vertexValues - Array of vertices
 * @param colorValues - Array of color vertices
 * @param textureValues - Array of local texture vertices
 */
@OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated")
public static void twoPointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues,
        float[] colorValues, float[] textureValues) {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    GL11.glBegin(beginMode);
    for (int i = 0, j = 0; i < vertexValues.length - 1; i += 2, j += 4) {
        GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]);
        GL11.glTexCoord2f(textureValues[i], textureValues[i + 1]);
        GL11.glVertex2f(vertexValues[i], vertexValues[i + 1]);
    }
    GL11.glEnd();
}

From source file:org.cogaen.lwjgl.scene.PointVisual.java

License:Open Source License

@Override
public void render() {
    getColor().apply();
    GL11.glBegin(GL11.GL_POINTS);
    GL11.glVertex2f(0f, 0f);
    GL11.glEnd();
}

From source file:org.craftmania.world.World.java

License:Apache License

private void renderOverlay() {
    Configuration conf = Game.getInstance().getConfiguration();

    Game.getInstance().initOverlayRendering();

    GL11.glColor3f(1, 1, 1);//from   w ww .java2 s  .  c  o m

    if (Game.RENDER_INFORMATION_OVERLAY) {
        GLFont infoFont = FontStorage.getFont("Monospaced_20");

        /* Down Left Info */
        infoFont.print(4, 4, "CraftMania");
        infoFont.print(4, 30, _player.coordinatesToString());
        infoFont.print(4, 45, "Visible Chunks:      " + _visibleChunks.size());
        infoFont.print(4, 60, "Updading Blocks:     " + _updatingBlocks);
        infoFont.print(4, 75, "Total Chunks in RAM: " + _chunkManager.getTotalChunkCount());
        infoFont.print(4, 90, "Local Chunks:        " + _localChunks.size());
        infoFont.print(4, 105, "Total Local Blocks:  " + _localBlockCount);
        infoFont.print(4, 120, "Time:  " + _time);
        infoFont.print(4, 135, "Sunlight:  " + _sunlight);

    }
    /** RENDER **/
    if (_activatedInventory != null) {
        Game.getInstance().renderTransculentOverlayLayer();
        _activatedInventory.renderInventory();
    } else {
        int width = conf.getWidth();
        int height = conf.getHeight();
        // Center Cross
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        if (CENTER_CROSS_CALL_LIST == 0) {
            CENTER_CROSS_CALL_LIST = GL11.glGenLists(1);
            GL11.glNewList(CENTER_CROSS_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE);

            int crossSize = 10;
            int crossHole = 5;

            GL11.glLineWidth(2.5f);

            GL11.glColor3f(0, 0, 0);
            GL11.glBegin(GL11.GL_LINES);
            GL11.glVertex3f(width / 2f - crossSize - crossHole, height / 2f, 0);
            GL11.glVertex3f(width / 2f - crossHole, height / 2f, 0);

            GL11.glVertex3f(width / 2f + crossSize + crossHole, height / 2f, 0);
            GL11.glVertex3f(width / 2f + crossHole, height / 2f, 0);

            GL11.glVertex3f(width / 2f, height / 2f - crossSize - crossHole, 0);
            GL11.glVertex3f(width / 2f, height / 2f - crossHole, 0);

            GL11.glVertex3f(width / 2f, height / 2f + crossSize + crossHole, 0);
            GL11.glVertex3f(width / 2f, height / 2f + crossHole, 0);

            GL11.glEnd();
            GL11.glEndList();
        } else {
            GL11.glCallList(CENTER_CROSS_CALL_LIST);
        }
        GL11.glEnable(GL11.GL_TEXTURE_2D);

        // Inventory bar
        GL11.glPushMatrix();
        Texture texGui = TextureStorage.getTexture("gui.gui");
        texGui.bind();
        float tileSize = 20.0f / texGui.getImageWidth();
        if (INVENTORY_BAR_CALL_LIST == 0) {
            INVENTORY_BAR_CALL_LIST = GL11.glGenLists(2);

            /* Bar */
            GL11.glNewList(INVENTORY_BAR_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE);

            GL11.glTranslatef(width / 2.0f - 9 * 20, 10, 0);
            GL11.glColor3f(1.0f, 1.0f, 1.0f);
            GL11.glBegin(GL11.GL_QUADS);

            GL11.glTexCoord2f(0, 0);
            GL11.glVertex2f(0, 40);

            GL11.glTexCoord2f(tileSize * 9, 0);
            GL11.glVertex2f(9 * 40, 40);

            GL11.glTexCoord2f(tileSize * 9, tileSize);
            GL11.glVertex2f(9 * 40, 0);

            GL11.glTexCoord2f(0, tileSize);
            GL11.glVertex2f(0, 0);

            GL11.glEnd();
            GL11.glEndList();

            /* Little frame around selected item */
            float frameTileSize = 24.0f / texGui.getImageWidth();
            float frameTileY = 22.0f / texGui.getImageHeight();

            GL11.glNewList(INVENTORY_BAR_CALL_LIST + 1, GL11.GL_COMPILE);
            GL11.glBegin(GL11.GL_QUADS);

            GL11.glTexCoord2f(0, frameTileY);
            GL11.glVertex2f(0, 48);

            GL11.glTexCoord2f(frameTileSize, frameTileY);
            GL11.glVertex2f(48, 48);

            GL11.glTexCoord2f(frameTileSize, frameTileY + frameTileSize);
            GL11.glVertex2f(48, 0);

            GL11.glTexCoord2f(0, frameTileY + frameTileSize);
            GL11.glVertex2f(0, 0);

            GL11.glEnd();
            GL11.glEndList();
        } else {
            GL11.glCallList(INVENTORY_BAR_CALL_LIST);
        }

        /* Content */
        GL11.glPushMatrix();
        GL11.glTranslatef(20, 20, 0);
        for (int i = 0; i < 9; ++i) {
            InventoryPlace place = getActivePlayer().getInventory().getInventoryPlace(i);
            if (place != null)
                place.render();
            GL11.glTranslatef(40, 0, 0);
        }
        texGui.bind();
        GL11.glPopMatrix();
        GL11.glTranslatef(getActivePlayer().getSelectedInventoryItemIndex() * 40.0f - 4, -4, 0);
        GL11.glCallList(INVENTORY_BAR_CALL_LIST + 1);

        GL11.glPopMatrix();
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Char(int x, int y, int num) {

    num &= 255;//from  w  w w  .  j  a  va2 s  .  c  om

    if ((num & 127) == 32) {
        return; // space
    }
    if (y <= -8) {
        return; // totally off screen
    }
    int row = num >> 4;
    int col = num & 15;

    float frow = row * 0.0625f;
    float fcol = col * 0.0625f;
    float size = 0.0625f;

    GL_Bind(draw_chars.texnum);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(fcol, frow);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(fcol + size, frow);
    GL11.glVertex2f(x + 8, y);
    GL11.glTexCoord2f(fcol + size, frow + size);
    GL11.glVertex2f(x + 8, y + 8);
    GL11.glTexCoord2f(fcol, frow + size);
    GL11.glVertex2f(x, y + 8);
    GL11.glEnd();
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_StretchPic(int x, int y, int w, int h, String pic) {

    image_t image;//from www  .j  a  v  a 2s. c  o  m

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }

    if (scrap_dirty) {
        Scrap_Upload();
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(image.sl, image.tl);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(image.sh, image.tl);
    GL11.glVertex2f(x + w, y);
    GL11.glTexCoord2f(image.sh, image.th);
    GL11.glVertex2f(x + w, y + h);
    GL11.glTexCoord2f(image.sl, image.th);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Pic(int x, int y, String pic) {
    image_t image;/*from ww  w.ja v  a 2  s . c  om*/

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }
    if (scrap_dirty) {
        Scrap_Upload();
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(image.sl, image.tl);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(image.sh, image.tl);
    GL11.glVertex2f(x + image.width, y);
    GL11.glTexCoord2f(image.sh, image.th);
    GL11.glVertex2f(x + image.width, y + image.height);
    GL11.glTexCoord2f(image.sl, image.th);
    GL11.glVertex2f(x, y + image.height);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_TileClear(int x, int y, int w, int h, String pic) {
    image_t image;//ww  w .ja v a 2s . c  o  m

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(x / 64.0f, y / 64.0f);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f((x + w) / 64.0f, y / 64.0f);
    GL11.glVertex2f(x + w, y);
    GL11.glTexCoord2f((x + w) / 64.0f, (y + h) / 64.0f);
    GL11.glVertex2f(x + w, y + h);
    GL11.glTexCoord2f(x / 64.0f, (y + h) / 64.0f);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) {

    if (colorIndex > 255) {
        Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color");
    }/*  w w w .  ja  v  a 2 s. co m*/

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    int color = d_8to24table[colorIndex];

    GL11.glColor3ub((byte) ((color) & 0xff), // r
            (byte) ((color >> 8) & 0xff), // g
            (byte) ((color >> 16) & 0xff) // b
    );

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + w, y);
    GL11.glVertex2f(x + w, y + h);
    GL11.glVertex2f(x, y + h);

    GL11.glEnd();
    GL11.glColor3f(1, 1, 1);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte[] data) {
    int i, j, trows;
    int sourceIndex;
    int frac, fracstep;
    float hscale;
    int row;// ww  w . j  a v  a  2 s  .com
    float t;

    GL_Bind(0);

    if (rows <= 256) {
        hscale = 1;
        trows = rows;
    } else {
        hscale = rows / 256.0f;
        trows = 256;
    }
    t = rows * hscale / 256;

    if (!qglColorTableEXT) {
        //int[] image32 = new int[256*256];
        image32.clear();
        int destIndex = 0;

        for (i = 0; i < trows; i++) {
            row = (int) (i * hscale);
            if (row > rows) {
                break;
            }
            sourceIndex = cols * row;
            destIndex = i * 256;
            fracstep = cols * 0x10000 / 256;
            frac = fracstep >> 1;
            for (j = 0; j < 256; j++) {
                image32.put(destIndex + j, r_rawpalette[data[sourceIndex + (frac >> 16)] & 0xff]);
                frac += fracstep;
            }
        }
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, gl_tex_solid_format, 256, 256, 0, GL11.GL_RGBA,
                GL11.GL_UNSIGNED_BYTE, image32);
    } else {
        //byte[] image8 = new byte[256*256];
        image8.clear();
        int destIndex = 0;

        for (i = 0; i < trows; i++) {
            row = (int) (i * hscale);
            if (row > rows) {
                break;
            }
            sourceIndex = cols * row;
            destIndex = i * 256;
            fracstep = cols * 0x10000 / 256;
            frac = fracstep >> 1;
            for (j = 0; j < 256; j++) {
                image8.put(destIndex + j, data[sourceIndex + (frac >> 16)]);
                frac += fracstep;
            }
        }

        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, 256, 256, 0, GL11.GL_COLOR_INDEX,
                GL11.GL_UNSIGNED_BYTE, image8);
    }
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);

    if ((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0)) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2f(x + w, y);
    GL11.glTexCoord2f(1, t);
    GL11.glVertex2f(x + w, y + h);
    GL11.glTexCoord2f(0, t);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();

    if ((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0)) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.geekygoblin.nedetlesmaki.game.systems.DrawSystem.java

License:Open Source License

private void drawLevel(LevelBackground level) {

    GL11.glPushMatrix();//from  w w w  . ja v a2 s .c o  m
    GL11.glLoadIdentity();
    IPlay backgroundAnimationPlay = level.getBackground();
    backgroundAnimationPlay.update((long) (world.getDelta() * 1000L));
    final IAnimationFrame currentFrame = backgroundAnimationPlay.getCurrentFrame();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) currentFrame.getImage().getId());
    float x1 = -VirtualResolution.WIDTH / 2.0f;
    float x2 = VirtualResolution.WIDTH / 2.0f;
    float y1 = VirtualResolution.HEIGHT / 2.0f;
    float y2 = -VirtualResolution.HEIGHT / 2.0f;
    float u1 = currentFrame.getU1();
    float u2 = currentFrame.getU2();

    float v1 = currentFrame.getV2();
    float v2 = currentFrame.getV1();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x1, y2);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(x2, y1);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x1, y1);
    GL11.glEnd();
    GL11.glPopMatrix();
}