Java Code Examples for org.lwjgl.opengl.GL11#glEnd()
The following examples show how to use
org.lwjgl.opengl.GL11#glEnd() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerEspHack.java From ForgeWurst with GNU General Public License v3.0 | 6 votes |
private void renderLines(double partialTicks) { Vec3d start = RotationUtils.getClientLookVec() .addVector(0, WMinecraft.getPlayer().getEyeHeight(), 0) .addVector(TileEntityRendererDispatcher.staticPlayerX, TileEntityRendererDispatcher.staticPlayerY, TileEntityRendererDispatcher.staticPlayerZ); GL11.glBegin(GL11.GL_LINES); for(EntityPlayer e : players) { Vec3d end = e.getEntityBoundingBox().getCenter() .subtract(new Vec3d(e.posX, e.posY, e.posZ) .subtract(e.prevPosX, e.prevPosY, e.prevPosZ) .scale(1 - partialTicks)); float f = WEntity.getDistance(WMinecraft.getPlayer(), e) / 20F; GL11.glColor4f(2 - f, f, 0, 0.5F); GL11.glVertex3d(WVec3d.getX(start), WVec3d.getY(start), WVec3d.getZ(start)); GL11.glVertex3d(WVec3d.getX(end), WVec3d.getY(end), WVec3d.getZ(end)); } GL11.glEnd(); }
Example 2
Source File: DebugRender.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
public final static void drawQuad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float z, float r, float g, float b) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor3f(r, g, b); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_LINE); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(x1, y1, z); GL11.glVertex3f(x2, y2, z); GL11.glVertex3f(x3, y3, z); GL11.glVertex3f(x4, y4, z); GL11.glEnd(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glPolygonMode(GL11.GL_BACK, GL11.GL_FILL); GL11.glEnable(GL11.GL_TEXTURE_2D); }
Example 3
Source File: Cursor.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public final void render(float x, float y) { if (render_gl_cursor || LocalEventQueue.getQueue().getDeterministic().isPlayback()) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getHandle()); GL11.glBegin(GL11.GL_QUADS); cursor.render(x - offset_x, y - offset_y); GL11.glEnd(); } }
Example 4
Source File: GUIRoot.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public final void renderTopmost() { if (Globals.draw_status) status.render(0, getWidth(), 0, getHeight()); GL11.glEnd(); // Started in renderGeometry() GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE); if (cursor_object.getCursorIndex() != CURSOR_NULL) { cursors[cursor_object.getCursorIndex()].setActive(); if (getModalDelegate() != null || getDelegate().renderCursor()) { cursors[cursor_object.getCursorIndex()].render(LocalInput.getMouseX(), LocalInput.getMouseY()); } } else PointerInput.setActiveCursor(null); }
Example 5
Source File: Gui.java From Slyther with MIT License | 5 votes |
public void drawTexture(float x, float y, float u, float v, float width, float height, float actualWidth, float actualHeight, float textureWidth, float textureHeight) { float uMultiplier = 1.0F / textureWidth; float vMultiplier = 1.0F / textureHeight; GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBegin(GL11.GL_QUADS); GL11.glShadeModel(GL11.GL_FLAT); drawVertex(x, y, u, v, uMultiplier, vMultiplier); drawVertex(x + actualWidth, y, u + width, v, uMultiplier, vMultiplier); drawVertex(x + actualWidth, y + actualHeight, u + width, v + height, uMultiplier, vMultiplier); drawVertex(x, y + actualHeight, u, v + height, uMultiplier, vMultiplier); GL11.glEnd(); }
Example 6
Source File: GuiComponentColorPicker.java From OpenModsLib with MIT License | 5 votes |
@Override public void render(int offsetX, int offsetY, int mouseX, int mouseY) { GlStateManager.color(1, 1, 1, 1); int renderX = offsetX + x; int renderY = offsetY + y; bindComponentsSheet(); drawTexturedModalRect(renderX, renderY, 156, 206, getWidth(), getColorsHeight()); drawRect(renderX, renderY, renderX + getWidth(), renderY + getColorsHeight(), (tone << 24) | 0xFFFFFF); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.disableAlpha(); GlStateManager.shadeModel(GL11.GL_SMOOTH); GL11.glBegin(GL11.GL_QUADS); GlStateManager.color(0, 0, 0, 1.0f); GL11.glVertex3d(renderX, renderY + getColorsHeight(), 0.0); GL11.glVertex3d(renderX + getWidth(), renderY + getColorsHeight(), 0.0); GlStateManager.color(0, 0, 0, 0f); GL11.glVertex3d(renderX + getWidth(), renderY, 0.0D); GL11.glVertex3d(renderX, renderY, 0.0); GL11.glEnd(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); GlStateManager.enableAlpha(); drawRect(renderX + pointX - 1, renderY + pointY - 1, renderX + pointX + 1, renderY + pointY + 1, 0xCCCC0000); }
Example 7
Source File: Point.java From OpenPeripheral-Addons with MIT License | 5 votes |
@Override protected void drawContents(RenderState renderState, float partialTicks) { renderState.setColor(color, opacity); renderState.setupSolidRender(); renderState.setPointSize(size); GL11.glBegin(GL11.GL_POINTS); GL11.glVertex2i(0, 0); GL11.glEnd(); }
Example 8
Source File: FeatureButton.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private void drawSettingsBackground(int x2, int x3, int y1, int y2, boolean hSettings) { float[] bgColor = GUI.getBgColor(); float opacity = GUI.getOpacity(); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], hSettings ? opacity * 1.5F : opacity); GL11.glVertex2i(x3, y1); GL11.glVertex2i(x3, y2); GL11.glVertex2i(x2, y2); GL11.glVertex2i(x2, y1); GL11.glEnd(); }
Example 9
Source File: MobSpawnEspHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private void compileDisplayList() { GL11.glNewList(displayList, GL11.GL_COMPILE); try { GL11.glColor4f(1, 0, 0, 0.5F); GL11.glBegin(GL11.GL_LINES); new ArrayList<>(red).forEach(pos -> { GL11.glVertex3d(pos.getX(), pos.getY() + 0.01, pos.getZ()); GL11.glVertex3d(pos.getX() + 1, pos.getY() + 0.01, pos.getZ() + 1); GL11.glVertex3d(pos.getX() + 1, pos.getY() + 0.01, pos.getZ()); GL11.glVertex3d(pos.getX(), pos.getY() + 0.01, pos.getZ() + 1); }); GL11.glColor4f(1, 1, 0, 0.5F); new ArrayList<>(yellow).forEach(pos -> { GL11.glVertex3d(pos.getX(), pos.getY() + 0.01, pos.getZ()); GL11.glVertex3d(pos.getX() + 1, pos.getY() + 0.01, pos.getZ() + 1); GL11.glVertex3d(pos.getX() + 1, pos.getY() + 0.01, pos.getZ()); GL11.glVertex3d(pos.getX(), pos.getY() + 0.01, pos.getZ() + 1); }); GL11.glEnd(); }finally { GL11.glEndList(); } doneCompiling = true; }
Example 10
Source File: Gui.java From Slyther with MIT License | 5 votes |
public void drawLine(float x1, float y1, float x2, float y2, float width, int color) { GL11.glPushMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4f((color >> 16 & 0xFF) / 255.0F, (color >> 8 & 0xFF) / 255.0F, (color & 0xFF) / 255.0F, 1.0F); GL11.glLineWidth(width * renderResolution.getScale()); GL11.glBegin(GL11.GL_LINES); GL11.glVertex2f(x1, y1); GL11.glVertex2f(x2, y2); GL11.glEnd(); GL11.glPopMatrix(); }
Example 11
Source File: ChestEspHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@Override protected void onEnable() { MinecraftForge.EVENT_BUS.register(this); AxisAlignedBB bb = new AxisAlignedBB(BlockPos.ORIGIN); greenBox = GL11.glGenLists(1); GL11.glNewList(greenBox, GL11.GL_COMPILE); GL11.glColor4f(0, 1, 0, 0.25F); GL11.glBegin(GL11.GL_QUADS); RenderUtils.drawSolidBox(bb); GL11.glEnd(); GL11.glColor4f(0, 1, 0, 0.5F); GL11.glBegin(GL11.GL_LINES); RenderUtils.drawOutlinedBox(bb); GL11.glEnd(); GL11.glEndList(); orangeBox = GL11.glGenLists(1); GL11.glNewList(orangeBox, GL11.GL_COMPILE); GL11.glColor4f(1, 0.5F, 0, 0.25F); GL11.glBegin(GL11.GL_QUADS); RenderUtils.drawSolidBox(bb); GL11.glEnd(); GL11.glColor4f(1, 0.5F, 0, 0.5F); GL11.glBegin(GL11.GL_LINES); RenderUtils.drawOutlinedBox(bb); GL11.glEnd(); GL11.glEndList(); cyanBox = GL11.glGenLists(1); GL11.glNewList(cyanBox, GL11.GL_COMPILE); GL11.glColor4f(0, 1, 1, 0.25F); GL11.glBegin(GL11.GL_QUADS); RenderUtils.drawSolidBox(bb); GL11.glEnd(); GL11.glColor4f(0, 1, 1, 0.5F); GL11.glBegin(GL11.GL_LINES); RenderUtils.drawOutlinedBox(bb); GL11.glEnd(); GL11.glEndList(); normalChests = GL11.glGenLists(1); }
Example 12
Source File: CurveRenderState.java From opsu-dance with GNU General Public License v3.0 | 4 votes |
/** * Draw a curve to the screen that's tinted with `color`. The first time * this is called this caches the image result of the curve and on subsequent * runs it just draws the cached copy to the screen. * @param color tint of the curve * @param borderColor the curve border color * @param from index to draw from * @param to index to draw to (exclusive) */ public void draw(Color color, Color borderColor, int from, int to) { float alpha = color.a; if (fbo == null) { // this should not be null, but issue #106 claims it is possible, at least 3 people had this... // debugging shows that the draw was called after discardGeometry was, which does not really make sense initFBO(); } if (lastPointDrawn != to || firstPointDrawn != from) { int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); //glGetInteger requires a buffer of size 16, even though just 4 //values are returned in this specific case IntBuffer oldViewport = BufferUtils.createIntBuffer(16); GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID()); GL11.glViewport(0, 0, fbo.width, fbo.height); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); this.renderCurve(color, borderColor, from, to, firstPointDrawn != from); lastPointDrawn = to; firstPointDrawn = from; color.a = 1f; GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb); GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3)); } // draw a fullscreen quad with the texture that contains the curve GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i(fbo.width, 0); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(0, fbo.height); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(fbo.width, fbo.height); GL11.glEnd(); }
Example 13
Source File: TabGui.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private void drawBox(int x1, int y1, int x2, int y2) { ClickGui gui = WurstClient.INSTANCE.getGui(); float[] bgColor = gui.getBgColor(); float[] acColor = gui.getAcColor(); float opacity = gui.getOpacity(); // color GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity); // box GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2i(x1, y1); GL11.glVertex2i(x2, y1); GL11.glVertex2i(x2, y2); GL11.glVertex2i(x1, y2); } GL11.glEnd(); // outline positions double xi1 = x1 - 0.1; double xi2 = x2 + 0.1; double yi1 = y1 - 0.1; double yi2 = y2 + 0.1; // outline GL11.glLineWidth(1); GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F); GL11.glBegin(GL11.GL_LINE_LOOP); { GL11.glVertex2d(xi1, yi1); GL11.glVertex2d(xi2, yi1); GL11.glVertex2d(xi2, yi2); GL11.glVertex2d(xi1, yi2); } GL11.glEnd(); // shadow positions xi1 -= 0.9; xi2 += 0.9; yi1 -= 0.9; yi2 += 0.9; // top left GL11.glBegin(GL11.GL_POLYGON); { GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.75F); GL11.glVertex2d(x1, y1); GL11.glVertex2d(x2, y1); GL11.glColor4f(0, 0, 0, 0); GL11.glVertex2d(xi2, yi1); GL11.glVertex2d(xi1, yi1); GL11.glVertex2d(xi1, yi2); GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.75F); GL11.glVertex2d(x1, y2); } GL11.glEnd(); // bottom right GL11.glBegin(GL11.GL_POLYGON); { GL11.glVertex2d(x2, y2); GL11.glVertex2d(x2, y1); GL11.glColor4f(0, 0, 0, 0); GL11.glVertex2d(xi2, yi1); GL11.glVertex2d(xi2, yi2); GL11.glVertex2d(xi1, yi2); GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.75F); GL11.glVertex2d(x1, y2); } GL11.glEnd(); }
Example 14
Source File: TunnellerHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); for(int displayList : displayLists) GL11.glCallList(displayList); if(currentBlock != null) { float p = prevProgress + (progress - prevProgress) * event.getPartialTicks(); float red = p * 2F; float green = 2 - red; GL11.glTranslated(currentBlock.getX(), currentBlock.getY(), currentBlock.getZ()); if(p < 1) { GL11.glTranslated(0.5, 0.5, 0.5); GL11.glScaled(p, p, p); GL11.glTranslated(-0.5, -0.5, -0.5); } AxisAlignedBB box2 = new AxisAlignedBB(BlockPos.ORIGIN); GL11.glColor4f(red, green, 0, 0.25F); GL11.glBegin(GL11.GL_QUADS); RenderUtils.drawSolidBox(box2); GL11.glEnd(); GL11.glColor4f(red, green, 0, 0.5F); GL11.glBegin(GL11.GL_LINES); RenderUtils.drawOutlinedBox(box2); GL11.glEnd(); } GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 15
Source File: RenderUtils.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
public static void drawArrow(Vec3d from, Vec3d to) { double startX = WVec3d.getX(from); double startY = WVec3d.getY(from); double startZ = WVec3d.getZ(from); double endX = WVec3d.getX(to); double endY = WVec3d.getY(to); double endZ = WVec3d.getZ(to); GL11.glPushMatrix(); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(startX, startY, startZ); GL11.glVertex3d(endX, endY, endZ); GL11.glEnd(); GL11.glTranslated(endX, endY, endZ); GL11.glScaled(0.1, 0.1, 0.1); double angleX = Math.atan2(endY - startY, startZ - endZ); GL11.glRotated(Math.toDegrees(angleX) + 90, 1, 0, 0); double angleZ = Math.atan2(endX - startX, Math.sqrt(Math.pow(endY - startY, 2) + Math.pow(endZ - startZ, 2))); GL11.glRotated(Math.toDegrees(angleZ), 0, 0, 1); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(0, 2, 1); GL11.glVertex3d(-1, 2, 0); GL11.glVertex3d(-1, 2, 0); GL11.glVertex3d(0, 2, -1); GL11.glVertex3d(0, 2, -1); GL11.glVertex3d(1, 2, 0); GL11.glVertex3d(1, 2, 0); GL11.glVertex3d(0, 2, 1); GL11.glVertex3d(1, 2, 0); GL11.glVertex3d(-1, 2, 0); GL11.glVertex3d(0, 2, 1); GL11.glVertex3d(0, 2, -1); GL11.glVertex3d(0, 0, 0); GL11.glVertex3d(1, 2, 0); GL11.glVertex3d(0, 0, 0); GL11.glVertex3d(-1, 2, 0); GL11.glVertex3d(0, 0, 0); GL11.glVertex3d(0, 2, -1); GL11.glVertex3d(0, 0, 0); GL11.glVertex3d(0, 2, 1); GL11.glEnd(); GL11.glPopMatrix(); }
Example 16
Source File: Model.java From pycode-minecraft with MIT License | 4 votes |
public void genList() { this.glList = GL11.glGenLists(1); GL11.glNewList(this.glList, GL11.GL_COMPILE); // if use_texture: glEnable(GL_TEXTURE_2D) GL11.glFrontFace(GL11.GL_CCW); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glDepthFunc(GL11.GL_LESS); GL11.glCullFace(GL11.GL_BACK); String currentMaterial = ""; Material mtl; for (Face face : this.faces) { if (!face.material.equals(currentMaterial)) { currentMaterial = face.material; mtl = this.materials.get(face.material); if (mtl == null) { GL11.glColor3f(1, 1, 1); } else { // if 'texture_Kd' in mtl: // # use diffuse texmap // glBindTexture(GL_TEXTURE_2D, mtl['texture_Kd']) GL11.glColor3f(mtl.diffuse.x, mtl.diffuse.y, mtl.diffuse.z); } } GL11.glBegin(GL11.GL_POLYGON); for (int i = 0; i < face.vertexes.size(); i++) { if (face.normals.get(i) != 0) { Vector3f n = this.normals.get(face.normals.get(i)); GL11.glNormal3f(n.x, n.y, n.z); } // if texture_coords[i]: // glTexCoord2fv(self.texcoords[texture_coords[i] - 1]) Vector3f v = this.vertices.get(face.vertexes.get(i)); GL11.glVertex3f(v.x, v.y, v.z); } GL11.glEnd(); } GL11.glCullFace(GL11.GL_BACK); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); GL11.glDisable(GL11.GL_CULL_FACE); // if use_texture: glDisable(GL11.GL_TEXTURE_2D); GL11.glEndList(); }
Example 17
Source File: AutoFarmHack.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); GL11.glCallList(displayList); if(currentBlock != null) { GL11.glPushMatrix(); AxisAlignedBB box = new AxisAlignedBB(BlockPos.ORIGIN); float p = prevProgress + (progress - prevProgress) * event.getPartialTicks(); float red = p * 2F; float green = 2 - red; GL11.glTranslated(currentBlock.getX(), currentBlock.getY(), currentBlock.getZ()); if(p < 1) { GL11.glTranslated(0.5, 0.5, 0.5); GL11.glScaled(p, p, p); GL11.glTranslated(-0.5, -0.5, -0.5); } GL11.glColor4f(red, green, 0, 0.25F); GL11.glBegin(GL11.GL_QUADS); RenderUtils.drawSolidBox(box); GL11.glEnd(); GL11.glColor4f(red, green, 0, 0.5F); GL11.glBegin(GL11.GL_LINES); RenderUtils.drawOutlinedBox(box); GL11.glEnd(); GL11.glPopMatrix(); } GL11.glPopMatrix(); // GL resets GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 18
Source File: LegacyCurveRenderState.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Draw a curve to the screen that's tinted with `color`. The first time * this is called this caches the image result of the curve and on subsequent * runs it just draws the cached copy to the screen. * @param color tint of the curve * @param borderColor the curve border color * @param from index to draw from * @param to index to draw to (exclusive) */ public void draw(Color color, Color borderColor, int from, int to) { float alpha = color.a; if (fbo == null) initFBO(); if (lastPointDrawn != to || firstPointDrawn != from) { int oldFb = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int oldTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); //glGetInteger requires a buffer of size 16, even though just 4 //values are returned in this specific case IntBuffer oldViewport = BufferUtils.createIntBuffer(16); GL11.glGetInteger(GL11.GL_VIEWPORT, oldViewport); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.getID()); GL11.glViewport(0, 0, fbo.width, fbo.height); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); this.renderCurve(color, borderColor, from, to, firstPointDrawn != from); lastPointDrawn = to; firstPointDrawn = from; color.a = 1f; GL11.glBindTexture(GL11.GL_TEXTURE_2D, oldTex); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, oldFb); GL11.glViewport(oldViewport.get(0), oldViewport.get(1), oldViewport.get(2), oldViewport.get(3)); } // draw a fullscreen quad with the texture that contains the curve GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_1D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i(fbo.width, 0); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(0, fbo.height); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(fbo.width, fbo.height); GL11.glEnd(); }
Example 19
Source File: BlockComponent.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
@Override public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { ClickGui gui = WurstClient.INSTANCE.getGui(); float[] bgColor = gui.getBgColor(); float opacity = gui.getOpacity(); int x1 = getX(); int x2 = x1 + getWidth(); int x3 = x2 - BLOCK_WITDH; int y1 = getY(); int y2 = y1 + getHeight(); int scroll = getParent().isScrollingEnabled() ? getParent().getScrollOffset() : 0; boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2 && mouseY < y2 && mouseY >= -scroll && mouseY < getParent().getHeight() - 13 - scroll; boolean hText = hovering && mouseX < x3; boolean hBlock = hovering && mouseX >= x3; ItemStack stack = new ItemStack(setting.getBlock()); // tooltip if(hText) gui.setTooltip(setting.getDescription()); else if(hBlock) { String tooltip = "\u00a76Name:\u00a7r " + getBlockName(stack); tooltip += "\n\u00a76ID:\u00a7r " + setting.getBlockName(); tooltip += "\n\n\u00a7e[left-click]\u00a7r to edit"; tooltip += "\n\u00a7e[right-click]\u00a7r to reset"; gui.setTooltip(tooltip); } // background GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2i(x1, y1); GL11.glVertex2i(x1, y2); GL11.glVertex2i(x2, y2); GL11.glVertex2i(x2, y1); GL11.glEnd(); // setting name GL11.glColor4f(1, 1, 1, 1); GL11.glEnable(GL11.GL_TEXTURE_2D); TextRenderer fr = WurstClient.MC.textRenderer; String text = setting.getName() + ":"; fr.draw(matrixStack, text, x1, y1 + 2, 0xf0f0f0); renderIcon(matrixStack, stack, x3, y1, true); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); }
Example 20
Source File: AltManagerScreen.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
@Override public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { renderBackground(matrixStack); listGui.render(matrixStack, mouseX, mouseY, partialTicks); // skin preview if(listGui.getSelectedSlot() != -1 && listGui.getSelectedSlot() < altManager.getList().size()) { Alt alt = listGui.getSelectedAlt(); AltRenderer.drawAltBack(matrixStack, alt.getNameOrEmail(), (width / 2 - 125) / 2 - 32, height / 2 - 64 - 9, 64, 128); AltRenderer.drawAltBody(matrixStack, alt.getNameOrEmail(), width - (width / 2 - 140) / 2 - 32, height / 2 - 64 - 9, 64, 128); } // title text drawCenteredString(matrixStack, textRenderer, "Alt Manager", width / 2, 4, 16777215); drawCenteredString(matrixStack, textRenderer, "Alts: " + altManager.getList().size(), width / 2, 14, 10526880); drawCenteredString( matrixStack, textRenderer, "premium: " + altManager.getNumPremium() + ", cracked: " + altManager.getNumCracked(), width / 2, 24, 10526880); // red flash for errors if(errorTimer > 0) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_BLEND); GL11.glColor4f(1, 0, 0, errorTimer / 16F); GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2d(0, 0); GL11.glVertex2d(width, 0); GL11.glVertex2d(width, height); GL11.glVertex2d(0, height); } GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); errorTimer--; } super.render(matrixStack, mouseX, mouseY, partialTicks); }