List of usage examples for org.lwjgl.opengl GL11 glEnd
public static native void glEnd();
From source file:com.samrj.devil.graphics.GraphicsUtil.java
public static void drawCircle(Vec2 pos, float radius, int segments, int mode) { float dt = 8.0f / segments; GL11.glBegin(mode);/*from w ww . jav a2 s . co m*/ for (float t = 0.0f; t < 8.0f; t += dt) glVertex(Util.squareDir(t).normalize().mult(radius).add(pos)); GL11.glEnd(); }
From source file:com.samrj.devil.ui.Font.java
License:Open Source License
public void draw(String text, Vec2 pos, Vec2 align) { pos = new Vec2(pos.x, pos.y - cellHeight); align = new Vec2(align.x - 1.0f, -align.y - 1.0f).mult(0.5f); align.x *= getWidth(text);/*from www . j a v a 2 s.com*/ align.y *= -height; pos.add(align); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glTranslatef(Math.round(pos.x), Math.round(pos.y), 0.0f); float x0 = 0f; GL11.glEnable(GL11.GL_TEXTURE_2D); tex.bind(); GL11.glBegin(GL11.GL_QUADS); for (int i = 0; i < text.length(); i++) { int charbits = text.charAt(i) - 32; int fontposx = charbits & 0xF; int fontposy = 15 - (charbits >> 4); float u0 = fontposx++ / 16f; float v0 = fontposy++ / 16f; float u1 = fontposx / 16f; float v1 = fontposy / 16f; float x1 = x0 + cellHeight; GL11.glTexCoord2f(u0, v0); GL11.glVertex2f(x0, 0f); GL11.glTexCoord2f(u0, v1); GL11.glVertex2f(x0, cellHeight); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, cellHeight); GL11.glTexCoord2f(u1, v0); GL11.glVertex2f(x1, 0f); x0 += getWidth(text.charAt(i)); } GL11.glEnd(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void drawOverdraw(int level) { GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT); GL11.glStencilFunc(level == 5 ? GL11.GL_LEQUAL : GL11.GL_EQUAL, level, 0xf); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP); GL11.glTranslatef(mNode.bounds.x, -mNode.bounds.y, 0.0f); if (level == 2) { loadColor(ColorType.OVERDRAW_BLUE); } else if (level == 3) { loadColor(ColorType.OVERDRAW_GREEN); } else if (level == 4) { loadColor(ColorType.OVERDRAW_RED_LOW); } else if (level > 4) { loadColor(ColorType.OVERDRAW_RED_HIGH); }// w w w. j a v a 2s.co m GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0.0f, 0.0f, 0.0f); GL11.glVertex3f(mNode.bounds.width, 0.0f, 0.0f); GL11.glVertex3f(mNode.bounds.width, -mNode.bounds.height, 0.0f); GL11.glVertex3f(0.0f, -mNode.bounds.height, 0.0f); GL11.glEnd(); GL11.glPopAttrib(); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void drawImage(Node node, int textureId, boolean isBackground) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); loadColor(ColorType.COLOR_WHITE); GL11.glEnable(GL11.GL_TEXTURE_2D);/*from www. ja v a 2 s. c om*/ GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(0.0f, 0.0f, 0.0f); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(node.bounds.width, 0.0f, 0.0f); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(node.bounds.width, -node.bounds.height, 0.0f); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(0.0f, -node.bounds.height, 0.0f); GL11.glEnd(); GL11.glDisable(GL11.GL_TEXTURE_2D); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void drawDepth(Node node, float depth, int mode) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, mode); GL11.glBegin(mode == GL11.GL_FILL ? GL11.GL_QUAD_STRIP : GL11.GL_LINES); // Top-left.//from w w w .java 2 s.com GL11.glVertex3f(0.0f, 0.0f, 0.0f); GL11.glVertex3f(0.0f, 0.0f, depth); // Top-right. GL11.glVertex3f(node.bounds.width, 0.0f, 0.0f); GL11.glVertex3f(node.bounds.width, 0.0f, depth); // Bottom-right. GL11.glVertex3f(node.bounds.width, -node.bounds.height, 0.0f); GL11.glVertex3f(node.bounds.width, -node.bounds.height, depth); // Bottom-left. GL11.glVertex3f(0.0f, -node.bounds.height, 0.0f); GL11.glVertex3f(0.0f, -node.bounds.height, depth); // Complete the quad strip. if (mode == GL11.GL_FILL) { // Top-left. GL11.glVertex3f(0.0f, 0.0f, 0.0f); GL11.glVertex3f(0.0f, 0.0f, depth); } GL11.glEnd(); }
From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java
License:Mozilla Public License
private void drawFrontFace(Node node, float depth, int mode) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, mode); GL11.glBegin(GL11.GL_QUADS);//from w ww . j a va 2 s .c o m GL11.glVertex3f(0.0f, 0.0f, depth); GL11.glVertex3f(node.bounds.width, 0.0f, depth); GL11.glVertex3f(node.bounds.width, -node.bounds.height, depth); GL11.glVertex3f(0.0f, -node.bounds.height, depth); GL11.glEnd(); }
From source file:com.teambr.bookshelf.client.gui.component.control.GuiComponentSideSelector.java
License:Creative Commons License
/** * Draws the highlights onto the block//from w w w. java 2 s . c o m * @param selections The colors to render */ private void drawHighlights(List<Pair<SidePicker.Side, Color>> selections) { GlStateManager.disableLighting(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enableBlend(); GlStateManager.enableAlpha(); GlStateManager.disableDepth(); GlStateManager.disableTexture2D(); GL11.glBegin(GL11.GL_QUADS); for (Pair<SidePicker.Side, Color> pair : selections) { if (pair.getRight() != null) RenderUtils.setColor(pair.getRight()); switch (pair.getLeft()) { case XPos: GL11.glVertex3d(0.5, -0.5, -0.5); GL11.glVertex3d(0.5, 0.5, -0.5); GL11.glVertex3d(0.5, 0.5, 0.5); GL11.glVertex3d(0.5, -0.5, 0.5); break; case YPos: GL11.glVertex3d(-0.5, 0.5, -0.5); GL11.glVertex3d(-0.5, 0.5, 0.5); GL11.glVertex3d(0.5, 0.5, 0.5); GL11.glVertex3d(0.5, 0.5, -0.5); break; case ZPos: GL11.glVertex3d(-0.5, -0.5, 0.5); GL11.glVertex3d(0.5, -0.5, 0.5); GL11.glVertex3d(0.5, 0.5, 0.5); GL11.glVertex3d(-0.5, 0.5, 0.5); break; case XNeg: GL11.glVertex3d(-0.5, -0.5, -0.5); GL11.glVertex3d(-0.5, -0.5, 0.5); GL11.glVertex3d(-0.5, 0.5, 0.5); GL11.glVertex3d(-0.5, 0.5, -0.5); break; case YNeg: GL11.glVertex3d(-0.5, -0.5, -0.5); GL11.glVertex3d(0.5, -0.5, -0.5); GL11.glVertex3d(0.5, -0.5, 0.5); GL11.glVertex3d(-0.5, -0.5, 0.5); break; case ZNeg: GL11.glVertex3d(-0.5, -0.5, -0.5); GL11.glVertex3d(-0.5, 0.5, -0.5); GL11.glVertex3d(0.5, 0.5, -0.5); GL11.glVertex3d(0.5, -0.5, -0.5); break; default: } } GL11.glEnd(); GlStateManager.disableBlend(); GlStateManager.enableDepth(); GlStateManager.enableTexture2D(); }
From source file:com.teambr.bookshelf.client.gui.component.display.GuiComponentColoredZone.java
License:Creative Commons License
/** * Called to render the component/* w w w . j a v a 2 s. c om*/ */ @Override public void render(int guiLeft, int guiTop, int mouseX, int mouseY) { color = getDynamicColor(); GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enableBlend(); GlStateManager.enableAlpha(); GlStateManager.disableDepth(); GlStateManager.disableTexture2D(); GlStateManager.translate(xPos, yPos, 10); RenderUtils.setColor(color); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3d(0, 0, 0); GL11.glVertex3d(0, height, 0); GL11.glVertex3d(width, height, 0); GL11.glVertex3d(width, 0, 0); GL11.glEnd(); GlStateManager.disableBlend(); GlStateManager.enableDepth(); GlStateManager.enableTexture2D(); GlStateManager.popMatrix(); }
From source file:com.teambrmodding.luxetumbra.client.gui.GuiToggleMenu.java
License:Creative Commons License
@Override public void drawScreen(int mx, int my, float partialTicks) { super.drawScreen(mx, my, partialTicks); GlStateManager.pushMatrix();/*from www. j a v a 2s. c o m*/ GlStateManager.disableTexture2D(); final int x = width / 2; final int y = height / 2; final int maxRadius = 60; final boolean mouseIn = true; final float angle = mouseAngle(x, y, mx, my); final float distance = mouseDistance(x, y, mx, my); final int highlight = 5; GlStateManager.enableBlend(); GlStateManager.shadeModel(GL11.GL_SMOOTH); final int segments = 2; //TODO float totalDeg = 0F; final float degPer = 360F / segments; final List<int[]> stringPosition = new ArrayList<>(); boolean wasSelected = false; for (int seg = 0; seg <= segments; seg++) { boolean mouseOverSection = distance <= maxRadius && (mouseIn && angle > totalDeg && angle < totalDeg + degPer); float radius = Math.max(0F, Math.min(timeIn * 10F, maxRadius)); GL11.glBegin(GL11.GL_TRIANGLE_FAN); float gs = 0.25F; if (seg % 2 == 0) gs += 0.1F; float r = 200; //TODO float g = 200; //TODO float b = gs; float a = 0.4F; if (mouseOverSection) { selected = seg; wasSelected = true; r = 255; //TODO g = 255; //TODO a = 0.5F; } GlStateManager.color(r, g, b, a); GL11.glVertex2i(x, y); float i = degPer; while (i >= 0) { double rad = ((i + totalDeg) / 180F * Math.PI); double xp = x + Math.cos(rad) * radius; double yp = y + Math.sin(rad) * radius; if (i == (int) (degPer / 2)) stringPosition.add(new int[] { seg, (int) xp, (int) yp, mouseOverSection ? 'n' : 'r' }); GL11.glVertex2d(xp, yp); i -= 1; } totalDeg += degPer; GL11.glVertex2i(x, y); GL11.glEnd(); if (mouseOverSection) radius -= highlight; } if (!wasSelected) selected = -1; GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableTexture2D(); for (int[] pos : stringPosition) { int slot = pos[0]; float xp = pos[1]; float yp = pos[2]; char c = (char) pos[3]; ItemStack displayStack = new ItemStack(Items.APPLE); if (displayStack != null) { float xsp = xp - 4; float ysp = yp; String name = "\u00a7" + c + "testing"; int width = fontRendererObj.getStringWidth(name); float mod = 0.6F; int xdp = (int) ((xp - x) * mod + x); int ydp = (int) ((yp - y) * mod + y); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.pushMatrix(); GlStateManager.translate(xdp - 10, ydp - 10, 2); GlStateManager.scale(1.25, 1.25, 1.25); Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(displayStack, 0, 0); GlStateManager.popMatrix(); RenderHelper.disableStandardItemLighting(); if (xsp < x) xsp -= width - 8; if (ysp < y) ysp -= 9; fontRendererObj.drawStringWithShadow(name, xsp, ysp, 0xFFFFFF); } } GlStateManager.popMatrix(); }
From source file:com.telinc1.rpjg.module.Module.java
License:Apache License
/** * Renders the module's graphics and UI elements. * Also applied the screen darkening effect for modal modules.<br /> * Generally not a good idea to override this. *///from www .ja v a2s .c o m public void render() { if (this.isModal()) { DrawingUtils.unbindTextures(); // Not going to change this to use DrawingUtils until // I don't make actual modal modules. // Don't want untested code! GL11.glPushAttrib(DrawingUtils.GL_COLOR_BITS); GL11.glColor4f(0f, 0f, 0f, .5f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(0, 0); GL11.glVertex2i(Display.getWidth(), 0); GL11.glVertex2i(Display.getWidth(), Display.getHeight()); GL11.glVertex2i(0, Display.getHeight()); GL11.glEnd(); GL11.glPopAttrib(); } this.renderGraphics(); this.renderUI(); for (Gui gui : this.getGUIs()) { gui.render(); } }