List of usage examples for org.lwjgl.opengl GL11 glPolygonOffset
public static void glPolygonOffset(@NativeType("GLfloat") float factor, @NativeType("GLfloat") float units)
From source file:chb.mods.mffs.client.TECapacitorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityCapacitor) { TileEntityCapacitor topview = (TileEntityCapacitor) tileEntity; GL11.glPushMatrix();/* w w w.j ava2s. c o m*/ GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Capacitor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("capacity: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getCapacity()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getCapacity()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("range: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getTransmitRange()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getTransmitRange())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("linked device: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getLinketProjektor()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getLinketProjektor())), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:chb.mods.mffs.client.TEExtractorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityExtractor) { TileEntityExtractor topview = (TileEntityExtractor) tileEntity; GL11.glPushMatrix();//from w w w .j a va 2s . c o m GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Extractor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("WE:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkdone()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkdone()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("WC left:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkCylce()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkCylce())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("FE Cap:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getForceEnergybuffer() / 1000).concat("k"), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth( String.valueOf(topview.getForceEnergybuffer() / 1000).concat("k")), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:com.ardor3d.scene.state.lwjgl.LwjglOffsetStateUtil.java
License:Open Source License
private static void setOffset(final float factor, final float units, final OffsetStateRecord record) { if (!record.isValid() || record.factor != factor || record.units != units) { GL11.glPolygonOffset(factor, units); record.factor = factor;/*from w ww. j ava2 s . co m*/ record.units = units; } }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glPolygonOffset(float factor, float units) { GL11.glPolygonOffset(factor, units); }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glPolygonOffset(float factor, float units) { GL11.glPolygonOffset(factor, units); }
From source file:fr.def.iss.vd2.lib_v3d.V3DCanvas.java
License:Open Source License
/** * Sets up the screen.//w w w . j ava 2 s .c o m * * @see javax.media.openGL11.GLEventListener#init(javax.media.openGL11.GLAutoDrawable) */ public void init() { try { frame = new JFrame("Space agencies"); //frame.setSize(width,height); //frame.setUndecorated(true); //here frame.setVisible(true); //frame.setAlwaysOnTop(true); frame.setLocation(0, 0); Canvas canvas = new Canvas(); canvas.setMinimumSize(new Dimension(800, 600)); canvas.setPreferredSize(new Dimension(width, height)); frame.add(canvas); frame.pack(); frame.addWindowListener(generateWindowListener()); frame.getContentPane().addHierarchyBoundsListener(new HierarchyBoundsListener() { @Override public void ancestorMoved(HierarchyEvent e) { } @Override public void ancestorResized(HierarchyEvent e) { width = frame.getContentPane().getWidth(); height = frame.getContentPane().getHeight(); reshape(0, 0, width, height); } }); Display.setDisplayMode(new DisplayMode(width, height)); //Display.setFullscreen(true); Display.setVSyncEnabled(false); Display.setTitle("Space agencies"); Display.setParent(canvas); Display.create(); canvas.requestFocus(); } catch (Exception e) { System.out.println("Error setting up display" + e); System.exit(0); } // Enable z- (depth) buffer for hidden surface removal. GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_POINT_SMOOTH); if (polygonOffset) { GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPolygonOffset(1.0f, 1.0f); } GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); // Enables Clearing Of The Depth Buffer GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); // Enable smooth shading. GL11.glShadeModel(GL11.GL_SMOOTH); // Define "clear" color. GL11.glClearColor(0f, 0f, 0.4f, 0f); // We want a nice perspective. GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glFlush(); TextureManager.clearCache(); initied = true; // new LWJGLBinding(); }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glPolygonOffset(float factor, float units) { GL11.glPolygonOffset(factor, units); }
From source file:mods.mffs.client.renderer.TECapacitorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityCapacitor) { TileEntityCapacitor topview = (TileEntityCapacitor) tileEntity; GL11.glPushMatrix();/* ww w . jav a 2s .c o m*/ GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Capacitor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("capacity: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getPercentageStorageCapacity()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth( String.valueOf(topview.getPercentageStorageCapacity()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("range: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getTransmitRange()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getTransmitRange())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("linked device: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getLinketProjektor()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getLinketProjektor())), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:mods.mffs.client.renderer.TEExtractorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityExtractor) { TileEntityExtractor topview = (TileEntityExtractor) tileEntity; GL11.glPushMatrix();/*from www . j a va 2 s. c om*/ GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Extractor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("WE:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkdone()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkdone()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("WC left:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkCylce()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkCylce())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("FE Cap:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getCapacity()).concat("%"), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getCapacity()).concat("%")), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:net.malisis.demo.rwldemo.RwlRenderer.java
License:Open Source License
private void renderBlockHighlight() { EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; MovingObjectPosition mop = Minecraft.getMinecraft().objectMouseOver; ForgeDirection dir = ForgeDirection.getOrientation(mop.sideHit); set(mop.blockX + dir.offsetX, mop.blockY + dir.offsetY, mop.blockZ + dir.offsetZ); set(world, world.getBlock(mop.blockX, mop.blockY, mop.blockZ), mop.blockX, mop.blockY, mop.blockZ, world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ)); //set(-1, 3, 6); int color = 0x000066; GL11.glPushMatrix();/*from w w w. j a v a 2 s . c o m*/ GL11.glTranslatef(x, y, z); next(GL11.GL_LINE_LOOP); //GL11.glDisable(GL11.GL_DEPTH_TEST); disableTextures(); RenderParameters rp = new RenderParameters(); rp.colorMultiplier.set(color); drawShape(new Cube(), rp); next(GL11.GL_QUADS); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glPolygonOffset(-3.0F, -3.0F); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); enableTextures(); ForgeDirection facing = EntityUtils.getEntityFacing(player); String[] texts = { x + "," + y + "," + z + " (" + blockMetadata + ")", "" + facing, "" + player.rotationYaw, "Chunk " + (x >> 4) + ", " + (z >> 4) }; FontRenderOptions fro = new FontRenderOptions(); fro.fontScale = 0.1F; fro.color = 0x000066; float ox = 0; float oy = 1 - fro.fontScale; float oz = 0; if (facing == ForgeDirection.NORTH) { oz = 1; } else if (facing == ForgeDirection.EAST) { //fro.angle = 270; ox = -1; } else if (facing == ForgeDirection.SOUTH) { //fro.angle = 180; oz = -1; } else if (facing == ForgeDirection.WEST) { //fro.angle = 90; ox = 1; } if (dir == ForgeDirection.UP) { // fro.angle = -90; // fro.aX = 1; // fro.aY = 0; oz = 0; oy = 1; if (facing == ForgeDirection.NORTH) { ox = 0; oy = 0; } if (facing == ForgeDirection.WEST) { oy = 0; } } MalisisFont font = MalisisFont.minecraftFont; int i = 0; for (String str : texts) { float offset = font.getStringWidth(str, fro); ox = x + ox; oy = y + oy - i * fro.fontScale; oz = z + oz; drawText(font, str, ox, oy, oz, fro); i++; } // MalisisCore.message(fro.x + "," + fro.y + "," + fro.z); next(); GL11.glPopMatrix(); GL11.glPolygonOffset(0.0F, 0.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); }