Example usage for org.lwjgl.opengl GL11 glNormal3f

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

Introduction

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

Prototype

public static native void glNormal3f(@NativeType("GLfloat") float nx, @NativeType("GLfloat") float ny,
        @NativeType("GLfloat") float nz);

Source Link

Document

Sets the current normal.

Usage

From source file:com.kegare.frozenland.client.renderer.FrozenlandWheatherRenderer.java

License:Minecraft Mod Public

@Override
public void render(float ticks, WorldClient world, Minecraft mc) {
    ++rendererUpdateCount;//from  ww w  . j a  v a2s .  c om

    float rainStrength = mc.theWorld.getRainStrength(ticks);

    if (rainStrength > 0.0F) {
        mc.entityRenderer.enableLightmap(ticks);

        if (rainXCoords == null) {
            rainXCoords = new float[1024];
            rainYCoords = new float[1024];

            for (int i = 0; i < 32; ++i) {
                for (int j = 0; j < 32; ++j) {
                    float f1 = j - 16;
                    float f2 = i - 16;
                    float f3 = MathHelper.sqrt_float(f1 * f1 + f2 * f2);

                    rainXCoords[i << 5 | j] = -f2 / f3;
                    rainYCoords[i << 5 | j] = f1 / f3;
                }
            }
        }

        EntityLivingBase entity = mc.renderViewEntity;
        int x = MathHelper.floor_double(entity.posX);
        int y = MathHelper.floor_double(entity.posY);
        int z = MathHelper.floor_double(entity.posZ);
        Tessellator tessellator = Tessellator.instance;
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * ticks;
        double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * ticks;
        double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * ticks;
        int i = MathHelper.floor_double(d1);
        byte range = 5;

        if (mc.gameSettings.fancyGraphics) {
            range = 10;
        }

        byte b1 = -1;
        float f1 = rendererUpdateCount + ticks;

        if (mc.gameSettings.fancyGraphics) {
            range = 10;
        }

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        for (int j = z - range; j <= z + range; ++j) {
            for (int k = x - range; k <= x + range; ++k) {
                int index = (j - z + 16) * 32 + k - x + 16;
                float f2 = rainXCoords[index] * 0.5F;
                float f3 = rainYCoords[index] * 0.5F;
                int height = world.getPrecipitationHeight(k, j);
                int cloud = MathHelper.floor_float(world.provider.getCloudHeight());
                int l = MathHelper.clamp_int(y - range, height, cloud);
                int m = MathHelper.clamp_int(y + range, height, cloud);

                if (l == cloud || m == cloud) {
                    continue;
                }

                float f4 = 1.35F;
                int n = height;

                if (height < i) {
                    n = i;
                }

                if (l != m) {
                    random.setSeed(k * k * 3121 + k * 45238971 ^ j * j * 418711 + j * 13761);

                    if (b1 != 1) {
                        if (b1 >= 0) {
                            tessellator.draw();
                        }

                        b1 = 1;
                        mc.getTextureManager().bindTexture(locationSnowPng);
                        tessellator.startDrawingQuads();
                    }

                    float f5 = ((rendererUpdateCount & 0x1FF) + ticks) / 512.0F;
                    float f6 = random.nextFloat() + f1 * 0.01F * (float) random.nextGaussian();
                    float f7 = random.nextFloat() + f1 * (float) random.nextGaussian() * 0.001F;
                    double xDist = k + 0.5F - entity.posX;
                    double zDist = j + 0.5F - entity.posZ;
                    float f8 = MathHelper.sqrt_double(xDist * xDist + zDist * zDist) / range;
                    tessellator.setBrightness(
                            (world.getLightBrightnessForSkyBlocks(k, n, j, 0) * 3 + 15728880) / 4);
                    tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F,
                            ((1.0F - f8 * f8) * 0.3F + 0.5F) * rainStrength);
                    tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D);
                    tessellator.addVertexWithUV(k - f2 + 0.5D, l, j - f3 + 0.5D, 0.0F * f4 + f6,
                            l * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k + f2 + 0.5D, l, j + f3 + 0.5D, 1.0F * f4 + f6,
                            l * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k + f2 + 0.5D, m, j + f3 + 0.5D, 1.0F * f4 + f6,
                            m * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k - f2 + 0.5D, m, j - f3 + 0.5D, 0.0F * f4 + f6,
                            m * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
                }
            }
        }

        if (b1 >= 0) {
            tessellator.draw();
        }

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);

        mc.entityRenderer.disableLightmap(ticks);
    }
}

From source file:com.maxkorlaar.hypixel.PartyTagRender.java

License:Open Source License

public void renderName(RendererLivingEntity renderer, String str, EntityPlayer entityIn, double x, double y,
        double z) {
    FontRenderer fontrenderer = renderer.getFontRendererFromRenderManager(); // The thingy that can render text on our screen
    float f = 1.6F; // Okay this is where the witchcraft begins. A float is like an integer, with decimals. For some reason, it also has an F at the end of it to remind us of the fact that it is, in fact, a float.
    // We would simply call it a number, although unfortunately programmers turn out to be a bit picky.
    float f1 = 0.016666668F * f;
    GlStateManager.pushMatrix(); // * random green chars fall down on a black screen *
    GlStateManager.translate((float) x + 0.0F, (float) y + entityIn.height + 0.5F, (float) z); // So, are you going to take the red pill or the blue pill?
    // Actually, the above means that we're deciding where the stuff should be rendered. Translating here doesn't mean from English to Dutch or something, but rather moving the 'object' in a threedimensional space.
    GL11.glNormal3f(0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-renderer.getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(renderer.getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
    // I guess that makes sure that it stays aligned with the player's nametag, as seen by us?
    GlStateManager.scale(-f1, -f1, f1);//from  w  ww .  jav  a  2s . co m
    GlStateManager.disableLighting();
    GlStateManager.depthMask(false);
    GlStateManager.disableDepth();
    GlStateManager.enableBlend();
    // Some advanced stuff making it look OK!
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    // But.. Will it blend??
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer(); // This object makes it possible to just dump our renders into the actual rendered world
    // Actually just ignore it from here on. As most programmers tend to do, just copy the code, see if it works and make sure NOT TO TOUCH IT IF IT WORKS SUCCESSFULLY!
    int i = 0;

    int j = fontrenderer.getStringWidth(str) / 2;
    GlStateManager.disableTexture2D();
    worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
    worldrenderer.pos((double) (-j - 1), (double) (-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    worldrenderer.pos((double) (-j - 1), (double) (8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    worldrenderer.pos((double) (j + 1), (double) (8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    worldrenderer.pos((double) (j + 1), (double) (-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127);
    GlStateManager.enableDepth();
    GlStateManager.depthMask(true);
    fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1);
    GlStateManager.enableLighting();
    GlStateManager.disableBlend();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.popMatrix();

    // Advanced stuff, Ben! I doubt that I myself am ever going to become a 'professional' / 'good' Java programmer :P
}

From source file:com.replaymod.pixelcam.renderer.PathVisualizer.java

License:Apache License

private void drawPoint(double playerX, double playerY, double playerZ, Position pos, int index) {
    GlStateManager.pushMatrix();//from  ww w. ja va2  s.c  o  m
    GlStateManager.pushAttrib();

    GlStateManager.enableBlend();

    GlStateManager.color(1, 1, 1, 0.5f);

    VertexBuffer vb = Tessellator.getInstance().getBuffer();

    mc.renderEngine.bindTexture(pointTexture);

    double x = pos.getX() - playerX;
    double y = pos.getY() - playerY;
    double z = pos.getZ() - playerZ;

    GlStateManager.translate(x, y + mc.player.eyeHeight, z);

    float pitch = mc.getRenderManager().playerViewX;
    float yaw = mc.getRenderManager().playerViewY;

    GL11.glNormal3f(0, 1, 0);

    GlStateManager.rotate(-yaw, 0, 1, 0);
    GlStateManager.rotate(pitch, 1, 0, 0);

    float minX = -0.5f;
    float minY = -0.5f;
    float maxX = 0.5f;
    float maxY = 0.5f;

    float size = 10 / 16f;

    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);

    vb.pos(minX, minY, 0).tex(size, size).endVertex();
    vb.pos(minX, maxY, 0).tex(size, 0).endVertex();
    vb.pos(maxX, maxY, 0).tex(0, 0).endVertex();
    vb.pos(maxX, minY, 0).tex(0, size).endVertex();

    Tessellator.getInstance().draw();
    vb.setTranslation(0, 0, 0);

    GlStateManager.disableBlend();

    String string = String.valueOf(index);
    float scale = 0.05f / (string.length());

    GlStateManager.rotate(180, 0, 0, 1);
    GlStateManager.scale(scale, scale, scale);
    GlStateManager.translate(-mc.fontRenderer.getStringWidth(string) / 2 + 0.5, -3.5, -0.1);
    mc.fontRenderer.drawString(string, 0, 0, Color.BLACK.getRGB());

    GlStateManager.popAttrib();
    GlStateManager.popMatrix();
}

From source file:de.ellpeck.actuallyadditions.mod.util.AssetUtil.java

@SideOnly(Side.CLIENT)
public static void renderNameTag(String tag, double x, double y, double z) {
    FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
    float f = 1.6F;
    float f1 = 0.016666668F * f;
    GlStateManager.pushMatrix();//w w w  . j  a  v  a  2s.  c o m
    GlStateManager.translate(x, y, z);
    GL11.glNormal3f(0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(-f1, -f1, f1);
    GlStateManager.disableLighting();
    GlStateManager.depthMask(false);
    GlStateManager.disableDepth();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer renderer = tessellator.getBuffer();
    int i = 0;
    int j = fontrenderer.getStringWidth(tag) / 2;
    GlStateManager.disableTexture2D();
    renderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
    renderer.pos((double) (-j - 1), (double) (-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    renderer.pos((double) (-j - 1), (double) (8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    renderer.pos((double) (j + 1), (double) (8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    renderer.pos((double) (j + 1), (double) (-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, 553648127);
    GlStateManager.enableDepth();
    GlStateManager.depthMask(true);
    fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, -1);
    GlStateManager.enableLighting();
    GlStateManager.disableBlend();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.popMatrix();
}

From source file:de.sanandrew.mods.turretmod.client.render.entity.RenderTurretArrow.java

License:Creative Commons License

public void doRender(EntityArrow arrow, double x, double y, double z, float yaw, float partTicks) {
    this.bindEntityTexture(arrow);
    GL11.glPushMatrix();/*  ww w  .j ava  2 s. c  om*/
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glRotatef(arrow.prevRotationYaw + (arrow.rotationYaw - arrow.prevRotationYaw) * partTicks - 90.0F,
            0.0F, 1.0F, 0.0F);
    GL11.glRotatef(arrow.prevRotationPitch + (arrow.rotationPitch - arrow.prevRotationPitch) * partTicks, 0.0F,
            0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    float shake = arrow.arrowShake - partTicks;

    if (shake > 0.0F) {
        float shakeVal = -MathHelper.sin(shake * 3.0F) * shake;
        GL11.glRotatef(shakeVal, 0.0F, 0.0F, 1.0F);
    }

    float scale = 0.03625F;
    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(scale, 0.0F, 0.0F);

    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, 0.0F, 0.15625F);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, 0.15625F, 0.15625F);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, 0.15625F, 0.3125F);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, 0.0F, 0.3125F);
    tessellator.draw();
    GL11.glNormal3f(-scale, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, 0.0F, 0.15625F);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, 0.15625F, 0.15625F);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, 0.15625F, 0.3125F);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, 0.0F, 0.3125F);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, scale);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, 0.0F, 0.0F);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, 0.5F, 0.0F);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, 0.5F, 0.15625F);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, 0.0F, 0.15625F);
        tessellator.draw();
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:electricMagicTools.tombenpotter.electricmagictools.client.renderer.RenderLaser.java

License:Open Source License

public void renderArrow(EntityLaser entityLaser, double par2, double par4, double par6, float par8,
        float par9) {

    this.bindEntityTexture(entityLaser);
    GL11.glPushMatrix();//from w w w . j  a v a2  s  . c  o m
    GL11.glTranslatef((float) par2, (float) par4, (float) par6);
    GL11.glRotatef(entityLaser.prevRotationYaw + (entityLaser.rotationYaw - entityLaser.prevRotationYaw) * par9
            - 90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(
            entityLaser.prevRotationPitch + (entityLaser.rotationPitch - entityLaser.prevRotationPitch) * par9,
            0.0F, 0.0F, 1.0F);
    Tessellator tessellator = Tessellator.instance;
    byte b0 = 0;
    float f2 = 0.4F;
    float f3 = 0.7F;
    float f4 = (float) (0 + b0 * 10) / 32.0F;
    float f5 = (float) (5 + b0 * 10) / 32.0F;
    float f6 = 0.0F;
    float f7 = 0.15625F;
    float f8 = (float) (5 + b0 * 10) / 32.0F;
    float f9 = (float) (10 + b0 * 10) / 32.0F;
    float f10 = 0.05625F;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(f10, f10, f10);
    GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
    GL11.glNormal3f(f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f9);
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f9);
    tessellator.draw();
    GL11.glNormal3f(-f10, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double) f6, (double) f8);
    tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double) f7, (double) f8);
    tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double) f7, (double) f9);
    tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double) f6, (double) f9);
    tessellator.draw();

    for (int i = 0; i < 4; ++i) {
        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glNormal3f(0.0F, 0.0F, f10);
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double) f2, (double) f4);
        tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double) f3, (double) f4);
        tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double) f3, (double) f5);
        tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double) f2, (double) f5);
        tessellator.draw();
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:engine.obj.OBJLoader.java

License:Open Source License

/**
 * Renders a given <code>Obj</code> file.
 *
 * @param model the <code>Obj</code> file to be rendered
 *//*from ww w  .  j  a v  a2  s.co m*/
public void render(Obj model) {
    GL11.glMaterialf(GL_FRONT, GL_SHININESS, 120);
    GL11.glBegin(GL_TRIANGLES);
    {
        for (Obj.Face face : model.getFaces()) {
            Vector3f[] normals = { model.getNormals().get(face.getNormals()[0] - 1),
                    model.getNormals().get(face.getNormals()[1] - 1),
                    model.getNormals().get(face.getNormals()[2] - 1) };
            Vector2f[] texCoords = { model.getTextureCoordinates().get(face.getTextureCoords()[0] - 1),
                    model.getTextureCoordinates().get(face.getTextureCoords()[1] - 1),
                    model.getTextureCoordinates().get(face.getTextureCoords()[2] - 1) };
            Vector3f[] vertices = { model.getVertices().get(face.getVertices()[0] - 1),
                    model.getVertices().get(face.getVertices()[1] - 1),
                    model.getVertices().get(face.getVertices()[2] - 1) };
            {
                GL11.glNormal3f(normals[0].getX(), normals[0].getY(), normals[0].getZ());
                GL11.glTexCoord2f(texCoords[0].getX(), texCoords[0].getY());
                GL11.glVertex3f(vertices[0].getX(), vertices[0].getY(), vertices[0].getZ());
                GL11.glNormal3f(normals[1].getX(), normals[1].getY(), normals[1].getZ());
                GL11.glTexCoord2f(texCoords[1].getX(), texCoords[1].getY());
                GL11.glVertex3f(vertices[1].getX(), vertices[1].getY(), vertices[1].getZ());
                GL11.glNormal3f(normals[2].getX(), normals[2].getY(), normals[2].getZ());
                GL11.glTexCoord2f(texCoords[2].getX(), texCoords[2].getY());
                GL11.glVertex3f(vertices[2].getX(), vertices[2].getY(), vertices[2].getZ());
            }
        }
    }
    GL11.glEnd();
}

From source file:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void draw2DRect(float x0, float y0, float x1, float y1, float z) {
    GL11.glBegin(GL11.GL_QUADS);//from   w ww .  j a  v  a 2 s .c om
    GL11.glNormal3f(0, 0, 1);
    GL11.glTexCoord2d(0, 0);
    GL11.glVertex3d(x0, y0, z);
    GL11.glNormal3f(0, 0, 1);
    GL11.glTexCoord2d(0, 0.9999999);
    GL11.glVertex3d(x0, y1, z);
    GL11.glNormal3f(0, 0, 1);
    GL11.glTexCoord2d(0.9999999, 0.9999999);
    GL11.glVertex3d(x1, y1, z);
    GL11.glNormal3f(0, 0, 1);
    GL11.glTexCoord2d(0.9999999, 0);
    GL11.glVertex3d(x1, y0, z);
    GL11.glEnd();
}

From source file:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void drawCircle(float r, float d) {

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);/*from  w ww .  ja  v a 2  s . co  m*/

    for (float a = (float) ((2.0f * Math.PI) / d); a < 2 * Math.PI; a += (2.0f * Math.PI) / (float) d) {

        GL11.glNormal3f(0, 0, -1.0f);
        GL11.glTexCoord2d((Math.sin(a) + 1.0f) / 2.0f, (Math.cos(a) + 1.0f) / 2.0f);
        GL11.glVertex3d(Math.sin(a) * r, Math.cos(a) * r, 0);

    }

    GL11.glEnd();

}

From source file:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void drawHexagon(float r) {
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);//from w ww.j a  va  2 s . c  o  m

    for (float a = (float) ((2.0f * Math.PI) / 6.0f); a < 2 * Math.PI; a += (2.0f * Math.PI) / 6.0f) {

        GL11.glNormal3f(0, 0, -1.0f);
        GL11.glTexCoord2d((Math.sin(a) + 1.0f) / 2.0f, (Math.cos(a) + 1.0f) / 2.0f);
        GL11.glVertex3d(Math.sin(a) * r, Math.cos(a) * r, 0);

    }
    GL11.glEnd();
}