List of usage examples for org.lwjgl.opengl GL11 glTranslatef
public static native void glTranslatef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:com.aelitis.azureus.plugins.view3d.ViewTest2.java
License:Open Source License
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite comp = new Composite(shell, SWT.NONE); comp.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true;//from www . j a va 2 s . co m data.accumAlphaSize = 8; data.accumBlueSize = 8; data.accumGreenSize = 8; data.accumRedSize = 8; final GLCanvas canvas = new GLCanvas(comp, SWT.NONE, data); canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } canvas.addListener(SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle bounds = canvas.getBounds(); float fAspect = (float) bounds.width / (float) bounds.height; canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } GL11.glViewport(0, 0, bounds.width, bounds.height); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); } }); GL11.glLineWidth(1); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor3f(1.0f, 0.0f, 0.0f); GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST); GL11.glClearDepth(1.0); GL11.glLineWidth(2); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glShadeModel(GL11.GL_FLAT); GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClearAccum(0.0f, 0.0f, 0.0f, 0.0f); shell.setText("SWT/LWJGL Example"); shell.setSize(640, 480); shell.open(); final Runnable run = new Runnable() { float rot = 0; public void run() { if (!canvas.isDisposed()) { canvas.setCurrent(); try { GLContext.useContext(canvas); } catch (LWJGLException e) { e.printStackTrace(); } int ACSIZE = 8; int[] viewport = getViewport(); GL11.glClear(GL11.GL_ACCUM_BUFFER_BIT); for (int jitter = 0; jitter < ACSIZE; jitter++) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); double jit_x = jits[jitter][0]; double jit_y = jits[jitter][1]; accPerspective(50.0, (double) viewport[2] / (double) viewport[3], 1.0, 15.0, jit_x, jit_y, 0.0, 0.0, 1.0); { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glClearColor(.3f, .5f, .8f, 1.0f); GL11.glLoadIdentity(); GL11.glTranslatef(0.0f, 0.0f, -10.0f); float frot = rot; GL11.glRotatef(0.15f * rot, 2.0f * frot, 10.0f * frot, 1.0f); GL11.glRotatef(0.3f * rot, 3.0f * frot, 1.0f * frot, 1.0f); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); GL11.glColor3f(0.9f, 0.9f, 0.9f); drawCylinder(2, 3, 50, 0); drawTorus(1, 1.9f + ((float) Math.sin((0.004f * frot))), 15, 15); } GL11.glAccum(GL11.GL_ACCUM, 1.0f / ACSIZE); } GL11.glAccum(GL11.GL_RETURN, 1.0f); GL11.glFlush(); rot += 0.1; canvas.swapBuffers(); display.asyncExec(this); } } }; canvas.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { run.run(); } }); display.asyncExec(run); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:com.ardor3d.renderer.lwjgl.LwjglFont.java
License:Open Source License
/** * <code>buildDisplayList</code> sets up the 256 display lists that are used to render each font character. Each * list quad is 16x16, as defined by the font image size. */// w w w. ja va 2 s. c o m public void buildDisplayList() { float cx; float cy; base = GL11.glGenLists(256); for (int loop = 0; loop < 256; loop++) { cx = (loop % 16) / 16.0f; cy = (loop / 16) / 16.0f; GL11.glNewList(base + loop, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(cx, 1 - cy - 0.0625f); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f); GL11.glVertex2i(16, 0); GL11.glTexCoord2f(cx + 0.0625f, 1 - cy); GL11.glVertex2i(16, 16); GL11.glTexCoord2f(cx, 1 - cy); GL11.glVertex2i(0, 16); GL11.glEnd(); GL11.glTranslatef(10, 0, 0); GL11.glEndList(); } }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glTranslatef(float x, float y, float z) { GL11.glTranslatef(x, y, z); }
From source file:com.badlogic.gdx.tools.hiero.unicodefont.UnicodeFont.java
License:Apache License
/** Identical to {@link #drawString(float, float, String, Color, int, int)} but returns a DisplayList which provides access to * the width and height of the text drawn. */ public void drawDisplayList(float x, float y, String text, Color color, int startIndex, int endIndex) { if (text == null) throw new IllegalArgumentException("text cannot be null."); if (text.length() == 0) return;//from w w w . j a v a 2 s .com if (color == null) throw new IllegalArgumentException("color cannot be null."); x -= paddingLeft; y -= paddingTop; String displayListKey = text.substring(startIndex, endIndex); GL11.glColor4f(color.r, color.g, color.b, color.a); GL11.glTranslatef(x, y, 0); char[] chars = text.substring(0, endIndex).toCharArray(); GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, Font.LAYOUT_LEFT_TO_RIGHT); int maxWidth = 0, totalHeight = 0, lines = 0; int extraX = 0, extraY = ascent; boolean startNewLine = false; Texture lastBind = null; int offsetX = 0; for (int glyphIndex = 0, n = vector.getNumGlyphs(); glyphIndex < n; glyphIndex++) { int charIndex = vector.getGlyphCharIndex(glyphIndex); if (charIndex < startIndex) continue; if (charIndex > endIndex) break; int codePoint = text.codePointAt(charIndex); Rectangle bounds = getGlyphBounds(vector, glyphIndex, codePoint); bounds.x += offsetX; Glyph glyph = getGlyph(vector.getGlyphCode(glyphIndex), codePoint, bounds, vector, glyphIndex); if (startNewLine && codePoint != '\n') { extraX = -bounds.x; startNewLine = false; } if (glyph.getTexture() == null && missingGlyph != null && glyph.isMissing()) glyph = missingGlyph; if (glyph.getTexture() != null) { // Draw glyph, only binding a new glyph page texture when necessary. Texture texture = glyph.getTexture(); if (lastBind != null && lastBind != texture) { GL11.glEnd(); lastBind = null; } if (lastBind == null) { texture.bind(); GL11.glBegin(GL11.GL_QUADS); lastBind = texture; } int glyphX = bounds.x + extraX; int glyphY = bounds.y + extraY; GL11.glTexCoord2f(glyph.getU(), glyph.getV()); GL11.glVertex3f(glyphX, glyphY, 0); GL11.glTexCoord2f(glyph.getU(), glyph.getV2()); GL11.glVertex3f(glyphX, glyphY + glyph.getHeight(), 0); GL11.glTexCoord2f(glyph.getU2(), glyph.getV2()); GL11.glVertex3f(glyphX + glyph.getWidth(), glyphY + glyph.getHeight(), 0); GL11.glTexCoord2f(glyph.getU2(), glyph.getV()); GL11.glVertex3f(glyphX + glyph.getWidth(), glyphY, 0); } if (glyphIndex > 0) extraX += paddingRight + paddingLeft + paddingAdvanceX; maxWidth = Math.max(maxWidth, bounds.x + extraX + bounds.width); totalHeight = Math.max(totalHeight, ascent + bounds.y + bounds.height); if (codePoint == '\n') { startNewLine = true; // Mac gives -1 for bounds.x of '\n', so use the bounds.x of the next glyph. extraY += getLineHeight(); lines++; totalHeight = 0; } else if (nativeRendering) offsetX += bounds.width; } if (lastBind != null) GL11.glEnd(); GL11.glTranslatef(-x, -y, 0); }
From source file:com.blogspot.jabelarminecraft.magicbeans.models.ModelGiant.java
License:Open Source License
/** * Renders specific entity to allow access to any specific fields * @param parEntity/* w w w . ja v a2 s . co m*/ * @param par2 * @param par3 * @param par4 * @param par5 * @param par6 * @param par7 */ public void renderGiant(EntityGiant parEntity, float par2, float par3, float par4, float par5, float par6, float par7) { setRotationAngles(parEntity, par2, par3, par4, par5, par6, par7, parEntity); // scale the whole thing for big or small entities GL11.glPushMatrix(); GL11.glTranslatef(0F, 1.5F - 1.5F * parEntity.getScaleFactor(), 0F); GL11.glScalef(parEntity.getScaleFactor(), parEntity.getScaleFactor(), parEntity.getScaleFactor()); bipedHead.render(par7); bipedBody.render(par7); bipedRightArm.render(par7); bipedLeftArm.render(par7); bipedRightLeg.render(par7); bipedLeftLeg.render(par7); bipedHeadwear.render(par7); // don't forget to pop the matrix for overall scaling GL11.glPopMatrix(); }
From source file:com.blogspot.jabelarminecraft.magicbeans.models.ModelGoldenGoose.java
License:Open Source License
/** * Renders specific entity to allow access to any specific fields * @param parEntity/*w ww . j a v a 2s .c o m*/ * @param par2 * @param par3 * @param par4 * @param par5 * @param par6 * @param par7 */ public void renderGoldenGoose(EntityGoldenGoose parEntity, float par2, float par3, float par4, float par5, float par6, float par7) { setRotationAngles(par2, par3, par4, par5, par6, par7, parEntity); // scale the whole thing for big or small entities GL11.glPushMatrix(); GL11.glTranslatef(0F, 1.5F - 1.5F * parEntity.getScaleFactor(), 0F); GL11.glScalef(parEntity.getScaleFactor(), parEntity.getScaleFactor(), parEntity.getScaleFactor()); if (isChild) { float f6 = 2.0F; GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 5.0F * par7, 2.0F * par7); head.render(par7); bill.render(par7); chin.render(par7); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); body.render(par7); rightLeg.render(par7); leftLeg.render(par7); rightWing.render(par7); leftWing.render(par7); GL11.glPopMatrix(); } else { head.render(par7); bill.render(par7); chin.render(par7); body.render(par7); rightLeg.render(par7); leftLeg.render(par7); rightWing.render(par7); leftWing.render(par7); } // don't forget to pop the matrix for overall scaling GL11.glPopMatrix(); }
From source file:com.blogspot.jabelarminecraft.magicbeans.renderers.RenderGoldenEggThrown.java
License:Open Source License
/** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. *///from ww w. j a v a 2 s .c om @Override public void doRender(Entity parEntity, double parX, double parY, double parZ, float parIgnored1, float parIgnored2) { // IIcon iicon = itemBasisForEntity.getIconFromDamage(iconIndex); // // if (iicon != null) // { GL11.glPushMatrix(); GL11.glTranslatef((float) parX, (float) parY, (float) parZ); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F, 0.5F); int l = 0xF5E16F; float f5 = (l >> 16 & 255) / 255.0F; float f6 = (l >> 8 & 255) / 255.0F; float f7 = (l & 255) / 255.0F; GL11.glColor4f(f5, f6, f7, 1.0F); bindEntityTexture(parEntity); Tessellator tessellator = Tessellator.getInstance(); // if (iicon == ItemPotion.func_94589_d("bottle_splash")) // { // int i = PotionHelper.func_77915_a(((EntityPotion)parEntity).getPotionDamage(), false); // float f2 = (i >> 16 & 255) / 255.0F; // float f3 = (i >> 8 & 255) / 255.0F; // float f4 = (i & 255) / 255.0F; // GL11.glColor3f(f2, f3, f4); // GL11.glPushMatrix(); // invokeTesselator(tessellator, ItemPotion.func_94589_d("overlay")); // GL11.glPopMatrix(); // GL11.glColor3f(1.0F, 1.0F, 1.0F); // } // invokeTesselator(tessellator, iicon); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); // } }
From source file:com.blogspot.jabelarminecraft.wildanimals.models.ModelBigCat.java
License:Open Source License
public void renderBigCat(EntityBigCat entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); // scale the whole thing for big or small entities GL11.glPushMatrix();// w w w . j av a2 s . com GL11.glTranslatef(0F, -0.2F, 0F); // need to figure out how to calculate this from scaleFactor (need to manually tweak currently) GL11.glScalef(entity.getScaleFactor(), entity.getScaleFactor(), entity.getScaleFactor()); if (!isChild) { head.renderWithRotation(f5); body.render(f5); leg1.render(f5); leg2.render(f5); leg3.render(f5); leg4.render(f5); tail.renderWithRotation(f5); } else { float f6 = 2.0F; GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 5.0F * f5, 2.0F * f5); head.renderWithRotation(f5); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); GL11.glTranslatef(-0.05F, 24.0F * f5, 0.0F); body.render(f5); leg1.render(f5); leg2.render(f5); leg3.render(f5); leg4.render(f5); tail.renderWithRotation(f5); GL11.glPopMatrix(); } // don't forget to pop the matrix for overall scaling GL11.glPopMatrix(); }
From source file:com.blogspot.jabelarminecraft.wildanimals.models.ModelElephant.java
License:Open Source License
public void renderElephant(EntityElephant parEntity, float parTime, float parSwingSuppress, float par4, float parHeadAngleY, float parHeadAngleX, float par7) { setRotationAngles(parTime, parSwingSuppress, par4, parHeadAngleY, parHeadAngleX, par7, parEntity); // scale the whole thing for big or small entities GL11.glPushMatrix();/* ww w . j a v a2s .com*/ GL11.glTranslatef(0F, -1.5F, 0F); GL11.glScalef(parEntity.getScaleFactor(), parEntity.getScaleFactor(), parEntity.getScaleFactor()); if (this.isChild) { float f6 = 2.0F; GL11.glPushMatrix(); GL11.glTranslatef(0.0F, this.field_78145_g * par7, this.field_78151_h * par7); childHead.render(par7); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); body.render(par7); // scale legs slightly to reduce render flicker on overlapping areas GL11.glPushMatrix(); GL11.glScalef(0.99F, 1.00F, 0.99F); legRearRight.render(par7); legRearLeft.render(par7); legFrontRight.render(par7); legFrontLeft.render(par7); GL11.glPopMatrix(); GL11.glPopMatrix(); } else { head.render(par7); body.render(par7); // scale legs slightly to reduce render flicker on overlapping areas GL11.glPushMatrix(); GL11.glScalef(0.99F, 1.00F, 0.99F); legRearRight.render(par7); legRearLeft.render(par7); legFrontRight.render(par7); legFrontLeft.render(par7); GL11.glPopMatrix(); } // don't forget to pop the matrix for overall scaling GL11.glPopMatrix(); }
From source file:com.blogspot.jabelarminecraft.wildanimals.models.ModelRaptor.java
License:Open Source License
@Override public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { // Set Rotation this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); // Initiate Matrix GL11.glPushMatrix();//from www . j a v a2 s . c o m // Set Scale GL11.glScalef(1.0F / shrink_factor, 1.0F / shrink_factor, 1.0F / shrink_factor); GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); this.head.render(par7); this.headb.render(par7); this.headuppera.render(par7); this.headupperb.render(par7); this.tongue.render(par7); this.tooth1a.render(par7); this.tooth2a.render(par7); this.tooth1b.render(par7); this.tooth2b.render(par7); this.tooth1c.render(par7); this.tooth2c.render(par7); this.tooth1d.render(par7); this.tooth2d.render(par7); this.tooth1e.render(par7); this.tooth2e.render(par7); this.tooth1f.render(par7); this.tooth2f.render(par7); this.tooth1g.render(par7); this.tooth2g.render(par7); this.tooth1h.render(par7); this.tooth2h.render(par7); this.tooth1i.render(par7); this.tooth2i.render(par7); this.tooth1j.render(par7); this.tooth2j.render(par7); this.tooth1k.render(par7); this.tooth2k.render(par7); this.tooth1l.render(par7); this.tooth2l.render(par7); this.tooth1m.render(par7); this.tooth2m.render(par7); this.tooth1n.render(par7); this.tooth2n.render(par7); this.tooth1o.render(par7); this.tooth2o.render(par7); // Set Scale GL11.glScalef(0.995F, 1.0F, 1.0F); this.headlowera.render(par7); this.headlowerb.render(par7); GL11.glScalef(1 / 0.995F, 1.0F, 1.0F); this.body.render(par7); //this.neck.render(par7); this.taila.render(par7); this.tailb.render(par7); this.tailc.render(par7); this.taild.render(par7); this.taile.render(par7); this.leftarm.render(par7); this.lefthanda.render(par7); this.lefthandb.render(par7); this.rightarm.render(par7); this.righthanda.render(par7); this.righthandb.render(par7); this.leftleg.render(par7); //this.leftlegb.render(par7); this.leftlegc.render(par7); this.leftfoot.render(par7); this.leftfoottoe1a.render(par7); this.leftfoottoe2a.render(par7); this.leftfoottoe1b.render(par7); this.leftfoottoe2b.render(par7); this.rightleg.render(par7); //this.rightlegb.render(par7); this.rightlegc.render(par7); this.rightfoot.render(par7); this.rightfoottoe1a.render(par7); this.rightfoottoe2a.render(par7); this.rightfoottoe1b.render(par7); this.rightfoottoe2b.render(par7); // Handle Smaller Parts // Set Scale GL11.glScalef(0.995F, 1.0F, 1.0F); this.neck.render(par7); this.leftlegb.render(par7); this.rightlegb.render(par7); this.headlowerb.render(par7); // Finish Matrix GL11.glPopMatrix(); }