Example usage for org.lwjgl.opengl GL11 glVertex3f

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:shadertool.nodes.input.PerlinNoiseNode.java

@Override
public void run() throws SlickException {

    Output imgOut = outputs.get(0);//w w  w  . ja v a2  s.c o  m
    imgOut.create(width, height);
    Graphics g = imgOut.img.getGraphics();
    Graphics.setCurrent(g);

    shader.bind();

    // Dibujar cuadrado blanco (tamao de textura)
    GL11.glTranslatef(0, 0, 0);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(0, 0, 0);
    GL11.glVertex3f(0, height, 0);
    GL11.glVertex3f(width, height, 0);
    GL11.glVertex3f(width, 0, 0);
    GL11.glEnd();

    g.flush();
    shader.unbind();

    imgOut.updated();
}

From source file:shadertool.nodes.input.PerlinNoiseTimeNode.java

@Override
public void run() throws SlickException {

    Output imgOut = outputs.get(0);//from   w ww. j  a v  a 2s.  c  o m
    imgOut.create(width, height);
    Graphics g = imgOut.img.getGraphics();
    Graphics.setCurrent(g);

    shader.bind();
    shader.setUniform1f("time", (float) (System.currentTimeMillis() - start) / 1000f);

    // Dibujar cuadrado blanco (tamao de textura)
    GL11.glTranslatef(0, 0, 0);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(0, 0, 0);
    GL11.glVertex3f(0, height, 0);
    GL11.glVertex3f(width, height, 0);
    GL11.glVertex3f(width, 0, 0);
    GL11.glEnd();

    g.flush();
    shader.unbind();

    imgOut.updated();
}

From source file:shadowmage.ancient_framework.client.gui.elements.GuiScrollBarSimple.java

License:Open Source License

protected void renderQuad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4,
        float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4) {
    GL11.glBegin(GL11.GL_QUADS);/*from   w w w.j av a2 s.c o m*/
    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex3f(x1, y1, 0);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex3f(x2, y2, 0);
    GL11.glTexCoord2f(u3, v3);
    GL11.glVertex3f(x3, y3, 0);
    GL11.glTexCoord2f(u4, v4);
    GL11.glVertex3f(x4, y4, 0);
    GL11.glEnd();
}

From source file:shadowmage.ancient_framework.client.model.ModelPiece.java

License:Open Source License

public void renderForEditor(ModelPiece piece, Primitive prim) {
    GL11.glPushMatrix();//w  w w.  ja va  2 s.  com
    if (x != 0 || y != 0 || z != 0) {
        GL11.glTranslatef(x, y, z);
    }
    if (rx != 0) {
        GL11.glRotatef(rx, 1, 0, 0);
    }
    if (ry != 0) {
        GL11.glRotatef(ry, 0, 1, 0);
    }
    if (rz != 0) {
        GL11.glRotatef(rz, 0, 0, 1);
    }
    if (piece == this) {
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_POINT_SMOOTH);
        GL11.glColor4f(1.0f, 0.f, 0.f, 1.f);
        GL11.glPointSize(5.f);
        GL11.glBegin(GL11.GL_POINTS);
        GL11.glVertex3f(0, 0, 0);
        GL11.glEnd();
        GL11.glColor4f(0.75f, 0.5f, 0.5f, 1.f);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    for (Primitive primitive : this.primitives) {
        if (primitive == prim) {
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_TEXTURE_2D);

            GL11.glColor4f(1.0f, 0.f, 0.f, 1.f);

            GL11.glBegin(GL11.GL_POINTS);
            GL11.glVertex3f(prim.x, prim.y, prim.z);
            GL11.glEnd();

            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);

            GL11.glColor4f(1.0f, 0.5f, 0.5f, 1.f);
        }
        primitive.render();
        if (primitive == prim) {
            GL11.glColor4f(0.75f, 0.5f, 0.5f, 1.f);
        }
    }
    for (ModelPiece child : this.children) {
        child.renderForEditor(piece, prim);
    }
    GL11.glColor4f(1.f, 1.f, 1.f, 1.f);
    GL11.glPopMatrix();
}

From source file:shadowmage.ancient_framework.client.model.PrimitiveBox.java

License:Open Source License

@Override
protected void renderForDisplayList() {

    float tw = parent.getModel().textureWidth;
    float th = parent.getModel().textureHeight;
    float px = 1.f / tw;
    float py = 1.f / th;
    float w = (x2 - x1) * 16.f;
    float h = (y2 - y1) * 16.f;
    float l = (z2 - z1) * 16.f;
    float ty = this.ty();
    float tx = this.tx();

    float tx1, ty1, tx2, ty2;

    //render the cube. only called a single time when building the display list for a piece
    if (rx != 0) {
        GL11.glRotatef(rx, 1, 0, 0);/*from ww  w  .j  av  a2  s .  c om*/
    }
    if (ry != 0) {
        GL11.glRotatef(ry, 0, 1, 0);
    }
    if (rz != 0) {
        GL11.glRotatef(rz, 0, 0, 1);
    }

    GL11.glBegin(GL11.GL_QUADS);

    AWLog.logDebug("tx, ty: " + tx + "," + ty);
    AWLog.logDebug("w,l,h: " + w + "," + l + "," + h);

    //front side  
    tx1 = (tx + l) * px;
    ty1 = (th - (ty + l + h)) * py;
    tx2 = (tx + l + w) * px;
    ty2 = (th - (ty + l)) * py;
    GL11.glNormal3f(0, 0, 1);
    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex3f(x1, y1, z2);
    GL11.glTexCoord2f(tx2, ty1);
    GL11.glVertex3f(x2, y1, z2);
    GL11.glTexCoord2f(tx2, ty2);
    GL11.glVertex3f(x2, y2, z2);
    GL11.glTexCoord2f(tx1, ty2);
    GL11.glVertex3f(x1, y2, z2);
    AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2));

    ////rear side
    tx1 = (tx + l + l + w) * px;
    ty1 = (th - (ty + l + h)) * py;
    tx2 = (tx + l + w + l + w) * px;
    ty2 = (th - (ty + l)) * py;
    GL11.glNormal3f(0, 0, -1);
    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex3f(x2, y1, z1);
    GL11.glTexCoord2f(tx2, ty1);
    GL11.glVertex3f(x1, y1, z1);
    GL11.glTexCoord2f(tx2, ty2);
    GL11.glVertex3f(x1, y2, z1);
    GL11.glTexCoord2f(tx1, ty2);
    GL11.glVertex3f(x2, y2, z1);
    AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2));

    //right side
    tx1 = (tx + l + w) * px;
    ty1 = (th - (ty + l + h)) * py;
    tx2 = (tx + l + w + l) * px;
    ty2 = (th - (ty + l)) * py;
    GL11.glNormal3f(1, 0, 0);
    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex3f(x1, y1, z1);
    GL11.glTexCoord2f(tx2, ty1);
    GL11.glVertex3f(x1, y1, z2);
    GL11.glTexCoord2f(tx2, ty2);
    GL11.glVertex3f(x1, y2, z2);
    GL11.glTexCoord2f(tx1, ty2);
    GL11.glVertex3f(x1, y2, z1);
    AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2));

    //  //left side
    tx1 = (tx) * px;
    ty1 = (th - (ty + l + h)) * py;
    tx2 = (tx + l) * px;
    ty2 = (th - (ty + l)) * py;
    GL11.glNormal3f(-1, 0, 0);
    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex3f(x2, y1, z2);
    GL11.glTexCoord2f(tx2, ty1);
    GL11.glVertex3f(x2, y1, z1);
    GL11.glTexCoord2f(tx2, ty2);
    GL11.glVertex3f(x2, y2, z1);
    GL11.glTexCoord2f(tx1, ty2);
    GL11.glVertex3f(x2, y2, z2);
    AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2));

    //  //top side
    tx1 = (tx + l) * px;
    ty1 = (th - (ty + l)) * py;
    tx2 = (tx + l + w) * px;
    ty2 = (th - (ty)) * py;
    GL11.glNormal3f(0, 1, 0);
    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex3f(x2, y2, z1);
    GL11.glTexCoord2f(tx2, ty1);
    GL11.glVertex3f(x1, y2, z1);
    GL11.glTexCoord2f(tx2, ty2);
    GL11.glVertex3f(x1, y2, z2);
    GL11.glTexCoord2f(tx1, ty2);
    GL11.glVertex3f(x2, y2, z2);
    AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2));

    //  //bottom side
    tx1 = (tx + l + w) * px;
    ty1 = (th - (ty + l)) * py;
    tx2 = (tx + l + w + w) * px;
    ty2 = (th - (ty)) * py;
    GL11.glNormal3f(0, -1, 0);
    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex3f(x2, y1, z2);
    GL11.glTexCoord2f(tx2, ty1);
    GL11.glVertex3f(x1, y1, z2);
    GL11.glTexCoord2f(tx2, ty2);
    GL11.glVertex3f(x1, y1, z1);
    GL11.glTexCoord2f(tx1, ty2);
    GL11.glVertex3f(x2, y1, z1);
    AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2));

    GL11.glEnd();
}

From source file:shadowmage.ancient_framework.client.model.PrimitiveQuad.java

License:Open Source License

@Override
protected void renderForDisplayList() {
    float tw = parent.getModel().textureWidth;
    float th = parent.getModel().textureHeight;
    float px = 1.f / tw;
    float py = 1.f / th;
    float w = (x2 - x1) * 16.f;
    float l = 1.f;//TODO fix this for proper texture handling
    float h = (y2 - y1) * 16.f;
    float ty = this.ty();
    float tx = this.tx();

    float tx1, ty1, tx2, ty2;

    //render the cube. only called a single time when building the display list for a piece
    if (rx != 0) {
        GL11.glRotatef(rx, 1, 0, 0);/*from  w  w  w .  ja v a 2 s  .  c o m*/
    }
    if (ry != 0) {
        GL11.glRotatef(ry, 0, 1, 0);
    }
    if (rz != 0) {
        GL11.glRotatef(rz, 0, 0, 1);
    }

    GL11.glBegin(GL11.GL_QUADS);

    AWLog.logDebug("tx, ty: " + tx + "," + ty);
    AWLog.logDebug("w,l,h: " + w + "," + h);
    //  AWLog.logDebug(String.format("t: %.4f, %.4f, %.4f, %.4f", tx1, ty1, tx2, ty2));

    //front side  
    tx1 = (tx + l) * px;
    ty1 = (th - (ty + l + h)) * py;
    tx2 = (tx + l + w) * px;
    ty2 = (th - (ty + l)) * py;

    GL11.glNormal3f(0, 0, 1);
    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex3f(x1, y1, 0.f);
    GL11.glTexCoord2f(tx2, ty1);
    GL11.glVertex3f(x2, y1, 0.f);
    GL11.glTexCoord2f(tx2, ty2);
    GL11.glVertex3f(x2, y2, 0.f);
    GL11.glTexCoord2f(tx1, ty2);
    GL11.glVertex3f(x1, y2, 0.f);

    GL11.glEnd();
}

From source file:shadowmage.ancient_framework.client.model.PrimitiveTriangle.java

License:Open Source License

@Override
protected void renderForDisplayList() {
    if (rx != 0) {
        GL11.glRotatef(rx, 1, 0, 0);//from  ww  w .j  a  v a2 s.  c  o  m
    }
    if (ry != 0) {
        GL11.glRotatef(ry, 0, 1, 0);
    }
    if (rz != 0) {
        GL11.glRotatef(rz, 0, 0, 1);
    }

    float tw = parent.getModel().textureWidth;
    float th = parent.getModel().textureHeight;
    float px = 1.f / tw;
    float py = 1.f / th;

    float u1, v1, u2, v2, u3, v3;
    u1 = this.u1 * px + this.tx() * px;
    u2 = this.u2 * px + this.tx() * px;
    u3 = this.u3 * px + this.tx() * px;
    v1 = this.v1 * py + this.ty() * py;
    v2 = this.v2 * py + this.ty() * py;
    v3 = this.v3 * py + this.ty() * py;
    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
    GL11.glNormal3f(normalX, normalY, normalZ);
    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex3f(x1, y1, z1);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex3f(x2, y2, z2);
    GL11.glTexCoord2f(u3, v3);
    GL11.glVertex3f(x3, y3, z3);
    GL11.glEnd();
}

From source file:shadowmage.meim.client.gui.GuiModelEditor.java

License:Open Source License

private void renderGrid() {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from   w  ww  .j  a va 2s .co m*/
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glLineWidth(2.f);
    if (gridDisplayList >= 0) {
        GL11.glCallList(gridDisplayList);
    } else {
        gridDisplayList = GL11.glGenLists(1);
        GL11.glNewList(gridDisplayList, GL11.GL_COMPILE_AND_EXECUTE);
        GL11.glColor4f(0.f, 0.f, 1.f, 1.f);
        for (int x = -5; x <= 5; x++) {
            GL11.glBegin(GL11.GL_LINE_LOOP);
            GL11.glVertex3f(x, 0.f, -5.f);
            GL11.glVertex3f(x, 0.f, 5.f);
            GL11.glEnd();
        }
        for (int z = -5; z <= 5; z++) {
            GL11.glBegin(GL11.GL_LINE_LOOP);
            GL11.glVertex3f(-5.f, 0.f, z);
            GL11.glVertex3f(5.f, 0.f, z);
            GL11.glEnd();
        }
        GL11.glColor4f(1.f, 1.f, 1.f, 1.f);
        GL11.glEndList();
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:shadowmage.meim.client.gui.GuiTextureElement.java

License:Open Source License

@Override
public void drawElement(int mouseX, int mouseY) {
    int x = renderPosX + guiLeft;
    int y = renderPosY + guiTop;
    int x1 = x;//from w  w  w  . ja va2 s .co m
    int y1 = y;
    int x2 = x;
    int y2 = y + height;
    int x3 = x + width;
    int y3 = y + height;
    int x4 = x + width;
    int y4 = y;

    float pixX = 1.f / (float) image.getWidth();
    float pixY = 1.f / (float) image.getHeight();
    float u1, v1, u2, v2, u3, v3, u4, v4;
    float uw, uh;

    uw = scale;//image.getWidth() * pixX * scale;
    uh = scale;

    float u = pixX * (float) viewX;
    float v = pixY * (float) viewY;
    v = v > 1 ? 1 : v;

    u1 = u;
    v1 = v;
    u2 = u;
    v2 = v + uh;
    u3 = u + uw;
    v3 = v + uh;
    u4 = u + uw;
    v4 = v;

    bindTexture();
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex3f(x1, y1, 0);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex3f(x2, y2, 0);
    GL11.glTexCoord2f(u3, v3);
    GL11.glVertex3f(x3, y3, 0);
    GL11.glTexCoord2f(u4, v4);
    GL11.glVertex3f(x4, y4, 0);

    GL11.glEnd();
    resetBoundTexture();

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1.f, 0.f, 0.f, 1.f);
    GL11.glPointSize(5);
    GL11.glBegin(GL11.GL_POINTS);
    GL11.glVertex3f(x, y, 0.f);
    GL11.glEnd();
    GL11.glColor4f(1.f, 1.f, 1.f, 1.f);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:sokobanMod.client.HandlerLevelPreviewRenderer.java

License:LGPL

public static void renderPulsingQuad() {
    time += 0.001;//from   w  w w. j  a v a 2  s .c  o  m
    if (time > 2 * Math.PI)
        time = 0;
    float quadPosX = (float) Math.sin(time) * 0.2F;
    float quadPosY = (float) Math.cos(time) * 0.2F;

    GL11.glColor4f(colliding ? 1F : 0F, colliding ? 0F : 1F, 0F, 1F);

    GL11.glLineWidth(3.0F);
    GL11.glBegin(GL11.GL_LINES);

    // the lines around the whole level
    GL11.glVertex3f(-0.5F, 0.5F, 0F);
    GL11.glVertex3f(0.5F, 0.5F, 0F);
    GL11.glVertex3f(0.5F, -0.5F, 0F);
    GL11.glVertex3f(-0.5F, -0.5F, 0F);

    // draw the lines from the bigger quad's corner to the small quad's
    // corner
    float quadSize = 0.1F;
    GL11.glVertex3f(-0.5F, 0.5F, 0F);
    GL11.glVertex3f(-quadSize + quadPosX, quadSize + quadPosY, 0F);
    GL11.glVertex3f(0.5F, 0.5F, 0F);
    GL11.glVertex3f(quadSize + quadPosX, quadSize + quadPosY, 0F);
    GL11.glVertex3f(0.5F, -0.5F, 0F);
    GL11.glVertex3f(quadSize + quadPosX, -quadSize + quadPosY, 0F);
    GL11.glVertex3f(-0.5F, -0.5F, 0F);
    GL11.glVertex3f(-quadSize + quadPosX, -quadSize + quadPosY, 0F);
    GL11.glEnd();

    // draw the quad inside the big quad
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex3f(-quadSize + quadPosX, quadSize + quadPosY, 0F);
    GL11.glVertex3f(quadSize + quadPosX, quadSize + quadPosY, 0F);
    GL11.glVertex3f(quadSize + quadPosX, -quadSize + quadPosY, 0F);
    GL11.glVertex3f(-quadSize + quadPosX, -quadSize + quadPosY, 0F);
    GL11.glEnd();
}