List of usage examples for org.lwjgl.opengl GL11 glColor4f
public static native void glColor4f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green, @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha);
From source file:com.ardor3d.renderer.lwjgl.LwjglFont.java
License:Open Source License
/** * <code>print</code> renders the specified string to a given (x,y) location. The x, y location is in terms of * screen coordinates. There are currently two sets of fonts supported: NORMAL and ITALICS. * //from w w w . java 2s . co m * @param r * * @param x * the x screen location to start the string render. * @param y * the y screen location to start the string render. * @param text * the String to render. * @param set * the mode of font: NORMAL or ITALICS. */ public void print(final Renderer r, final double x, final double y, final ReadOnlyVector3 scale, final StringBuffer text, int set) { final RendererRecord matRecord = ContextManager.getCurrentContext().getRendererRecord(); if (set > 1) { set = 1; } else if (set < 0) { set = 0; } final boolean alreadyOrtho = r.isInOrthoMode(); if (!alreadyOrtho) { r.setOrtho(); } else { LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); } GL11.glTranslated(x, y, 0); GL11.glScaled(scale.getX(), scale.getY(), scale.getZ()); GL11.glListBase(base - 32 + (128 * set)); // Put the string into a "pointer" if (text.length() > scratch.capacity()) { scratch = BufferUtils.createByteBuffer(text.length()); } else { scratch.clear(); } final int charLen = text.length(); for (int z = 0; z < charLen; z++) { scratch.put((byte) text.charAt(z)); } scratch.flip(); GL11.glColor4f(fontColor.getRed(), fontColor.getGreen(), fontColor.getBlue(), fontColor.getAlpha()); // call the list for each letter in the string. GL11.glCallLists(scratch); // set color back to white GL11.glColor4f(1, 1, 1, 1); if (!alreadyOrtho) { r.unsetOrtho(); } else { LwjglRendererUtil.switchMode(matRecord, GL11.GL_MODELVIEW); GL11.glPopMatrix(); } }
From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java
License:Open Source License
public void applyDefaultColor(final ReadOnlyColorRGBA defaultColor) { if (defaultColor != null) { GL11.glColor4f(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue(), defaultColor.getAlpha()); } else {/* w w w . j a va 2 s. c om*/ GL11.glColor4f(1, 1, 1, 1); } }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glColor4f(float red, float green, float blue, float alpha) { GL11.glColor4f(red, green, blue, alpha); }
From source file:com.badlogic.gdx.tools.hiero.unicodefont.GlyphPage.java
License:Apache License
/** Loads glyphs to the backing texture and sets the image on each loaded glyph. Loaded glyphs are removed from the list. * /* w ww .j a v a2 s .c o m*/ * If this page already has glyphs and maxGlyphsToLoad is -1, then this method will return 0 if all the new glyphs don't fit. * This reduces texture binds when drawing since glyphs loaded at once are typically displayed together. * @param glyphs The glyphs to load. * @param maxGlyphsToLoad This is the maximum number of glyphs to load from the list. Set to -1 to attempt to load all the * glyphs. * @return The number of glyphs that were actually loaded. */ int loadGlyphs(List glyphs, int maxGlyphsToLoad) { if (rowHeight != 0 && maxGlyphsToLoad == -1) { // If this page has glyphs and we are not loading incrementally, return zero if any of the glyphs don't fit. int testX = pageX; int testY = pageY; int testRowHeight = rowHeight; for (Iterator iter = getIterator(glyphs); iter.hasNext();) { Glyph glyph = (Glyph) iter.next(); int width = glyph.getWidth(); int height = glyph.getHeight(); if (testX + width >= pageWidth) { testX = 0; testY += testRowHeight; testRowHeight = height; } else if (height > testRowHeight) { testRowHeight = height; } if (testY + testRowHeight >= pageWidth) return 0; testX += width; } } GL11.glColor4f(1, 1, 1, 1); texture.bind(); int i = 0; for (Iterator iter = getIterator(glyphs); iter.hasNext();) { Glyph glyph = (Glyph) iter.next(); int width = Math.min(MAX_GLYPH_SIZE, glyph.getWidth()); int height = Math.min(MAX_GLYPH_SIZE, glyph.getHeight()); if (rowHeight == 0) { // The first glyph always fits. rowHeight = height; } else { // Wrap to the next line if needed, or break if no more fit. if (pageX + width >= pageWidth) { if (pageY + rowHeight + height >= pageHeight) break; pageX = 0; pageY += rowHeight; rowHeight = height; } else if (height > rowHeight) { if (pageY + height >= pageHeight) break; rowHeight = height; } } renderGlyph(glyph, width, height); pageGlyphs.add(glyph); pageX += width; iter.remove(); i++; if (i == maxGlyphsToLoad) { // If loading incrementally, flip orderAscending so it won't change, since we'll probably load the rest next time. orderAscending = !orderAscending; break; } } // Every other batch of glyphs added to a page are sorted the opposite way to attempt to keep same size glyps together. orderAscending = !orderAscending; return i; }
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;// w w w. j a v a 2 s . c om 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.gui.GuiFamilyCow.java
License:Open Source License
/** * Draws the screen and all the components in it. *///from w w w. ja va2 s . c o m @Override public void drawScreen(int parWidth, int parHeight, float p_73863_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (currPage == 0) { mc.getTextureManager().bindTexture(bookPageTextures[0]); } else { mc.getTextureManager().bindTexture(bookPageTextures[1]); } int offsetFromScreenLeft = (width - bookImageWidth) / 2; drawTexturedModalRect(offsetFromScreenLeft, 2, 0, 0, bookImageWidth, bookImageHeight); int widthOfString; String stringPageIndicator = I18n.format("book.pageIndicator", new Object[] { Integer.valueOf(currPage + 1), bookTotalPages }); widthOfString = fontRendererObj.getStringWidth(stringPageIndicator); fontRendererObj.drawString(stringPageIndicator, offsetFromScreenLeft - widthOfString + bookImageWidth - 44, 18, 0); fontRendererObj.drawSplitString(stringPageText[currPage], offsetFromScreenLeft + 36, 34, 116, 0); super.drawScreen(parWidth, parHeight, p_73863_3_); }
From source file:com.blogspot.jabelarminecraft.magicbeans.gui.GuiMysteriousStranger.java
License:Open Source License
/** * Draws the screen and all the components in it. *///from w ww . ja va 2s .c om @Override public void drawScreen(int parWidth, int parHeight, float p_73863_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (currPage == 0) { mc.getTextureManager().bindTexture(bookPageTextures[0]); } else { mc.getTextureManager().bindTexture(bookPageTextures[1]); } int offsetFromScreenLeft = (width - bookImageWidth) / 2; drawTexturedModalRect(offsetFromScreenLeft, 2, 0, 0, bookImageWidth, bookImageHeight); int widthOfString; String stringPageIndicator = I18n.format("book.pageIndicator", new Object[] { Integer.valueOf(currPage + 1), bookTotalPages }); widthOfString = fontRendererObj.getStringWidth(stringPageIndicator); fontRendererObj.drawString(stringPageIndicator, offsetFromScreenLeft - widthOfString + bookImageWidth - 44, 18, 0); fontRendererObj.drawSplitString(stringPageText[currPage], offsetFromScreenLeft + 36, 34, 116, 0); super.drawScreen(parWidth, parHeight, p_73863_3_); }
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. *//* ww w. j a va 2 s . c o m*/ @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.magicbeans.renderers.RenderMysteriousStranger.java
License:Open Source License
@Override public void passSpecialRender(EntityLivingBase parEntity, double parX, double parY, double parZ) { super.passSpecialRender(parEntity, parX, parY, parZ); if (parEntity.ticksExisted < 20 * 2) { GL11.glPushMatrix();//from w ww .j a v a2 s .c om GL11.glTranslated(parX, parY + parEntity.height / 2, parZ); GL11.glScalef(3.0F, 3.0F, 3.0F); GL11.glEnable(GL11.GL_BLEND); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, (40.0F - parEntity.ticksExisted) / 40.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glCallList(ClientProxy.sphereIdOutside); GL11.glCallList(ClientProxy.sphereIdInside); GL11.glPopMatrix(); } }
From source file:com.bluepowermod.client.gui.GuiBase.java
License:Open Source License
@Override protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(resLoc); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize); for (IGuiWidget widget : widgets) { widget.render(i, j);/*from www . j ava 2 s. com*/ } }