List of usage examples for org.lwjgl.opengl GL11 glVertex2f
public static native void glVertex2f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y);
From source file:$.DrawSystem.java
License:Open Source License
private void drawLevel(Level level) { GL11.glPushMatrix();/*from w w w.ja va 2 s .c o m*/ GL11.glLoadIdentity(); IPlay backgroundAnimationPlay = level.getBackground(); backgroundAnimationPlay.update((long) (world.getDelta() * 1000L)); final IAnimationFrame currentFrame = backgroundAnimationPlay.getCurrentFrame(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) currentFrame.getImage().getId()); float x1 = -toolkit.getVirtualResolutionWidth() / 2.0f; float x2 = toolkit.getVirtualResolutionWidth() / 2.0f; float y1 = toolkit.getVirtualResolutionHeight() / 2.0f; float y2 = -toolkit.getVirtualResolutionHeight() / 2.0f; float u1 = currentFrame.getU1(); float u2 = currentFrame.getU2(); float v1 = currentFrame.getV2(); float v2 = currentFrame.getV1(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, y2); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(x2, y1); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x1, y1); GL11.glEnd(); GL11.glPopMatrix(); }
From source file:$.DrawSystem.java
License:Open Source License
private void drawSprite(Sprite sprite) { Vector pos = spriteProjector.project(sprite.getPosition()); final IPlay play = sprite.getPlay(); if (null != play) { GL11.glPushMatrix();/*from w w w. java 2 s. c om*/ GL11.glTranslatef(pos.x, pos.y, 0.0f); GL11.glRotatef(sprite.getRotate(), 0, 0, 1.0f); GL11.glScalef(sprite.getScale(), sprite.getScale(), 1); final IAnimationFrame frame = play.getCurrentFrame(); final IAnimationImage image = frame.getImage(); if (image.hasAlpha()) { GL11.glEnable(GL11.GL_BLEND); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) image.getId()); final float u1, u2; if (sprite.isMirrorX()) { u1 = frame.getU2(); u2 = frame.getU1(); } else { u1 = frame.getU1(); u2 = frame.getU2(); } final float v1, v2; if (sprite.isMirrorY()) { v1 = frame.getV1(); v2 = frame.getV2(); } else { v1 = frame.getV2(); v2 = frame.getV1(); } GL11.glColor4f(sprite.getRed(), sprite.getGreen(), sprite.getBlue(), sprite.getAlpha()); float x1 = -sprite.getWidth() / 2.0f; float x2 = sprite.getWidth() / 2.0f; float y1 = -sprite.getHeight() / 2.0f; float y2 = sprite.getHeight() / 2.0f; GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(u1, v1); GL11.glVertex2f(x1, y2); GL11.glTexCoord2f(u2, v1); GL11.glVertex2f(x2, y2); GL11.glTexCoord2f(u2, v2); GL11.glVertex2f(x2, y1); GL11.glTexCoord2f(u1, v2); GL11.glVertex2f(x1, y1); GL11.glEnd(); GL11.glColor3f(1f, 1f, 1f); if (image.hasAlpha()) { GL11.glDisable(GL11.GL_BLEND); } GL11.glPopMatrix(); } if (null != sprite.getLabel()) { GL11.glPushMatrix(); GL11.glTranslatef(pos.x, pos.y, 0.0f); GL11.glScalef(0.5f, -0.5f, 1f); GL11.glEnable(GL11.GL_BLEND); LwjglNuitFont font = (LwjglNuitFont) assets.getFont(""); font.drawString(sprite.getLabel(), LwjglNuitFont.Align.CENTER); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); } }
From source file:aphelion.client.graphics.world.Projectile.java
License:Open Source License
@Override public boolean render(@Nonnull Camera camera, int iteration) { if (!isExists()) { return false; }//w ww . j a v a 2 s . c o m if (iteration > 1) { return false; } updateAnimObjects(); Point screenPos = new Point(); camera.mapToScreenPosition(pos, screenPos); if (camera.radarRendering) { if (iteration == 0 && this.animRadar != null) { org.newdawn.slick.Color color = this.animRadar.get(); TextureImpl.bindNone(); GL11.glColor4f(color.r, color.g, color.b, color.a * this.alpha); float x = screenPos.x - 0.5f; float y = screenPos.y - 0.5f; GL11.glBegin(SGL.GL_QUADS); GL11.glVertex2f(x, y); GL11.glVertex2f(x + 1, y); GL11.glVertex2f(x + 1, y + 1); GL11.glVertex2f(x, y + 1); GL11.glEnd(); } return false; } if (iteration == 0) { // render the trail SpriteSheetCounted trail = this.imageTrail.getSpriteSheet(); if (trail != null) { Point trailPos = new Point(); PhysicsPositionVector phyPos = new PhysicsPositionVector(); long rand = imageTrailRandomized.get() ? SwissArmyKnife.fastRandomIsh() : 0; long tick = this.renderingAt_tick - (rand & 0b11); // 0, 1, 2, 3 rand >>= 2; for (int tile = 0; tile < trail.getTilesCount(); tile += (rand & 0b1) + 1, rand >>= 1) { physicsProjectile.getHistoricPosition(phyPos, tick - 2 * tile, true); if (phyPos.pos.set) { trailPos.set(phyPos.pos); trailPos.divide(1024); camera.mapToScreenPosition(trailPos, trailPos); Image img = trail.getSubImage(tile); img.draw(trailPos.x - img.getWidth() / 2, trailPos.y - img.getHeight() / 2, this.alphaFilter); } } } } else if (iteration == 1) { Animation anim; if (imageInactive.isSet() && !this.physicsProjectile.isActive()) { anim = animInactive; } else if (imageBounces.isSet() && this.physicsProjectile.getBouncesLeft() != 0) { anim = animBounces; } else { anim = animNoBounce; // also fallback } if (anim != null) { anim.draw(screenPos.x - anim.getWidth() / 2 * camera.zoom, screenPos.y - anim.getHeight() / 2 * camera.zoom, anim.getWidth() * camera.zoom, anim.getHeight() * camera.zoom, this.alphaFilter); } if (Client.showDebug) { camera.renderPlayerText(this.renderDelay_current + "", screenPos.x + 5, screenPos.y + 5, Color.WHITE); } } return iteration < 1; }
From source file:cellularautomata.CellularAutomata.java
public static void drawPath(TrueTypeFont trueTypeTitleFont, TrueTypeFont trueTypeDimensionsFont) { updateColour(7);/*from w w w . j ava2 s . c o m*/ GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, 0); GL11.glVertex2f(712, 0); GL11.glVertex2f(712, 600); GL11.glVertex2f(0, 600); GL11.glEnd(); for (int yi = 0; yi < 7; yi++) { updateColour(7); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(712, yi * 86); GL11.glVertex2f(800, yi * 86); GL11.glVertex2f(800, yi * 86 + 85); GL11.glVertex2f(712, yi * 86 + 85); GL11.glEnd(); } for (int yi = 0; yi < 7; yi++) { for (int xi = 0; xi < 10; xi++) { if (yi == 0) { updateColour(0); } else { updateColour(path[yi - 1][xi]); } GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(xi * 62 + 90, yi * 86); GL11.glVertex2f(xi * 62 + 61 + 90, yi * 86); GL11.glVertex2f(xi * 62 + 61 + 90, yi * 86 + 85); GL11.glVertex2f(xi * 62 + 90, yi * 86 + 85); GL11.glEnd(); } } for (int yi = 0; yi < 7; yi++) { for (int xi = 0; xi < 9; xi = xi + 8) { updateColour(yi); if (xi == 0) { GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, yi * 86); GL11.glVertex2f(89, yi * 86); GL11.glVertex2f(89, yi * 86 + 85); GL11.glVertex2f(0, yi * 86 + 85); GL11.glEnd(); } } } GL11.glEnable(GL11.GL_TEXTURE_2D); //Enables textures. for (int i = 0; i < 9; i++) { trueTypeTitleFont.drawString(110 + 62 * i, 20, i + 1 + "", Color.black); } trueTypeTitleFont.drawString(668, 20, "0", Color.black); String dimensions = ""; boolean dimensionsSelected = false; for (int yi = 0; yi < 7; yi++) { if (yi == 0) { dimensions = "800 x 600"; if (pixel == 1) { dimensionsSelected = true; borderSize = 0; } else { dimensionsSelected = false; } } if (yi == 1) { dimensions = "400 x 300"; if (pixel == 2) { dimensionsSelected = true; borderSize = 0; } else { dimensionsSelected = false; } } if (yi == 2) { dimensions = "200 x 150"; if (pixel == 4) { dimensionsSelected = true; borderSize = 0; } else { dimensionsSelected = false; } } if (yi == 3) { dimensions = " 80 x 60"; if (pixel == 10) { dimensionsSelected = true; } else { dimensionsSelected = false; } } if (yi == 4) { dimensions = " 32 x 24"; if (pixel == 25) { dimensionsSelected = true; } else { dimensionsSelected = false; } } if (yi == 5) { dimensions = " 16 x 12"; if (pixel == 50) { dimensionsSelected = true; } else { dimensionsSelected = false; } } if (yi == 6) { dimensions = " 8 x 6"; if (pixel == 100) { dimensionsSelected = true; } else { dimensionsSelected = false; } } if (dimensionsSelected) { trueTypeDimensionsFont.drawString(713, 28 + 86 * yi, dimensions, Color.yellow); } else { trueTypeDimensionsFont.drawString(713, 28 + 86 * yi, dimensions, Color.white); } } GL11.glDisable(GL11.GL_TEXTURE_2D); }
From source file:cellularautomata.CellularAutomata.java
public static void drawWeight(int background, int squares, TrueTypeFont trueTypeTitleFont, TrueTypeFont trueTypePaintBrushFont) { updateColour(background);/*w w w. j a va 2 s . c om*/ GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, 0); GL11.glVertex2f(711, 0); GL11.glVertex2f(711, 600); GL11.glVertex2f(0, 600); GL11.glEnd(); Color.black.bind(); for (int yi = 0; yi < 7; yi++) { for (int xi = 0; xi < 9; xi++) { updateColour(squares); if (xi == 0) { updateColour(yi); } if (xi == 8) { updateColour(0); } GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(xi * 89, yi * 86); GL11.glVertex2f(xi * 89 + 88, yi * 86); GL11.glVertex2f(xi * 89 + 88, yi * 86 + 85); GL11.glVertex2f(xi * 89, yi * 86 + 85); GL11.glEnd(); } } GL11.glEnable(GL11.GL_TEXTURE_2D); //Enables textures. for (int yi = 0; yi < 7; yi++) { for (int xi = 0; xi < 7; xi++) { if (xi != 3 || yi != 3) { if (squares == 1 || squares == 6) { trueTypeTitleFont.drawString(120 + 89 * xi, 20 + 86 * yi, neighbourhood[yi][xi][menuState] + "", Color.white); } else { trueTypeTitleFont.drawString(120 + 89 * xi, 20 + 86 * yi, neighbourhood[yi][xi][menuState] + "", Color.black); } } } } String stateString = ""; for (int yi = 1; yi < 7; yi++) { if (yi == 1) { if (black == 1) { stateString = " Left"; } else if (black == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.black); } if (yi == 2) { if (white == 1) { stateString = " Left"; } else if (white == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.white); } if (yi == 3) { if (red == 1) { stateString = " Left"; } else if (red == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.red); } if (yi == 4) { if (blue == 1) { stateString = " Left"; } else if (blue == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.blue); } if (yi == 5) { if (green == 1) { stateString = " Left"; } else if (green == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.green.darker(.7f)); } if (yi == 6) { if (purple == 1) { stateString = " Left"; } else if (purple == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 20 + 86 * yi, stateString, Color.magenta.darker(.7f)); } } if (screenState == 1 && menuState != 6) { trueTypeTitleFont.drawString(745, 20, brushRadius + "", Color.black); } GL11.glDisable(GL11.GL_TEXTURE_2D); }
From source file:cellularautomata.CellularAutomata.java
public static void drawBoard() { updateColour(0);//from w w w .j av a 2 s .c o m GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, 0); GL11.glVertex2f(800, 0); GL11.glVertex2f(800, 600); GL11.glVertex2f(0, 600); GL11.glEnd(); for (int yi = 0; yi < 600 / pixel; yi++) { for (int xi = 0; xi < 800 / pixel; xi++) { updateColour(state[xi][yi][currentRound]); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(xi * pixel + borderSize, yi * pixel + borderSize); GL11.glVertex2f(xi * pixel + pixel - borderSize, yi * pixel + borderSize); GL11.glVertex2f(xi * pixel + pixel - borderSize, yi * pixel + pixel - borderSize); GL11.glVertex2f(xi * pixel + borderSize, yi * pixel + pixel - borderSize); GL11.glEnd(); } } }
From source file:cn.academy.crafting.client.render.item.RendererMatterUnit.java
License:GNU General Public License
@Override public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { ItemMatterUnit item = ModuleCrafting.matterUnit; GL11.glColor4d(1, 1, 1, 1);/*from w w w . j ava 2s. co m*/ if (type != ItemRenderType.INVENTORY) { GL11.glPushMatrix(); { if (type == ItemRenderType.ENTITY) GL11.glTranslated(-.5, -0.1, 0); RenderUtils.drawEquippedItem(stack, 0.0625f); GL11.glColorMask(false, false, false, false); RenderUtils.drawEquippedItem(0.0626f, texMask, texMask); GL11.glColorMask(true, true, true, true); GL11.glDepthFunc(GL11.GL_EQUAL); MatterMaterial mat = item.getMaterial(stack); RenderUtils.drawEquippedItemOverlay(0.0626f, mat.texture); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glPopMatrix(); } else { ShaderMask shader = ShaderMask.instance; float du = -(GameTimer.getAbsTime() % 10000L) / 1e4f, dv = (GameTimer.getAbsTime() % 10000L) / 1e4f; GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderUtils.renderItemInventory(stack); shader.start(texMask); RenderUtils.loadTexture(item.getMaterial(stack).texture); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0 + du, 0 + dv); shader.maskTexCoord(0, 0); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(0 + du, 1 + dv); shader.maskTexCoord(0, 1); GL11.glVertex2f(0, 16); GL11.glTexCoord2f(1 + du, 1 + dv); shader.maskTexCoord(1, 1); GL11.glVertex2f(16, 16); GL11.glTexCoord2f(1 + du, 0 + dv); shader.maskTexCoord(1, 0); GL11.glVertex2f(16, 0); GL11.glEnd(); shader.end(); GL11.glDisable(GL11.GL_BLEND); } }
From source file:colonialdisplay.AntDisplayGL.java
private void drawTile(Rectangle bounds, Rectangle2D.Float r) { GL11.glBegin(GL11.GL_QUADS);/* w w w .ja v a 2 s . c om*/ GL11.glTexCoord2f(r.x, r.y + r.height); GL11.glVertex2f(bounds.x, bounds.y + bounds.height); GL11.glTexCoord2f(r.x + r.width, r.y + r.height); GL11.glVertex2f(bounds.x + bounds.width, bounds.y + bounds.height); GL11.glTexCoord2f(r.x + r.width, r.y); GL11.glVertex2f(bounds.x + bounds.width, bounds.y); GL11.glTexCoord2f(r.x, r.y); GL11.glVertex2f(bounds.x, bounds.y); GL11.glEnd(); }
From source file:com.acornui.jvm.LwjglHelloWorld.java
License:Apache License
private void draw() { // set the color of the quad (R,G,B,A) GL11.glColor3f(0.5f, 0.5f, 1.0f);/* w ww . j av a 2 s . c om*/ // draw quad GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(100, 100); GL11.glVertex2f(100 + 200, 100); GL11.glVertex2f(100 + 200, 100 + 200); GL11.glVertex2f(100, 100 + 200); GL11.glEnd(); }
From source file:com.breckinloggins.DrawUtils.java
License:Open Source License
public static void drawQuad(float x, float y, int size, float rotation) { int halfSize = size / 2; GL11.glPushMatrix();/*from w ww .j a va2 s .c om*/ { GL11.glTranslatef(x, y, 0); GL11.glRotatef(rotation, 0f, 0f, 1f); GL11.glTranslatef(-x, -y, 0); GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2f(x - halfSize, y - halfSize); GL11.glVertex2f(x + halfSize, y - halfSize); GL11.glVertex2f(x + halfSize, y + halfSize); GL11.glVertex2f(x - halfSize, y + halfSize); } GL11.glEnd(); } GL11.glPopMatrix(); }