List of usage examples for org.lwjgl.opengl GL11 glDisable
public static void glDisable(@NativeType("GLenum") int target)
From source file:com.professorvennie.machinerycraft.machines.windmill.TileEntityRendererwindmill.java
License:Creative Commons License
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { int x1 = tileentity.xCoord; int y1 = tileentity.yCoord; int z1 = tileentity.zCoord; while (tileentity.getWorldObj().getBlockMetadata(x1, y1, z1) < 7 && tileentity.getWorldObj().getBlock(x1, y1, z1).equals(ModBlocks.windmill)) { y1++;// www. jav a 2s . c o m } int direction = tileentity.getWorldObj().getBlockMetadata(x1, y1, z1) - 8; int metadata = tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord); GL11.glPushMatrix(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef((float) x, (float) y, (float) z); GL11.glTranslatef(0.5F, 0, 0.5F); GL11.glRotatef(direction * 90, 0, 1, 0); GL11.glTranslatef(-0.5F, 0, -0.5F); if (metadata == 1) { TileEntity cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord - 1, tileentity.yCoord, tileentity.zCoord); if (cable instanceof TileEntityCable) drawConnector(ForgeDirection.EAST); cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord + 1, tileentity.yCoord, tileentity.zCoord); if (cable instanceof TileEntityCable) drawConnector(ForgeDirection.WEST); cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord + 1); if (cable instanceof TileEntityCable) drawConnector(ForgeDirection.SOUTH); cable = tileentity.getWorldObj().getTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord - 1); if (cable instanceof TileEntityCable) drawConnector(ForgeDirection.NORTH); } Tessellator tessellator = Tessellator.instance; this.bindTexture(texterwindmill); tessellator.startDrawingQuads(); { if (metadata > 0 && metadata < 7) { tessellator.addVertexWithUV((8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth), 1 * (1F / textureHeight)); tessellator.addVertexWithUV((8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth), 0 * (1F / textureHeight)); tessellator.addVertexWithUV((8) / 2 * pixel, 1, (8) / 2 * pixel, 0 * (1F / textureWidth), 0 * (1F / textureHeight)); tessellator.addVertexWithUV((8) / 2 * pixel, 0, (8) / 2 * pixel, 0 * (1F / textureWidth), 1 * (1F / textureHeight)); tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth), 1 * (1F / textureHeight)); tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 8 * (1F / textureWidth), 0 * (1F / textureHeight)); tessellator.addVertexWithUV((8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth), 0 * (1F / textureHeight)); tessellator.addVertexWithUV((8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth), 1 * (1F / textureHeight)); tessellator.addVertexWithUV((8) / 2 * pixel, 0, (8) / 2 * pixel, 8 * (1F / textureWidth), 1 * (1F / textureHeight)); tessellator.addVertexWithUV((8) / 2 * pixel, 1, (8) / 2 * pixel, 8 * (1F / textureWidth), 0 * (1F / textureHeight)); tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, (8) / 2 * pixel, 0 * (1F / textureWidth), 0 * (1F / textureHeight)); tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, (8) / 2 * pixel, 0 * (1F / textureWidth), 1 * (1F / textureHeight)); tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, (8) / 2 * pixel, 8 * (1F / textureWidth), 1 * (1F / textureHeight)); tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, (8) / 2 * pixel, 8 * (1F / textureWidth), 0 * (1F / textureHeight)); tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 1, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth), 0 * (1F / textureHeight)); tessellator.addVertexWithUV(1 - (8) / 2 * pixel, 0, 1 - (8) / 2 * pixel, 0 * (1F / textureWidth), 1 * (1F / textureHeight)); } if (metadata > 7) { } } tessellator.draw(); if (metadata > 7) drawRoatar(tileentity); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); }
From source file:com.projectzed.mod.renderer.FluidTankRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) { GL11.glTranslated(x, y, z);/*from w ww. j ava2 s. com*/ GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xf0 % 65536, 0xf0 / 65536); this.bindTexture(texture); drawCuboid((TileEntityFluidTankBase) te, minVec, maxVec, (byte) 0); drawCuboid((TileEntityFluidTankBase) te, minVec, maxVec, (byte) 1); drawFluid((TileEntityFluidTankBase) te, fluidMinVec, fluidMaxVec); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glTranslated(-x, -y, -z); }
From source file:com.redthirddivision.quad.rendering.renderers.GuiRenderer.java
License:Apache License
@Override public void render(ArrayList<GuiTexture> elements) { shader.start();/*ww w .j av a2 s .c o m*/ GL30.glBindVertexArray(quad.getVaoID()); GL20.glEnableVertexAttribArray(0); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_DEPTH_TEST); for (GuiTexture gui : elements) { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, gui.getTexture()); Matrix4f matrix = MathHelper.createTransformationMatrix(gui.getPosition(), gui.getScale(), new Vector2f(0, 0)); shader.loadTransformation(matrix); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount()); } GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_DEPTH_TEST); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); shader.stop(); }
From source file:com.runescape.client.revised.editor.modelviewer.Model3D.java
License:Open Source License
public void render(final float x, final float y, final float z, final float rx, final float ry, final float rz, final float sx, final float sy, final float sz) { GL11.glLoadIdentity();/* w w w . j a va 2 s. c o m*/ GL11.glTranslatef(x, y, z); GL11.glRotatef(rx, 1.0F, 0.0F, 0.0F); GL11.glRotatef(ry, 0.0F, 1.0F, 0.0F); GL11.glRotatef(rz, 0.0F, 0.0F, 1.0F); GL11.glScalef(sx, sy, sz); final short[] tri_x = this.triangle_viewspace_x; final short[] tri_y = this.triangle_viewspace_y; final short[] tri_z = this.triangle_viewspace_z; // final short[] tex_map_x = this.texture_map_x; // final short[] tex_map_y = this.texture_map_y; // final short[] tex_map_z = this.texture_map_z; final short[] textures = this.textures; final int[] vertices_x = this.vertices_x; final int[] vertices_y = this.vertices_y; final int[] vertices_z = this.vertices_z; final short[] colors = this.colors; final float model_scale = 4.0F; final float texture_scale = 1.0F; if (this.pointers != null) { //glEnable(GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } Texture texture = null; for (int triangle = 0; triangle != this.triangle_count; ++triangle) { if ((this.alpha != null) && (this.alpha[triangle] == -1)) { continue; } final int point_a = tri_x[triangle]; final int point_b = tri_y[triangle]; final int point_c = tri_z[triangle]; final int color = Model.hsl2rgb[colors[triangle] & 0xffff]; int triangle_type; if (this.face_fill_attributes == null) { triangle_type = 0; } else { triangle_type = this.face_fill_attributes[triangle] & 3; } if ((textures != null) && (textures[triangle] != -1)) { final int id = textures[triangle] & 0xffff; if (ModelConstants.ENABLE_MODEL_TEXTURES && ((texture == null) && (id != -1))) { texture = TextureCache.get(id); } if (texture != null) { texture.bind(); } } final boolean textured = ModelConstants.ENABLE_MODEL_TEXTURES && (texture != null); GL11.glBegin(GL11.GL_TRIANGLES); GL11.glColor4ub((byte) (color >>> 16), (byte) (color >>> 8), (byte) color, (byte) (this.alpha == null ? 0xff : ~this.alpha[triangle])); switch (triangle_type) { case 0://shaded triangle case 1://flat triangle if (textured) { GL11.glTexCoord2f(0.0F, 0.0F); } GL11.glVertex3f(vertices_x[point_a] / model_scale, vertices_y[point_a] / model_scale, vertices_z[point_a] / model_scale); if (textured) { GL11.glTexCoord2f(0.0F, texture_scale / model_scale); } GL11.glVertex3f(vertices_x[point_b] / model_scale, vertices_y[point_b] / model_scale, vertices_z[point_b] / model_scale); if (textured) { GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale); } GL11.glVertex3f(vertices_x[point_c] / model_scale, vertices_y[point_c] / model_scale, vertices_z[point_c] / model_scale); break; case 2://textured? case 3://textured? final int ptr = this.face_fill_attributes[triangle] >> 2; final int tex_point_a = this.texture_map_x[ptr]; final int tex_point_b = this.texture_map_y[ptr]; final int tex_point_c = this.texture_map_z[ptr]; GL11.glTexCoord2f(0.0F, 0.0F); GL11.glVertex3f(vertices_x[tex_point_a] / model_scale, vertices_y[tex_point_a] / model_scale, vertices_z[tex_point_a] / model_scale); GL11.glTexCoord2f(0.0F, texture_scale / model_scale); GL11.glVertex3f(vertices_x[tex_point_b] / model_scale, vertices_y[tex_point_b] / model_scale, vertices_z[tex_point_b] / model_scale); GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale); GL11.glVertex3f(vertices_x[tex_point_c] / model_scale, vertices_y[tex_point_c] / model_scale, vertices_z[tex_point_c] / model_scale); break; } GL11.glEnd(); } if (texture != null) { GL11.glDisable(GL11.GL_TEXTURE_2D); } }
From source file:com.rvantwisk.cnctools.controls.opengl.ArrowsActor.java
License:Open Source License
@Override public void draw() { GL11.glPushMatrix(); GL11.glDisable(GL11.GL_CULL_FACE); vboInfo.draw(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glPopMatrix(); }
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 w ww . j ava 2 s . c om*/ 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.samrj.devil.game.Game.java
License:Open Source License
/** * Creates a new game object. Initializes the window with the given config. * /*w w w . j a va 2 s. c om*/ * @param title The title of the window. * @param hints The window hints to use. * @param config The configuration to use. */ public Game(String title, HintSet hints, GameConfig config) { if (title == null || config == null) throw new NullPointerException(); if (!initialized) throw new IllegalStateException("Game.init() not called."); ensureMainThread(); // <editor-fold defaultstate="collapsed" desc="Initialize Window"> { GLFW.glfwDefaultWindowHints(); GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GL11.GL_FALSE); GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GL11.GL_FALSE); GLFW.glfwWindowHint(GLFW.GLFW_DECORATED, config.borderless ? GL11.GL_FALSE : GL11.GL_TRUE); GLFW.glfwWindowHint(GLFW.GLFW_FLOATING, GL11.GL_FALSE); GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, 0); if (config.msaa > 0) GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, config.msaa); if (hints != null) hints.glfw(); GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GL11.GL_TRUE); monitor = config.fullscreen ? GLFW.glfwGetPrimaryMonitor() : 0; window = GLFW.glfwCreateWindow(config.resolution.x, config.resolution.y, title, monitor, 0); GLFW.glfwMakeContextCurrent(window); GLFW.glfwSwapInterval(config.vsync ? 1 : 0); GLFW.glfwSetInputMode(window, GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED); } if (!config.fullscreen) //Center window { Vec2i windowSize = GLFWUtil.getWindowSize(window); GLFWVidMode mode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor()); GLFW.glfwSetWindowPos(window, (mode.width() - windowSize.x) / 2, (mode.height() - windowSize.y) / 2); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Initialize OpenGL Context"> { capabilities = GL.createCapabilities(); GL11.glViewport(0, 0, config.resolution.x, config.resolution.y); GL11.glDisable(GL13.GL_MULTISAMPLE); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Initialize Sync"> { if (!config.vsync && config.fps > 0) { sync = new Sync(config.fps, config.sleeper); frameTime = sync.getFrameTime(); } else { sync = null; GLFWVidMode mode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor()); frameTime = Math.round(1_000_000_000.0 / mode.refreshRate()); } } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Initialize Input"> { mouse = new Mouse(window, this::onMouseMoved, this::onMouseButton, this::onMouseScroll); mouse.setGrabbed(false); keyboard = new Keyboard(this::onKey); eventBuffer = new EventBuffer(window, mouse, keyboard); } // </editor-fold> stepper = config.stepper; }
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);/* w ww.java 2s .c o m*/ 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.savageboy74.savagetech.client.render.tileentity.TileEntityRendererLootBox.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { if (tileEntity instanceof TileEntityLootBox) { TileEntityLootBox tileEntityLootBox = (TileEntityLootBox) tileEntity; ForgeDirection direction = null; if (tileEntityLootBox.getWorldObj() != null) { direction = tileEntityLootBox.getOrientation(); }// w w w.j a va2 s . c o m this.bindTexture(Textures.Model.LOOT_BOX); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short angle = 0; if (direction != null) { if (direction == ForgeDirection.NORTH) { angle = 180; } else if (direction == ForgeDirection.SOUTH) { angle = 0; } else if (direction == ForgeDirection.WEST) { angle = 90; } else if (direction == ForgeDirection.EAST) { angle = -90; } } GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float adjustedLidAngle = tileEntityLootBox.prevLidAngle + (tileEntityLootBox.lidAngle - tileEntityLootBox.prevLidAngle) * tick; adjustedLidAngle = 1.0F - adjustedLidAngle; adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle; modelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F); modelChest.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } }
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 va 2 s. c om*/ * * 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); }