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:kinect.KinectModule.java

License:Open Source License

/**
 * Mthode de dessin de cercle OPenGL//w  w  w. j  a  va 2 s .c  o  m
 * @param userID l'ID de l'utilisateur
 * @param joint la position du joint  dessiner
 */
private void drawCircle(int userID, SkeletonJoint joint) {
    SkeletonJointPosition pos = joints.get(userID).get(joint);
    Vec2 position = new Vec2(pos.getPosition().getX(), Display.getHeight() - pos.getPosition().getY());
    float radius = 5;
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex2f(position.x, position.y);
    float angle = 0.0f;
    for (angle = 0; angle < 2.0 * Math.PI + 0.0001;) {
        float xpos = (float) (position.x + Math.cos(angle) * radius);
        float ypos = (float) (position.y + Math.sin(angle) * radius);
        GL11.glVertex2f(xpos, ypos);
        angle += 2.0 * Math.PI / 20;
    }
    GL11.glEnd();

}

From source file:kuake2.render.lwjgl.Draw.java

License:Open Source License

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

    num &= 255;//from www .ja  v a  2  s. c o m

    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:kuake2.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 w  w  w.ja  va  2  s  .  co  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:kuake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Pic(int x, int y, String pic) {
    image_t image;//from  w  w w.  j  a v a  2s  .  com

    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:kuake2.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.  j a v  a 2  s  .com*/

    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:kuake2.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");

    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from w ww . j a v a 2s  .  c o m*/

    int color = d_8to24table[colorIndex];

    GL11.glColor3ub((byte) ((color >> 0) & 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:kuake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_FadeScreen() {
    GL11.glEnable(GL11.GL_BLEND);/*from  w ww.j a v a2 s  .c o  m*/
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor4f(0, 0, 0, 0.8f);
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex2f(0, 0);
    GL11.glVertex2f(vid.width, 0);
    GL11.glVertex2f(vid.width, vid.height);
    GL11.glVertex2f(0, vid.height);

    GL11.glEnd();
    GL11.glColor4f(1, 1, 1, 1);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:kuake2.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.ja v a2 s  . c o  m*/
    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:launcher.Main.java

private void drawWorld() {
    final int widthFit = (SCREEN_WIDTH / world.getBlockWidth()) + 1;
    final int heightFit = (SCREEN_HEIGHT / world.getBlockWidth()) + 1;

    final int cX = Math.min(widthFit, world.getSizeX());
    final int cY = Math.min(heightFit, world.getSizeY());//assuming the world is not a jagged grid...
    // Clear the screen and depth buffer

    Point playerPoint = world.getPlayerLocationInGrid(player);

    final int startX = playerPoint.getX() - (int) Math.floor(widthFit / 2);
    final int startY = playerPoint.getY() - (int) Math.floor(heightFit / 2);

    final int w = world.getBlockWidth();
    final int maxDamage = 500;
    final double damageProportion = w * 0.5 / maxDamage;
    for (int i = 0; i < cX + 1; i++) {
        for (int j = 0; j < cY + 1; j++) {
            Block block = world.getBlock(i + startX, j + startY);
            byte[] c = block.getColor();
            GL11.glColor3ub(c[0], c[1], c[2]);

            int left = i * w - (w / 2);
            int top = j * w - (w / 2);
            int right = left + w;
            int bottom = top + w;
            // draw quad block thing
            GL11.glBegin(GL11.GL_QUADS);
            {//from   w  w w.j  a  va 2 s  . co  m
                GL11.glVertex2f(left, top);
                GL11.glVertex2f(right, top);
                GL11.glVertex2f(right, bottom);
                GL11.glVertex2f(left, bottom);
            }
            GL11.glEnd();

            final int damage = block.getDamage();
            if (damage < maxDamage && !(block instanceof AirBlock)) {
                //wtf is dit?
                int tmp = (int) Math.ceil((maxDamage / (damage + 1)) * 0.1f) + 2;
                int centerX = (int) (left + w * 0.5);
                int centerY = (int) (top + w * 0.5);
                int visibleDamage = (int) Math.ceil(damage * damageProportion);
                //gray
                GL11.glColor3ub((byte) 80, (byte) 80, (byte) 80);

                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glVertex2f(left, top);
                    GL11.glVertex2f(left + tmp, top);
                    GL11.glVertex2f(centerX - visibleDamage, centerY - visibleDamage);
                    GL11.glVertex2f(left, top + tmp);
                }
                GL11.glEnd();

                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glVertex2f(right, top);
                    GL11.glVertex2f(right, top + tmp);
                    GL11.glVertex2f(centerX + visibleDamage, centerY - visibleDamage);
                    GL11.glVertex2f(right - tmp, top);
                }
                GL11.glEnd();

                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glVertex2f(right, bottom);
                    GL11.glVertex2f(right - tmp, bottom);
                    GL11.glVertex2f(centerX + visibleDamage, centerY + visibleDamage);
                    GL11.glVertex2f(right, bottom - tmp);
                }
                GL11.glEnd();

                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glVertex2f(left, bottom);
                    GL11.glVertex2f(left, bottom - tmp);
                    GL11.glVertex2f(centerX - visibleDamage, centerY + visibleDamage);
                    GL11.glVertex2f(left + tmp, bottom);
                }
                GL11.glEnd();
            }
        }
    }
}

From source file:launcher.Main.java

private void drawPlayer() {
    //orangered, why not?
    GL11.glColor3ub((byte) 255, (byte) 69, (byte) 0);

    final int w = player.getWidth() / 2;
    GL11.glBegin(GL11.GL_QUADS);//from w w w  .  jav  a 2  s  . c o m
    {
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w);
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w);
    }
    GL11.glEnd();

    //draw drill
    switch (player.getDirection()) {
    case IDLE:
        break;
    case LEFT:
        GL11.glBegin(GL11.GL_TRIANGLES); {
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X - w * 1.5f, SCREEN_CENTER_Y);
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w);
    }
        GL11.glEnd();
        break;
    case RIGHT:
        GL11.glBegin(GL11.GL_TRIANGLES); {
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X + w * 1.5f, SCREEN_CENTER_Y);
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w);
    }
        GL11.glEnd();
        break;
    case DOWN:
        GL11.glBegin(GL11.GL_TRIANGLES); {
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w);
        GL11.glVertex2f(SCREEN_CENTER_X, SCREEN_CENTER_Y + w * 1.5f);
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w);
    }
        GL11.glEnd();
        break;
    case UP:
        GL11.glBegin(GL11.GL_TRIANGLES); {
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X, SCREEN_CENTER_Y - w * 1.5f);
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w);
    }
        GL11.glEnd();
        break;
    default:
        break;
    }
}