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:io.flob.blackheart.WallLiftPanel.java

License:Open Source License

private void render_right() {
    GL11.glNormal3f(1, 0, 0);//from w w  w .j a va  2s .c om
    GL11.glTexCoord2f(texture.getU2(), texture.getV2());
    GL11.glVertex3f(size + position.getX(), -size + position.getY(), -size + position.getZ());
    GL11.glTexCoord2f(texture.getU2(), texture.getV());
    GL11.glVertex3f(size + position.getX(), size + position.getY(), -size + position.getZ());
    GL11.glTexCoord2f(texture.getU(), texture.getV());
    GL11.glVertex3f(size + position.getX(), size + position.getY(), size + position.getZ());
    GL11.glTexCoord2f(texture.getU(), texture.getV2());
    GL11.glVertex3f(size + position.getX(), -size + position.getY(), size + position.getZ());
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

public static void glVertex3f(float x, float y, float z) {
    GL11.glVertex3f(x, y, z);
}

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

License:Open Source License

/**
 * R_RenderDlight//w  w w.  java 2  s. c o m
 */
void R_RenderDlight(dlight_t light) {
    float rad = light.intensity * 0.35f;

    Math3D.VectorSubtract(light.origin, r_origin, v);

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glColor3f(light.color[0] * 0.2f, light.color[1] * 0.2f, light.color[2] * 0.2f);
    int i;
    for (i = 0; i < 3; i++)
        v[i] = light.origin[i] - vpn[i] * rad;

    GL11.glVertex3f(v[0], v[1], v[2]);
    GL11.glColor3f(0, 0, 0);

    int j;
    float a;
    for (i = 16; i >= 0; i--) {
        a = (float) (i / 16.0f * Math.PI * 2);
        for (j = 0; j < 3; j++)
            v[j] = (float) (light.origin[j] + vright[j] * Math.cos(a) * rad + vup[j] * Math.sin(a) * rad);
        GL11.glVertex3f(v[0], v[1], v[2]);
    }
    GL11.glEnd();
}

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

License:Open Source License

/**
 * R_DrawSpriteModel//  w  ww  .  jav  a2 s .c o  m
 */
void R_DrawSpriteModel(entity_t e) {
    float alpha = 1.0F;

    qfiles.dsprframe_t frame;
    qfiles.dsprite_t psprite;

    // don't even bother culling, because it's just a single
    // polygon without a surface cache

    psprite = (qfiles.dsprite_t) currentmodel.extradata;

    e.frame %= psprite.numframes;

    frame = psprite.frames[e.frame];

    if ((e.flags & Defines.RF_TRANSLUCENT) != 0)
        alpha = e.alpha;

    if (alpha != 1.0F)
        GL11.glEnable(GL11.GL_BLEND);

    GL11.glColor4f(1, 1, 1, alpha);

    GL_Bind(currentmodel.skins[e.frame].texnum);

    GL_TexEnv(GL11.GL_MODULATE);

    if (alpha == 1.0)
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    else
        GL11.glDisable(GL11.GL_ALPHA_TEST);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(0, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, -frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 0);
    Math3D.VectorMA(e.origin, frame.height - frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glTexCoord2f(1, 1);
    Math3D.VectorMA(e.origin, -frame.origin_y, vup, point);
    Math3D.VectorMA(point, frame.width - frame.origin_x, vright, point);
    GL11.glVertex3f(point[0], point[1], point[2]);

    GL11.glEnd();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL_TexEnv(GL11.GL_REPLACE);

    if (alpha != 1.0F)
        GL11.glDisable(GL11.GL_BLEND);

    GL11.glColor4f(1, 1, 1, 1);
}

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

License:Open Source License

/**
 * R_DrawNullModel/*from w  ww  .  j av a 2  s  .  co  m*/
 */
void R_DrawNullModel() {
    if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) {
        // cwei wollte blau: shadelight[0] = shadelight[1] = shadelight[2] = 1.0F;
        shadelight[0] = shadelight[1] = shadelight[2] = 0.0F;
        shadelight[2] = 0.8F;
    } else {
        R_LightPoint(currententity.origin, shadelight);
    }

    GL11.glPushMatrix();
    R_RotateForEntity(currententity);

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor3f(shadelight[0], shadelight[1], shadelight[2]);

    // this replaces the TRIANGLE_FAN
    //glut.glutWireCube(gl, 20);

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex3f(0, 0, -16);
    int i;
    for (i = 0; i <= 4; i++) {
        GL11.glVertex3f((float) (16.0f * Math.cos(i * Math.PI / 2)),
                (float) (16.0f * Math.sin(i * Math.PI / 2)), 0.0f);
    }
    GL11.glEnd();

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex3f(0, 0, 16);
    for (i = 4; i >= 0; i--) {
        GL11.glVertex3f((float) (16.0f * Math.cos(i * Math.PI / 2)),
                (float) (16.0f * Math.sin(i * Math.PI / 2)), 0.0f);
    }
    GL11.glEnd();

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

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

License:Open Source License

/**
 * GL_DrawParticles//  www .j  ava  2 s  .  c o  m
 */
void GL_DrawParticles(int num_particles) {
    float origin_x, origin_y, origin_z;

    Math3D.VectorScale(vup, 1.5f, up);
    Math3D.VectorScale(vright, 1.5f, right);

    GL_Bind(r_particletexture.texnum);
    GL11.glDepthMask(false); // no z buffering
    GL11.glEnable(GL11.GL_BLEND);
    GL_TexEnv(GL11.GL_MODULATE);

    GL11.glBegin(GL11.GL_TRIANGLES);

    FloatBuffer sourceVertices = particle_t.vertexArray;
    IntBuffer sourceColors = particle_t.colorArray;
    float scale;
    int color;
    for (int j = 0, i = 0; i < num_particles; i++) {
        origin_x = sourceVertices.get(j++);
        origin_y = sourceVertices.get(j++);
        origin_z = sourceVertices.get(j++);

        // hack a scale up to keep particles from disapearing
        scale = (origin_x - r_origin[0]) * vpn[0] + (origin_y - r_origin[1]) * vpn[1]
                + (origin_z - r_origin[2]) * vpn[2];

        scale = (scale < 20) ? 1 : 1 + scale * 0.004f;

        color = sourceColors.get(i);

        GL11.glColor4ub((byte) ((color) & 0xFF), (byte) ((color >> 8) & 0xFF), (byte) ((color >> 16) & 0xFF),
                (byte) ((color >>> 24)));
        // first vertex
        GL11.glTexCoord2f(0.0625f, 0.0625f);
        GL11.glVertex3f(origin_x, origin_y, origin_z);
        // second vertex
        GL11.glTexCoord2f(1.0625f, 0.0625f);
        GL11.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale);
        // third vertex
        GL11.glTexCoord2f(0.0625f, 1.0625f);
        GL11.glVertex3f(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale);
    }
    GL11.glEnd();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1, 1, 1, 1);
    GL11.glDepthMask(true); // back to normal Z buffering
    GL_TexEnv(GL11.GL_REPLACE);
}

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

License:Open Source License

/**
 * R_PolyBlend//www .  java 2s .c  om
 */
void R_PolyBlend() {
    if (gl_polyblend.value == 0.0f)
        return;

    if (v_blend[3] == 0.0f)
        return;

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glLoadIdentity();

    // FIXME: get rid of these
    GL11.glRotatef(-90, 1, 0, 0); // put Z going up
    GL11.glRotatef(90, 0, 0, 1); // put Z going up

    GL11.glColor4f(v_blend[0], v_blend[1], v_blend[2], v_blend[3]);

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex3f(10, 100, 100);
    GL11.glVertex3f(10, -100, 100);
    GL11.glVertex3f(10, -100, -100);
    GL11.glVertex3f(10, 100, -100);
    GL11.glEnd();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    GL11.glColor4f(1, 1, 1, 1);
}

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

License:Open Source License

/**
 * R_DrawBeam//w ww .ja va 2 s .com
 */
void R_DrawBeam(entity_t e) {
    oldorigin[0] = e.oldorigin[0];
    oldorigin[1] = e.oldorigin[1];
    oldorigin[2] = e.oldorigin[2];

    origin[0] = e.origin[0];
    origin[1] = e.origin[1];
    origin[2] = e.origin[2];

    normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
    normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
    normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];

    if (Math3D.VectorNormalize(normalized_direction) == 0.0f)
        return;

    Math3D.PerpendicularVector(perpvec, normalized_direction);
    Math3D.VectorScale(perpvec, e.frame / 2, perpvec);

    for (int i = 0; i < 6; i++) {
        Math3D.RotatePointAroundVector(start_points[i], normalized_direction, perpvec,
                (360.0f / NUM_BEAM_SEGS) * i);

        Math3D.VectorAdd(start_points[i], origin, start_points[i]);
        Math3D.VectorAdd(start_points[i], direction, end_points[i]);
    }

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDepthMask(false);

    float r = (d_8to24table[e.skinnum & 0xFF]) & 0xFF;
    float g = (d_8to24table[e.skinnum & 0xFF] >> 8) & 0xFF;
    float b = (d_8to24table[e.skinnum & 0xFF] >> 16) & 0xFF;

    r *= 1 / 255.0f;
    g *= 1 / 255.0f;
    b *= 1 / 255.0f;

    GL11.glColor4f(r, g, b, e.alpha);

    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);

    float[] v;

    for (int i = 0; i < NUM_BEAM_SEGS; i++) {
        v = start_points[i];
        GL11.glVertex3f(v[0], v[1], v[2]);
        v = end_points[i];
        GL11.glVertex3f(v[0], v[1], v[2]);
        v = start_points[(i + 1) % NUM_BEAM_SEGS];
        GL11.glVertex3f(v[0], v[1], v[2]);
        v = end_points[(i + 1) % NUM_BEAM_SEGS];
        GL11.glVertex3f(v[0], v[1], v[2]);
    }
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
}

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

License:Open Source License

/**
 * GL_DrawAliasShadow//from w w  w .ja  v  a2s .  com
 */
void GL_DrawAliasShadow(qfiles.dmdl_t paliashdr, int posenum) {
    float lheight = currententity.origin[2] - lightspot[2];
    // qfiles.daliasframe_t frame = paliashdr.aliasFrames[currententity.frame];
    int[] order = paliashdr.glCmds;
    float height = -lheight + 1.0f;

    int orderIndex = 0;
    int index = 0;

    // TODO shadow drawing with vertex arrays

    int count;
    while (true) {
        // get the vertex count and primitive type
        count = order[orderIndex++];
        if (count == 0)
            break; // done
        if (count < 0) {
            count = -count;
            GL11.glBegin(GL11.GL_TRIANGLE_FAN);
        } else
            GL11.glBegin(GL11.GL_TRIANGLE_STRIP);

        do {
            index = order[orderIndex + 2] * 3;
            point[0] = vertexArrayBuf.get(index);
            point[1] = vertexArrayBuf.get(index + 1);
            point[2] = vertexArrayBuf.get(index + 2);

            point[0] -= shadevector[0] * (point[2] + lheight);
            point[1] -= shadevector[1] * (point[2] + lheight);
            point[2] = height;
            GL11.glVertex3f(point[0], point[1], point[2]);

            orderIndex += 3;

        } while (--count != 0);

        GL11.glEnd();
    }
}

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

License:Open Source License

/**
 * R_DrawTriangleOutlines//from  ww w  . j av a  2  s.c o m
 */
void R_DrawTriangleOutlines() {
    if (gl_showtris.value == 0)
        return;

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glColor4f(1, 1, 1, 1);

    msurface_t surf;
    glpoly_t p;
    int j;
    for (int i = 0; i < MAX_LIGHTMAPS; i++) {
        for (surf = gl_lms.lightmap_surfaces[i]; surf != null; surf = surf.lightmapchain) {
            for (p = surf.polys; p != null; p = p.chain) {
                for (j = 2; j < p.numverts; j++) {
                    GL11.glBegin(GL11.GL_LINE_STRIP);
                    GL11.glVertex3f(p.x(0), p.y(0), p.z(0));
                    GL11.glVertex3f(p.x(j - 1), p.y(j - 1), p.z(j - 1));
                    GL11.glVertex3f(p.x(j), p.y(j), p.z(j));
                    GL11.glVertex3f(p.x(0), p.y(0), p.z(0));
                    GL11.glEnd();
                }
            }
        }
    }

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}