List of usage examples for org.lwjgl.opengl GL11 glEnd
public static native void glEnd();
From source file:com.acornui.jvm.LwjglHelloWorld.java
License:Apache License
private void draw() { // set the color of the quad (R,G,B,A) GL11.glColor3f(0.5f, 0.5f, 1.0f);/*from w w w. jav a2 s . c om*/ // draw quad GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(100, 100); GL11.glVertex2f(100 + 200, 100); GL11.glVertex2f(100 + 200, 100 + 200); GL11.glVertex2f(100, 100 + 200); GL11.glEnd(); }
From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java
License:Open Source License
static void drawTorus(float r, float R, int nsides, int rings) { double ringDelta = 2.0f * (double) Math.PI / rings; double sideDelta = 2.0f * (double) Math.PI / nsides; double theta = 0.0f, cosTheta = 1.0f, sinTheta = 0.0f; for (int i = rings - 1; i >= 0; i--) { double theta1 = theta + ringDelta; double cosTheta1 = (double) Math.cos(theta1); double sinTheta1 = (double) Math.sin(theta1); GL11.glBegin(GL11.GL_QUAD_STRIP); float phi = 0.0f; for (int j = nsides; j >= 0; j--) { phi += sideDelta;/* w w w . j a v a 2 s.co m*/ double cosPhi = (double) Math.cos(phi); double sinPhi = (double) Math.sin(phi); double dist = R + r * cosPhi; GL11.glNormal3d(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); GL11.glVertex3d(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); GL11.glNormal3d(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); GL11.glVertex3d(cosTheta * dist, -sinTheta * dist, r * sinPhi); } GL11.glEnd(); theta = theta1; cosTheta = cosTheta1; sinTheta = sinTheta1; } }
From source file:com.ardor3d.renderer.lwjgl.LwjglFont.java
License:Open Source License
/** * <code>buildDisplayList</code> sets up the 256 display lists that are used to render each font character. Each * list quad is 16x16, as defined by the font image size. *///from ww w.j a v a2 s .co m public void buildDisplayList() { float cx; float cy; base = GL11.glGenLists(256); for (int loop = 0; loop < 256; loop++) { cx = (loop % 16) / 16.0f; cy = (loop / 16) / 16.0f; GL11.glNewList(base + loop, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(cx, 1 - cy - 0.0625f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f); GL11.glVertex2i(16, 0); GL11.glTexCoord2f(cx + 0.0625f, 1 - cy); GL11.glVertex2i(16, 16); GL11.glTexCoord2f(cx, 1 - cy); GL11.glVertex2i(0, 16); GL11.glEnd(); GL11.glTranslatef(10, 0, 0); GL11.glEndList(); } }
From source file:com.badlogic.gdx.tools.hiero.unicodefont.UnicodeFont.java
License:Apache License
/** Identical to {@link #drawString(float, float, String, Color, int, int)} but returns a DisplayList which provides access to * the width and height of the text drawn. */ public void drawDisplayList(float x, float y, String text, Color color, int startIndex, int endIndex) { if (text == null) throw new IllegalArgumentException("text cannot be null."); if (text.length() == 0) return;//from www. jav a 2 s . c o m if (color == null) throw new IllegalArgumentException("color cannot be null."); x -= paddingLeft; y -= paddingTop; String displayListKey = text.substring(startIndex, endIndex); GL11.glColor4f(color.r, color.g, color.b, color.a); GL11.glTranslatef(x, y, 0); char[] chars = text.substring(0, endIndex).toCharArray(); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int maxWidth = 0, totalHeight = 0, lines = 0; int extraX = 0, extraY = ascent; boolean startNewLine = false; Texture lastBind = null; int offsetX = 0; for (int glyphIndex = 0, n = vector.getNumGlyphs(); glyphIndex < n; glyphIndex++) { int charIndex = vector.getGlyphCharIndex(glyphIndex); if (charIndex < startIndex) continue; if (charIndex > endIndex) break; int codePoint = text.codePointAt(charIndex); Rectangle bounds = getGlyphBounds(vector, glyphIndex, codePoint); bounds.x += offsetX; Glyph glyph = getGlyph(vector.getGlyphCode(glyphIndex), codePoint, bounds, vector, glyphIndex); if (startNewLine && codePoint != '\n') { extraX = -bounds.x; startNewLine = false; } if (glyph.getTexture() == null && missingGlyph != null && glyph.isMissing()) glyph = missingGlyph; if (glyph.getTexture() != null) { // Draw glyph, only binding a new glyph page texture when necessary. Texture texture = glyph.getTexture(); if (lastBind != null && lastBind != texture) { GL11.glEnd(); lastBind = null; } if (lastBind == null) { texture.bind(); GL11.glBegin(GL11.GL_QUADS); lastBind = texture; } int glyphX = bounds.x + extraX; int glyphY = bounds.y + extraY; GL11.glTexCoord2f(glyph.getU(), glyph.getV()); GL11.glVertex3f(glyphX, glyphY, 0); GL11.glTexCoord2f(glyph.getU(), glyph.getV2()); GL11.glVertex3f(glyphX, glyphY + glyph.getHeight(), 0); GL11.glTexCoord2f(glyph.getU2(), glyph.getV2()); GL11.glVertex3f(glyphX + glyph.getWidth(), glyphY + glyph.getHeight(), 0); GL11.glTexCoord2f(glyph.getU2(), glyph.getV()); GL11.glVertex3f(glyphX + glyph.getWidth(), glyphY, 0); } if (glyphIndex > 0) extraX += paddingRight + paddingLeft + paddingAdvanceX; maxWidth = Math.max(maxWidth, bounds.x + extraX + bounds.width); totalHeight = Math.max(totalHeight, ascent + bounds.y + bounds.height); if (codePoint == '\n') { startNewLine = true; // Mac gives -1 for bounds.x of '\n', so use the bounds.x of the next glyph. extraY += getLineHeight(); lines++; totalHeight = 0; } else if (nativeRendering) offsetX += bounds.width; } if (lastBind != null) GL11.glEnd(); GL11.glTranslatef(-x, -y, 0); }
From source file:com.bluepowermod.client.render.RenderHelper.java
License:Open Source License
public static void renderButton(double x, double y, double z, String res, String resSide) { GL11.glPushMatrix();/*ww w .ja va2 s .c o m*/ { GL11.glTranslated(x, y, z); GL11.glPushMatrix(); { GL11.glTranslated(6 / 16D, 2 / 16D, 8 / 16D); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(resSide)); for (int i = 0; i < 4; i++) { GL11.glTranslated(2 / 16D, 0, 2 / 16D); GL11.glRotated(90, 0, 1, 0); GL11.glTranslated(-2 / 16D, 0, -2 / 16D); GL11.glBegin(GL11.GL_QUADS); { GL11.glNormal3d(1, 0, 0); addVertexWithTexture(0, 0, 0, 0, 0); addVertexWithTexture(0, 1 / 16D, 0, 0, 1); addVertexWithTexture(4 / 16D, 1 / 16D, 0, 1, 1); addVertexWithTexture(4 / 16D, 0, 0, 1, 0); } GL11.glEnd(); } } GL11.glPopMatrix(); GL11.glTranslated(0, 1 / 16D, 0 / 16D); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(res)); Tessellator t = Tessellator.instance; y = 2 / 16D; t.startDrawingQuads(); t.setNormal(0, 1, 0); { t.addVertexWithUV(0, y, 0, 1, 1); t.addVertexWithUV(0, y, 1, 1, 0); t.addVertexWithUV(1, y, 1, 0, 0); t.addVertexWithUV(1, y, 0, 0, 1); } t.draw(); } GL11.glPopMatrix(); }
From source file:com.bluepowermod.client.render.RenderHelper.java
License:Open Source License
/** * @author amadornes//from w w w. j a v a2 s . com * @param x * @param y * @param z * @param angle */ public static void renderPointer(double x, double y, double z, double angle) { GL11.glPushMatrix(); { GL11.glTranslated(x, y, z); GL11.glTranslated(0.5, 0.5, 0.5); GL11.glRotated(180 + 360 * -angle, 0, 1, 0); GL11.glTranslated(-0.5, -0.5, -0.5); Minecraft.getMinecraft().renderEngine .bindTexture(new ResourceLocation("minecraft:textures/blocks/stone.png")); GL11.glBegin(GL11.GL_QUADS); { GL11.glNormal3d(0, -1, 0); // Bottom addVertexWithTexture(0.5, 0, 2D / 16D, 0.5, 1D / 16D); addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5); addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D); addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5); GL11.glNormal3d(0, 1, 0); // Top addVertexWithTexture(0.5, 1D / 16D, 2D / 16D, 0.5, 1D / 16D); addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5); addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D); addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5); GL11.glNormal3d(1, 0, 0); // Side 1 addVertexWithTexture(0.5, 1D / 16D, 2D / 16D, 0.5, 1D / 16D); addVertexWithTexture(0.5, 0, 2D / 16D, 0.5, 1D / 16D); addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5); addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5); // Side 2 addVertexWithTexture(0.5 - 1D / 8D, 1D / 16D, 0.5, 0.5 - 1D / 8D, 0.5); addVertexWithTexture(0.5 - 1D / 8D, 0, 0.5, 0.5 - 1D / 8D, 0.5); addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D); addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D); GL11.glNormal3d(-1, 0, 0); // Side 3 addVertexWithTexture(0.5, 1D / 16D, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D); addVertexWithTexture(0.5, 0, 0.5 + 1D / 8D, 0.5, 0.5 + 1D / 8D); addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5); addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5); // Side 4 addVertexWithTexture(0.5 + 1D / 8D, 1D / 16D, 0.5, 0.5 + 1D / 8D, 0.5); addVertexWithTexture(0.5 + 1D / 8D, 0, 0.5, 0.5 + 1D / 8D, 0.5); addVertexWithTexture(0.5, 0, 2D / 16D, 0.5, 1D / 16D); addVertexWithTexture(0.5, 1D / 16D, 2D / 16D, 0.5, 1D / 16D); } GL11.glEnd(); } GL11.glPopMatrix(); }
From source file:com.bluepowermod.client.render.RenderLamp.java
License:Open Source License
/******* TESR ***********/ @Override/*w w w . j a va 2s. com*/ public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) { if (pass != 0) { BlockLamp bLamp = (BlockLamp) te.getBlockType(); int power = ((TileLamp) te).getPower(); int color = bLamp.getColor(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord); int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF; int r = (color & redMask) >> 16; int g = (color & greenMask) >> 8; int b = (color & blueMask); if (bLamp.isInverted()) { power = 15 - power; } // power = 15; Vec3i vector = new Vec3i(te); Vec3dCube box = new Vec3dCube(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5).expand(0.8 / 16D); boolean[] renderFaces = new boolean[] { true, true, true, true, true, true }; for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { Vec3i v = vector.getRelative(d); Block bl = v.getBlock(); if (bl instanceof BlockLamp && ((BlockLamp) bl).getPower(v.getWorld(), v.getX(), v.getY(), v.getZ()) > 0) { if (d.offsetX < 0) { box.getMin().setX(-0.5); renderFaces[2] = false; } else if (d.offsetY < 0) { box.getMin().setY(-0.5); renderFaces[1] = false; } else if (d.offsetZ < 0) { box.getMin().setZ(-0.5); renderFaces[4] = false; } else if (d.offsetX > 0) { box.getMax().setX(0.5); renderFaces[3] = false; } else if (d.offsetY > 0) { box.getMax().setY(0.5); renderFaces[0] = false; } else if (d.offsetZ > 0) { box.getMax().setZ(0.5); renderFaces[5] = false; } } } box.getMin().add(0.5, 0.5, 0.5); box.getMax().add(0.5, 0.5, 0.5); GL11.glTranslated(x, y, z); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); // GL11.glDisable(GL11.GL_CULL_FACE); GL11.glBegin(GL11.GL_QUADS); double powerDivision = power / 18D; com.bluepowermod.client.render.RenderHelper.drawColoredCube(box, r / 256D, g / 256D, b / 256D, powerDivision * 0.625D, renderFaces); GL11.glEnd(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glDisable(GL11.GL_BLEND); GL11.glTranslated(-x, -y, -z); } }
From source file:com.bluepowermod.client.render.RenderLamp.java
License:Open Source License
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix();/*w ww . ja va 2 s .com*/ { switch (type) { case ENTITY: GL11.glTranslated(-0.5, -0.5, -0.5); break; case EQUIPPED: break; case EQUIPPED_FIRST_PERSON: GL11.glTranslated(0, -0.1, 0); break; case INVENTORY: GL11.glTranslated(0, -0.1, 0); break; default: break; } BlockLamp block = (BlockLamp) Block.getBlockFromItem(item.getItem()); int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF; int r = (block.getColor() & redMask) >> 16; int g = (block.getColor() & greenMask) >> 8; int b = (block.getColor() & blueMask); Vec3dCube cube = new Vec3dCube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); Tessellator t = Tessellator.instance; t.startDrawingQuads(); t.setColorOpaque(r, g, b); RenderHelper h = RenderHelper.instance; h.reset(); h.setColor(block.getColor()); h.renderBox(cube, block.isInverted() ? BlockLamp.on : BlockLamp.off); h.reset(); t.draw(); if (block.isInverted()) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); // GL11.glAlphaFunc(GL11.GL_EQUAL, (power / 15F) * 1F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); // GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); GL11.glBegin(GL11.GL_QUADS); com.bluepowermod.client.render.RenderHelper.drawColoredCube(cube.clone().expand(0.8 / 16D), r / 256D, g / 256D, b / 256D, 0.625D); GL11.glEnd(); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glDisable(GL11.GL_BLEND); } } GL11.glPopMatrix(); }
From source file:com.bluepowermod.part.gate.ic.IntegratedCircuit.java
License:Open Source License
@Override @SideOnly(Side.CLIENT)//from ww w. j a va 2 s . c om protected void renderTop(float frame) { renderTop("front", front()); renderTop("left", left()); renderTop("back", back()); renderTop("right", right()); Vec3d loc = new Vec3d(0, 0, 0); RenderHelper rh = RenderHelper.instance; rh.reset(); RenderBlocks rb = RenderBlocks.getInstance(); GL11.glPushMatrix(); { GL11.glTranslated(0, 2 / 16D - 1 / 16D * (1.0 / getCircuitWidth()), 0); GL11.glNormal3d(0, 1, 0); int size = getCircuitWidth(); double textureMaxUV = 0.5 * size; Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation( Refs.MODID + ":textures/blocks/gates/" + getTextureName() + "/checkerboard.png")); GL11.glBegin(GL11.GL_QUADS); { com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(BORDER_WIDTH, 0, BORDER_WIDTH, 0, 0); com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(BORDER_WIDTH, 0, 1 - BORDER_WIDTH, 0, textureMaxUV); com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(1 - BORDER_WIDTH, 0, 1 - BORDER_WIDTH, textureMaxUV, textureMaxUV); com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(1 - BORDER_WIDTH, 0, BORDER_WIDTH, textureMaxUV, 0); } GL11.glEnd(); } GL11.glPopMatrix(); GL11.glPushMatrix(); { GL11.glTranslated(BORDER_WIDTH, 2 / 16D + 0.001D, BORDER_WIDTH); GL11.glScaled((1 - 2 * BORDER_WIDTH) / 1, 1, (1 - 2 * BORDER_WIDTH) / 1); GL11.glScaled(1.0 / getCircuitWidth(), 1.0 / getCircuitWidth(), 1.0 / getCircuitWidth()); GL11.glTranslated(0, -2 / 16D, 0); for (GateBase[] gateArray : gates) { GL11.glPushMatrix(); for (GateBase gate : gateArray) { if (gate != null) { GL11.glPushMatrix(); gate.renderDynamic(loc, frame, 0); GL11.glPopMatrix(); if (!isRenderingItem) { // Static renderer GL11.glPushMatrix(); { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); Tessellator.instance.startDrawingQuads(); gate.renderStatic(new Vec3i(gate), rh, rb, 0); Tessellator.instance.draw(); } GL11.glPopMatrix(); } rh.reset(); } GL11.glTranslated(0, 0, 1); } GL11.glPopMatrix(); GL11.glTranslated(1, 0, 0); } } GL11.glPopMatrix(); }
From source file:com.bluepowermod.part.lamp.PartCageLamp.java
License:Open Source License
@Override @SideOnly(Side.CLIENT)//from w w w .j a v a2 s. co m public void renderGlow(int pass) { Vec3dCube vector = new Vec3dCube(5 / 16D, 2 / 16D, 5 / 16D, 11 / 16D, 11 / 16D, 11 / 16D).rotate(getFace(), Vec3d.center); double r = ((color.getHex() & 0xFF0000) >> 16) / 256D; double g = ((color.getHex() & 0x00FF00) >> 8) / 256D; double b = (color.getHex() & 0x0000FF) / 256D; if (pass == 1) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glBegin(GL11.GL_QUADS); com.bluepowermod.client.render.RenderHelper.drawColoredCube(vector.clone().expand(0.5 / 16D), r, g, b, ((inverted ? 255 - (power & 0xFF) : (power & 0xFF)) / 255D) * 0.625); GL11.glEnd(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_BLEND); } }