List of usage examples for org.lwjgl.opengl GL11 glShadeModel
public static native void glShadeModel(@NativeType("GLenum") int mode);
From source file:com.kodehawa.gui.api.render.ModGuiUtils.java
License:Open Source License
public static void drawGradientRect(double x, double y, double x2, double y2, int col1, int col2) { float f = ((col1 >> 24) & 0xFF) / 255F; float f1 = ((col1 >> 16) & 0xFF) / 255F; float f2 = ((col1 >> 8) & 0xFF) / 255F; float f3 = (col1 & 0xFF) / 255F; float f4 = ((col2 >> 24) & 0xFF) / 255F; float f5 = ((col2 >> 16) & 0xFF) / 255F; float f6 = ((col2 >> 8) & 0xFF) / 255F; float f7 = (col2 & 0xFF) / 255F; GL11.glEnable(GL11.GL_BLEND);/*from w w w . java 2 s.c om*/ GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glPushMatrix(); GL11.glBegin(GL11.GL_QUADS); GL11.glColor4f(f1, f2, f3, f); GL11.glVertex2d(x2, y); GL11.glVertex2d(x, y); GL11.glColor4f(f5, f6, f7, f4); GL11.glVertex2d(x, y2); GL11.glVertex2d(x2, y2); GL11.glEnd(); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glShadeModel(GL11.GL_FLAT); }
From source file:com.Magic.MagicMod.gui.utils.ScrollingBase.java
License:Open Source License
public void drawScreen(int mouseX, int mouseY, float p_22243_3_) { this.mouseX = mouseX; this.mouseY = mouseY; this.drawBackground(); int listLength = this.getSize(); int scrollBarXStart = this.left + this.listWidth - 6; int scrollBarXEnd = scrollBarXStart + 6; int boxLeft = this.left; int boxRight = scrollBarXStart - 1; int var10; int var11; int var13; int var19; if (Mouse.isButtonDown(0)) { if (this.initialMouseClickY == -1.0F) { boolean var7 = true; if (mouseY >= this.top && mouseY <= this.bottom) { var10 = mouseY - this.top - this.field_27261_r + (int) this.scrollDistance - 4; var11 = var10 / this.slotHeight; if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength) { boolean var12 = var11 == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L; this.elementClicked(var11, var12); this.selectedIndex = var11; this.lastClickTime = System.currentTimeMillis(); } else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0) { this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int) this.scrollDistance - 4); var7 = false; }/*w w w .j a v a 2 s. c om*/ if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd) { this.scrollFactor = -1.0F; var19 = this.getContentHeight() - (this.bottom - this.top - 4); if (var19 < 1) { var19 = 1; } var13 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top)) / (float) this.getContentHeight()); if (var13 < 32) { var13 = 32; } if (var13 > this.bottom - this.top - 8) { var13 = this.bottom - this.top - 8; } this.scrollFactor /= (float) (this.bottom - this.top - var13) / (float) var19; } else { this.scrollFactor = 1.0F; } if (var7) { this.initialMouseClickY = (float) mouseY; } else { this.initialMouseClickY = -2.0F; } } else { this.initialMouseClickY = -2.0F; } } else if (this.initialMouseClickY >= 0.0F) { this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor; this.initialMouseClickY = (float) mouseY; } } else { while (Mouse.next()) { int var16 = Mouse.getEventDWheel(); if (var16 != 0) { if (var16 > 0) { var16 = -1; } else if (var16 < 0) { var16 = 1; } this.scrollDistance += (float) (var16 * this.slotHeight / 2); } } this.initialMouseClickY = -1.0F; } this.applyScrollLimits(); Tessellator var18 = Tessellator.instance; //if (this.client.theWorld != null) { //this.drawGradientRect(this.left, this.top, this.right, this.bottom, -1072689136, -804253680); } //else { // System.out.print("10000"); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); this.client.renderEngine.bindTexture(Gui.optionsBackground); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float var17 = 32.0F; var18.startDrawingQuads(); var18.setColorOpaque_I(2105376); var18.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D, (double) ((float) this.left / var17), (double) ((float) (this.bottom + (int) this.scrollDistance) / var17)); var18.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D, (double) ((float) this.right / var17), (double) ((float) (this.bottom + (int) this.scrollDistance) / var17)); var18.addVertexWithUV((double) this.right, (double) this.top, 0.0D, (double) ((float) this.right / var17), (double) ((float) (this.top + (int) this.scrollDistance) / var17)); var18.addVertexWithUV((double) this.left, (double) this.top, 0.0D, (double) ((float) this.left / var17), (double) ((float) (this.top + (int) this.scrollDistance) / var17)); var18.draw(); } // boxRight = this.listWidth / 2 - 92 - 16; var10 = this.top + 4 - (int) this.scrollDistance; if (this.field_27262_q) { this.func_27260_a(boxRight, var10, var18); } int var14; for (var11 = 0; var11 < listLength; ++var11) { var19 = var10 + var11 * this.slotHeight + this.field_27261_r; var13 = this.slotHeight - 4; //System.out.print(" var19 "+var19+" \n var13 "+var13+" \n bottom "+this.bottom+" \n top "+this.top); if (var19 <= this.bottom && var19 + var13 >= this.top) { if (this.field_25123_p && this.isSelected(var11)) { var14 = boxLeft; int var15 = boxRight; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); var18.startDrawingQuads(); var18.setColorOpaque_I(8421504); var18.addVertexWithUV((double) var14, (double) (var19 + var13 + 2), 0.0D, 0.0D, 1.0D); var18.addVertexWithUV((double) var15, (double) (var19 + var13 + 2), 0.0D, 1.0D, 1.0D); var18.addVertexWithUV((double) var15, (double) (var19 - 2), 0.0D, 1.0D, 0.0D); var18.addVertexWithUV((double) var14, (double) (var19 - 2), 0.0D, 0.0D, 0.0D); var18.setColorOpaque_I(0); var18.addVertexWithUV((double) (var14 + 1), (double) (var19 + var13 + 1), 0.0D, 0.0D, 1.0D); var18.addVertexWithUV((double) (var15 - 1), (double) (var19 + var13 + 1), 0.0D, 1.0D, 1.0D); var18.addVertexWithUV((double) (var15 - 1), (double) (var19 - 1), 0.0D, 1.0D, 0.0D); var18.addVertexWithUV((double) (var14 + 1), (double) (var19 - 1), 0.0D, 0.0D, 0.0D); var18.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } //System.out.print("var19 "+var19+" /n var13 "+var13+" 1 "); this.drawSlot(var11, boxRight, var19, var13, var18); } } GL11.glDisable(GL11.GL_DEPTH_TEST); byte var20 = 4; if (this.client.theWorld == null) { this.overlayBackground(0, this.top, 255, 255); this.overlayBackground(this.bottom, this.listHeight, 255, 255); } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_TEXTURE_2D); var18.startDrawingQuads(); var18.setColorRGBA_I(0, 0); var18.addVertexWithUV((double) this.left, (double) (this.top + var20), 0.0D, 0.0D, 1.0D); var18.addVertexWithUV((double) this.right, (double) (this.top + var20), 0.0D, 1.0D, 1.0D); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV((double) this.right, (double) this.top, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV((double) this.left, (double) this.top, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D, 1.0D, 1.0D); var18.setColorRGBA_I(0, 0); var18.addVertexWithUV((double) this.right, (double) (this.bottom - var20), 0.0D, 1.0D, 0.0D); var18.addVertexWithUV((double) this.left, (double) (this.bottom - var20), 0.0D, 0.0D, 0.0D); var18.draw(); var19 = this.getContentHeight() - (this.bottom - this.top - 4); if (var19 > 0) { var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); if (var13 < 32) { var13 = 32; } if (var13 > this.bottom - this.top - 8) { var13 = this.bottom - this.top - 8; } var14 = (int) this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top; if (var14 < this.top) { var14 = this.top; } var18.startDrawingQuads(); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV((double) scrollBarXStart, (double) this.bottom, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV((double) scrollBarXEnd, (double) this.bottom, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV((double) scrollBarXEnd, (double) this.top, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV((double) scrollBarXStart, (double) this.top, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(8421504, 255); var18.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13), 0.0D, 0.0D, 1.0D); var18.addVertexWithUV((double) scrollBarXEnd, (double) (var14 + var13), 0.0D, 1.0D, 1.0D); var18.addVertexWithUV((double) scrollBarXEnd, (double) var14, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(12632256, 255); var18.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13 - 1), 0.0D, 0.0D, 1.0D); var18.addVertexWithUV((double) (scrollBarXEnd - 1), (double) (var14 + var13 - 1), 0.0D, 1.0D, 1.0D); var18.addVertexWithUV((double) (scrollBarXEnd - 1), (double) var14, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D); var18.draw(); } this.func_27257_b(mouseX, mouseY); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); }
From source file:com.Magic.MagicMod.gui.utils.ScrollingBase.java
License:Open Source License
protected void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) { float f = (float) (par5 >> 24 & 255) / 255.0F; float f1 = (float) (par5 >> 16 & 255) / 255.0F; float f2 = (float) (par5 >> 8 & 255) / 255.0F; float f3 = (float) (par5 & 255) / 255.0F; float f4 = (float) (par6 >> 24 & 255) / 255.0F; float f5 = (float) (par6 >> 16 & 255) / 255.0F; float f6 = (float) (par6 >> 8 & 255) / 255.0F; float f7 = (float) (par6 & 255) / 255.0F; GL11.glDisable(GL11.GL_TEXTURE_2D);/* www . ja v a 2 s . com*/ GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glShadeModel(GL11.GL_SMOOTH); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(f1, f2, f3, f); tessellator.addVertex((double) par3, (double) par2, 0.0D); tessellator.addVertex((double) par1, (double) par2, 0.0D); tessellator.setColorRGBA_F(f5, f6, f7, f4); tessellator.addVertex((double) par1, (double) par4, 0.0D); tessellator.addVertex((double) par3, (double) par4, 0.0D); tessellator.draw(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:com.mtbs3d.minecrift.VRRenderer.java
License:LGPL
public void renderWorld(float renderPartialTicks, long nextFrameTime, int renderSceneNumber) { RenderGlobal renderGlobal = this.mc.renderGlobal; EffectRenderer effectRenderer = this.mc.effectRenderer; EntityLivingBase renderViewEntity = this.mc.renderViewEntity; //TODO: fog color isn't quite right yet when eyes split water/air this.updateFogColor(renderPartialTicks); GL11.glClearColor(fogColorRed, fogColorGreen, fogColorBlue, 0.5f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glEnable(GL11.GL_CULL_FACE);// ww w. ja v a 2s . c o m GL11.glEnable(GL11.GL_DEPTH_TEST); //mc.checkGLError("FBO init"); this.mc.mcProfiler.startSection("lightTex"); if (this.lightmapUpdateNeeded) { this.updateLightmap(renderPartialTicks); } ActiveRenderInfo.updateRenderInfo(this.mc.thePlayer, this.mc.gameSettings.thirdPersonView == 2); this.mc.mcProfiler.endStartSection("frustrum"); ClippingHelperImpl.getInstance(); // setup clip, using current modelview / projection matrices if (!Config.isSkyEnabled() && !Config.isSunMoonEnabled() && !Config.isStarsEnabled()) { GL11.glDisable(GL11.GL_BLEND); } else { this.setupFog(-1, renderPartialTicks); this.mc.mcProfiler.endStartSection("sky"); renderGlobal.renderSky(renderPartialTicks); } GL11.glEnable(GL11.GL_FOG); this.setupFog(1, renderPartialTicks); if (this.mc.gameSettings.ambientOcclusion != 0) { GL11.glShadeModel(GL11.GL_SMOOTH); } this.mc.mcProfiler.endStartSection("culling"); Frustrum frustrum = new Frustrum(); frustrum.setPosition(renderOriginX, renderOriginY, renderOriginZ); this.mc.renderGlobal.clipRenderersByFrustum(frustrum, renderPartialTicks); if (renderSceneNumber == 0) { this.mc.mcProfiler.endStartSection("updatechunks"); while (!this.mc.renderGlobal.updateRenderers(renderViewEntity, false) && nextFrameTime != 0L) { long var15 = nextFrameTime - System.nanoTime(); if (var15 < 0L || var15 > 1000000000L) { break; } } } if (renderViewEntity.posY < 128.0D) { this.renderCloudsCheck(renderGlobal, renderPartialTicks); } this.mc.mcProfiler.endStartSection("prepareterrain"); this.setupFog(0, renderPartialTicks); GL11.glEnable(GL11.GL_FOG); this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); RenderHelper.disableStandardItemLighting(); this.mc.mcProfiler.endStartSection("terrain"); renderGlobal.sortAndRender(renderViewEntity, 0, (double) renderPartialTicks); GL11.glShadeModel(GL11.GL_FLAT); boolean var16 = Reflector.ForgeHooksClient.exists(); EntityPlayer var18; if (this.debugViewDirection == 0) { RenderHelper.enableStandardItemLighting(); this.mc.mcProfiler.endStartSection("entities"); if (var16) { Reflector.callVoid(Reflector.ForgeHooksClient_setRenderPass, new Object[] { Integer.valueOf(0) }); } //TODO: multiple render passes for entities? renderGlobal.renderEntities(renderViewEntity.getPosition(renderPartialTicks), frustrum, renderPartialTicks); if (var16) { Reflector.callVoid(Reflector.ForgeHooksClient_setRenderPass, new Object[] { Integer.valueOf(-1) }); } RenderHelper.disableStandardItemLighting(); } GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthMask(true); this.setupFog(0, renderPartialTicks); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_CULL_FACE); this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); WrUpdates.resumeBackgroundUpdates(); if (Config.isWaterFancy()) { this.mc.mcProfiler.endStartSection("water"); if (this.mc.gameSettings.ambientOcclusion != 0) { GL11.glShadeModel(GL11.GL_SMOOTH); } GL11.glColorMask(false, false, false, false); int var17 = renderGlobal.renderAllSortedRenderers(1, (double) renderPartialTicks); if (this.mc.gameSettings.anaglyph) { if (anaglyphField == 0) { GL11.glColorMask(false, true, true, true); } else { GL11.glColorMask(true, false, false, true); } } else { GL11.glColorMask(true, true, true, true); } if (var17 > 0) { renderGlobal.renderAllSortedRenderers(1, (double) renderPartialTicks); } GL11.glShadeModel(GL11.GL_FLAT); } else { this.mc.mcProfiler.endStartSection("water"); renderGlobal.renderAllSortedRenderers(1, (double) renderPartialTicks); } WrUpdates.pauseBackgroundUpdates(); if (var16 && this.debugViewDirection == 0) { RenderHelper.enableStandardItemLighting(); this.mc.mcProfiler.endStartSection("entities"); Reflector.callVoid(Reflector.ForgeHooksClient_setRenderPass, new Object[] { Integer.valueOf(1) }); this.mc.renderGlobal.renderEntities(renderViewEntity.getPosition(renderPartialTicks), frustrum, renderPartialTicks); Reflector.callVoid(Reflector.ForgeHooksClient_setRenderPass, new Object[] { Integer.valueOf(-1) }); RenderHelper.disableStandardItemLighting(); } GL11.glDepthMask(true); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); boolean renderOutline = this.mc.vrSettings.alwaysRenderBlockOutline || !this.mc.gameSettings.hideGUI; if (this.mc.currentScreen == null && this.cameraZoom == 1.0D && renderViewEntity instanceof EntityPlayer && this.mc.objectMouseOver != null && !renderViewEntity.isInsideOfMaterial(Material.water) && renderOutline) { var18 = (EntityPlayer) renderViewEntity; GL11.glDisable(GL11.GL_ALPHA_TEST); this.mc.mcProfiler.endStartSection("outline"); if (!var16 || !Reflector.callBoolean(Reflector.ForgeHooksClient_onDrawBlockHighlight, new Object[] { renderGlobal, var18, this.mc.objectMouseOver, Integer.valueOf(0), var18.inventory.getCurrentItem(), Float.valueOf(renderPartialTicks) })) { renderGlobal.drawSelectionBox(var18, this.mc.objectMouseOver, 0, renderPartialTicks); } GL11.glEnable(GL11.GL_ALPHA_TEST); } if (this.mc.currentScreen == null && this.cameraZoom == 1.0D && renderViewEntity instanceof EntityPlayer && !renderViewEntity.isInsideOfMaterial(Material.water) && renderOutline && this.mc.vrSettings.showEntityOutline) { var18 = (EntityPlayer) renderViewEntity; if (var18 != null) { GL11.glDisable(GL11.GL_ALPHA_TEST); this.mc.mcProfiler.endStartSection("entityOutline"); if (this.bb != null) drawBoundingBox(var18, this.bb, renderPartialTicks); GL11.glEnable(GL11.GL_ALPHA_TEST); } } this.mc.mcProfiler.endStartSection("destroyProgress"); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); renderGlobal.drawBlockDamageTexture(Tessellator.instance, renderViewEntity, renderPartialTicks); GL11.glDisable(GL11.GL_BLEND); this.mc.mcProfiler.endStartSection("weather"); this.renderRainSnow(renderPartialTicks); GL11.glDisable(GL11.GL_FOG); if (renderViewEntity.posY >= 128.0D) { this.renderCloudsCheck(renderGlobal, renderPartialTicks); } this.enableLightmap((double) renderPartialTicks); this.mc.mcProfiler.endStartSection("litParticles"); RenderHelper.enableStandardItemLighting(); effectRenderer.renderLitParticles(renderViewEntity, renderPartialTicks); RenderHelper.disableStandardItemLighting(); this.setupFog(0, renderPartialTicks); this.mc.mcProfiler.endStartSection("particles"); effectRenderer.renderParticles(renderViewEntity, renderPartialTicks); this.disableLightmap((double) renderPartialTicks); if (var16) { this.mc.mcProfiler.endStartSection("FRenderLast"); Reflector.callVoid(Reflector.ForgeHooksClient_dispatchRenderLast, new Object[] { renderGlobal, Float.valueOf(renderPartialTicks) }); } if (this.mc.vrSettings.renderFullFirstPersonModel == false) { GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); this.renderHand(renderPartialTicks, renderSceneNumber); } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); //white crosshair, with blending //Draw crosshair boolean renderCrosshair = this.mc.vrSettings.alwaysRenderInGameCrosshair || !this.mc.gameSettings.hideGUI; if (this.mc.currentScreen == null && this.mc.gameSettings.thirdPersonView == 0 && renderCrosshair) { this.mc.mcProfiler.endStartSection("crosshair"); float crossDepth = (float) Math.sqrt((crossX * crossX + crossY * crossY + crossZ * crossZ)); float scale = 0.025f * crossDepth * this.mc.vrSettings.crosshairScale; GL11.glPushMatrix(); GL11.glTranslatef(crossX, crossY, crossZ); GL11.glRotatef(-this.aimYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.aimPitch, 1.0F, 0.0F, 0.0F); if (this.mc.vrSettings.crosshairRollsWithHead) GL11.glRotatef(this.cameraRoll, 0.0F, 0.0F, 1.0F); GL11.glScalef(-scale, -scale, scale); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR); this.mc.getTextureManager().bindTexture(Gui.icons); float var7 = 0.00390625F; float var8 = 0.00390625F; Tessellator.instance.startDrawingQuads(); Tessellator.instance.addVertexWithUV(-1, +1, 0, 0, 16 * var8); Tessellator.instance.addVertexWithUV(+1, +1, 0, 16 * var7, 16 * var8); Tessellator.instance.addVertexWithUV(+1, -1, 0, 16 * var7, 0); Tessellator.instance.addVertexWithUV(-1, -1, 0, 0, 0); Tessellator.instance.draw(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glPopMatrix(); //mc.checkGLError("crosshair"); } this.mc.mcProfiler.endSection(); }
From source file:com.oneofthesevenbillion.ziah.ZiahsClient.gui.GuiScrollingList.java
License:Open Source License
public void drawScreen(int mouseX, int mouseY, float tick) { this.mouseX = mouseX; this.mouseY = mouseY; this.drawBackground(); int listLength = this.getSize(); int scrollBarXStart = this.left + this.listWidth - 6; int scrollBarXEnd = scrollBarXStart + 6; int boxLeft = this.left; int boxRight = scrollBarXStart - 1; int var10; int var11; int var13; int var19; if (Mouse.isButtonDown(0)) { if (this.initialMouseClickY == -1.0F) { boolean var7 = true; if (mouseY >= this.top && mouseY <= this.bottom) { var10 = mouseY - this.top - this.field_27261_r + (int) this.scrollDistance - 4; var11 = var10 / this.slotHeight; if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength) { boolean var12 = var11 == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L; this.elementClicked(var11, var12); this.selectedIndex = var11; this.lastClickTime = System.currentTimeMillis(); } else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0) { this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int) this.scrollDistance - 4); var7 = false; }/*from ww w. ja v a 2 s . co m*/ if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd) { this.scrollFactor = -1.0F; var19 = this.getContentHeight() - (this.bottom - this.top - 4); if (var19 < 1) { var19 = 1; } var13 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top)) / (float) this.getContentHeight()); if (var13 < 32) { var13 = 32; } if (var13 > this.bottom - this.top - 8) { var13 = this.bottom - this.top - 8; } this.scrollFactor /= (float) (this.bottom - this.top - var13) / (float) var19; } else { this.scrollFactor = 1.0F; } if (var7) { this.initialMouseClickY = mouseY; } else { this.initialMouseClickY = -2.0F; } } else { this.initialMouseClickY = -2.0F; } } else if (this.initialMouseClickY >= 0.0F) { this.scrollDistance -= (mouseY - this.initialMouseClickY) * this.scrollFactor; this.initialMouseClickY = mouseY; } } else { while (Mouse.next()) { int var16 = Mouse.getEventDWheel(); if (var16 != 0) { if (var16 > 0) { var16 = -1; } else if (var16 < 0) { var16 = 1; } this.scrollDistance += var16 * this.slotHeight / 2; } } this.initialMouseClickY = -1.0F; } this.applyScrollLimits(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_FOG); Tessellator var18 = Tessellator.instance; try { ((TextureManager) ModLoader.getPrivateValue(Minecraft.class, this.client, 7)) .func_110577_a(Gui.field_110325_k); } catch (Exception e) { e.printStackTrace(); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float var17 = 32.0F; var18.startDrawingQuads(); var18.setColorOpaque_I(2105376); var18.addVertexWithUV(this.left, this.bottom, 0.0D, this.left / var17, (this.bottom + (int) this.scrollDistance) / var17); var18.addVertexWithUV(this.right, this.bottom, 0.0D, this.right / var17, (this.bottom + (int) this.scrollDistance) / var17); var18.addVertexWithUV(this.right, this.top, 0.0D, this.right / var17, (this.top + (int) this.scrollDistance) / var17); var18.addVertexWithUV(this.left, this.top, 0.0D, this.left / var17, (this.top + (int) this.scrollDistance) / var17); var18.draw(); // boxRight = this.listWidth / 2 - 92 - 16; var10 = this.top + 4 - (int) this.scrollDistance; if (this.field_27262_q) { this.func_27260_a(boxRight, var10, var18); } int var14; for (var11 = 0; var11 < listLength; ++var11) { var19 = var10 + var11 * this.slotHeight + this.field_27261_r; var13 = this.slotHeight - 4; if (var19 <= this.bottom && var19 + var13 >= this.top) { if (this.field_25123_p && this.isSelected(var11)) { var14 = boxLeft; int var15 = boxRight; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); var18.startDrawingQuads(); var18.setColorOpaque_I(8421504); var18.addVertexWithUV(var14, var19 + var13 + 2, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(var15, var19 + var13 + 2, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(var15, var19 - 2, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(var14, var19 - 2, 0.0D, 0.0D, 0.0D); var18.setColorOpaque_I(0); var18.addVertexWithUV(var14 + 1, var19 + var13 + 1, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(var15 - 1, var19 + var13 + 1, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(var15 - 1, var19 - 1, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(var14 + 1, var19 - 1, 0.0D, 0.0D, 0.0D); var18.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } this.drawSlot(var11, boxRight, var19, var13, var18); } } GL11.glDisable(GL11.GL_DEPTH_TEST); byte var20 = 4; this.overlayBackground(0, this.top, 255, 255); this.overlayBackground(this.bottom, this.listHeight, 255, 255); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glDisable(GL11.GL_TEXTURE_2D); var18.startDrawingQuads(); var18.setColorRGBA_I(0, 0); var18.addVertexWithUV(this.left, this.top + var20, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(this.right, this.top + var20, 0.0D, 1.0D, 1.0D); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV(this.right, this.top, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(this.left, this.top, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV(this.left, this.bottom, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(this.right, this.bottom, 0.0D, 1.0D, 1.0D); var18.setColorRGBA_I(0, 0); var18.addVertexWithUV(this.right, this.bottom - var20, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(this.left, this.bottom - var20, 0.0D, 0.0D, 0.0D); var18.draw(); var19 = this.getContentHeight() - (this.bottom - this.top - 4); if (var19 > 0) { var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); if (var13 < 32) { var13 = 32; } if (var13 > this.bottom - this.top - 8) { var13 = this.bottom - this.top - 8; } var14 = (int) this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top; if (var14 < this.top) { var14 = this.top; } var18.startDrawingQuads(); var18.setColorRGBA_I(0, 255); var18.addVertexWithUV(scrollBarXStart, this.bottom, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd, this.bottom, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd, this.top, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(scrollBarXStart, this.top, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(8421504, 255); var18.addVertexWithUV(scrollBarXStart, var14 + var13, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd, var14 + var13, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd, var14, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(scrollBarXStart, var14, 0.0D, 0.0D, 0.0D); var18.draw(); var18.startDrawingQuads(); var18.setColorRGBA_I(12632256, 255); var18.addVertexWithUV(scrollBarXStart, var14 + var13 - 1, 0.0D, 0.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd - 1, var14 + var13 - 1, 0.0D, 1.0D, 1.0D); var18.addVertexWithUV(scrollBarXEnd - 1, var14, 0.0D, 1.0D, 0.0D); var18.addVertexWithUV(scrollBarXStart, var14, 0.0D, 0.0D, 0.0D); var18.draw(); } this.func_27257_b(mouseX, mouseY); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_FLAT); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); }
From source file:com.oneofthesevenbillion.ziah.ZiahsClient.util.Utils.java
License:Open Source License
/** * Draws a rectangle with a vertical gradient between the specified colors. *///from w w w. java 2s. c o m public static void drawGradientRect(int x, int y, int x1, int y2, int color1, int color2, float zLevel) { float var7 = (color1 >> 24 & 255) / 255.0F; float var8 = (color1 >> 16 & 255) / 255.0F; float var9 = (color1 >> 8 & 255) / 255.0F; float var10 = (color1 & 255) / 255.0F; float var11 = (color2 >> 24 & 255) / 255.0F; float var12 = (color2 >> 16 & 255) / 255.0F; float var13 = (color2 >> 8 & 255) / 255.0F; float var14 = (color2 & 255) / 255.0F; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); Tessellator var15 = Tessellator.instance; var15.startDrawingQuads(); var15.setColorRGBA_F(var8, var9, var10, var7); var15.addVertex(x1, y, zLevel); var15.addVertex(x, y, zLevel); var15.setColorRGBA_F(var12, var13, var14, var11); var15.addVertex(x, y2, zLevel); var15.addVertex(x1, y2, zLevel); var15.draw(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:com.professorvennie.machinerycraft.core.helpers.RenderHelper.java
License:Creative Commons License
public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { float var7 = (par5 >> 24 & 255) / 255F; float var8 = (par5 >> 16 & 255) / 255F; float var9 = (par5 >> 8 & 255) / 255F; float var10 = (par5 & 255) / 255F; float var11 = (par6 >> 24 & 255) / 255F; float var12 = (par6 >> 16 & 255) / 255F; float var13 = (par6 >> 8 & 255) / 255F; float var14 = (par6 & 255) / 255F; GL11.glDisable(GL11.GL_TEXTURE_2D);//w w w . ja v a 2 s. c o m GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); Tessellator var15 = Tessellator.instance; var15.startDrawingQuads(); var15.setColorRGBA_F(var8, var9, var10, var7); var15.addVertex(par3, par2, z); var15.addVertex(par1, par2, z); var15.setColorRGBA_F(var12, var13, var14, var11); var15.addVertex(par1, par4, z); var15.addVertex(par3, par4, z); var15.draw(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:com.runescape.client.revised.editor.modelviewer.Main.java
License:Open Source License
public static void initialize(final Canvas modelCanvas) { try {/*from w ww . j av a 2 s . c o m*/ Display.setParent(modelCanvas); Display.create(new PixelFormat(8, 24, 8, 8)); Display.makeCurrent(); } catch (final LWJGLException lwjgle) { try { Display.create(new PixelFormat(8, 24, 8, 0)); } catch (final LWJGLException e) { e.printStackTrace(); } } Display.setVSyncEnabled(false); Display.setSwapInterval(0); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glClearDepth(1.0F); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_NORMALIZE); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_POINT_SMOOTH); GL11.glEnable(GL11.GL_POLYGON_SMOOTH); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE); GL11.glCullFace(GL11.GL_BACK); }
From source file:com.rvantwisk.cnctools.controls.opengl.BeadActor.java
License:Open Source License
@Override public void initialize() { ambient = allocFloats(colorDefaultDiffuse); diffuse = allocFloats(colorDefaultDiffuse); specular = allocFloats(colorDefaultSpecular); shininess = allocFloats(new float[] { 32.0f, 0.0f, 0.0f, 0.0f }); light = allocFloats(colorDefaultLight); lightPos0 = allocFloats(lightDefaultPos0); lightPos1 = allocFloats(lightDefaultPos1); display_list = GL11.glGenLists(1);/*from www.j a v a2 s.c o m*/ GL11.glNewList(display_list, GL11.GL_COMPILE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHT0); GL11.glEnable(GL11.GL_LIGHT1); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT, ambient); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, diffuse); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SPECULAR, specular); GL11.glMaterial(GL11.GL_FRONT, GL11.GL_SHININESS, shininess); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, light); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, lightPos0); GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, lightPos1); GL11.glColor3f(1.0f, 0.0f, 0.0f); Sphere s = new Sphere(); s.setDrawStyle(GLU.GLU_FILL); s.setNormals(GLU.GLU_SMOOTH); s.draw(3.8f, 100, 100); GL11.glDisable(GL11.GL_LIGHT1); GL11.glDisable(GL11.GL_LIGHT0); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEndList(); }
From source file:com.savoycraft.gui.TGFrame.java
License:Open Source License
/** * Draws a rectangle with a HORIZONTAL gradient between the specified * colors./*from w w w. j a v a2 s . co m*/ * * From MOJANG code */ protected void drawGradientRectH(int par1, int par2, int par3, int par4, int par5, int par6) { float f = (float) (par5 >> 24 & 255) / 255.0F; float f1 = (float) (par5 >> 16 & 255) / 255.0F; float f2 = (float) (par5 >> 8 & 255) / 255.0F; float f3 = (float) (par5 & 255) / 255.0F; float f4 = (float) (par6 >> 24 & 255) / 255.0F; float f5 = (float) (par6 >> 16 & 255) / 255.0F; float f6 = (float) (par6 >> 8 & 255) / 255.0F; float f7 = (float) (par6 & 255) / 255.0F; GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glShadeModel(GL11.GL_SMOOTH); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(f5, f6, f7, f4); tessellator.addVertex((double) par3, (double) par2, (double) this.zLevel); tessellator.setColorRGBA_F(f1, f2, f3, f); tessellator.addVertex((double) par1, (double) par2, (double) this.zLevel); tessellator.addVertex((double) par1, (double) par4, (double) this.zLevel); tessellator.setColorRGBA_F(f5, f6, f7, f4); tessellator.addVertex((double) par3, (double) par4, (double) this.zLevel); tessellator.draw(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); }