public JmeBatchRenderBackend(final NiftyJmeDisplay display) { this.display = display; this.batchPool = new ObjectPool<Batch>(new Factory<Batch>() { @Override public Batch createNew() { return new Batch(); } }); }
@Override public void beginBatch(final BlendMode blendMode, final int textureId) { batches.add(batchPool.allocate()); currentBatch = batches.get(batches.size() - 1); currentBatch.begin(blendMode, getTextureAtlas(textureId)); }
public void renderQuad(int x, int y, int width, int height, Color color) { //We test for alpha >0 as an optimization to prevent the render of completely transparent quads. //Nifty use layers that are often used for logical positionning and not rendering. //each layer is rendered as a quad, but that can bump up the number of geometry rendered by a lot. //Since we disable depth write, there is absolutely no point in rendering those quads //This optimization can result in a huge increase of perfs on complex Nifty UIs. if(color.getAlpha() >0){ colorMaterial.setColor("Color", convertColor(color, tempColor)); tempMat.loadIdentity(); tempMat.setTranslation(x, getHeight() - y, 0); tempMat.setScale(width, height, 0); rm.setWorldMatrix(tempMat); rm.setForcedRenderState(renderState); colorMaterial.render(quadGeom, rm); } //System.out.format("renderQuad1(%d, %d, %d, %d, %s)\n", x, y, width, height, color.toString()); }
@Override public void activate( @Nonnull final Nifty nifty, @Nonnull final Element element, @Nonnull final EffectProperties parameter) { startColor = new Color(parameter.getProperty("startColor", "#0000")); endColor = new Color(parameter.getProperty("endColor", "#ffff")); width = new SizeValue(parameter.getProperty("width")); }
public static boolean check(final String color) { if (ColorValidator.isShortModeWithoutAlpha(color) || ColorValidator.isLongModeWithoutAlpha(color) || ColorValidator.isValid(color)) { return true; } return false; }
@Override public void beginFrame() { log.fine("beginFrame()"); for (int i=0; i<batches.size(); i++) { batchPool.free(batches.get(i)); } batches.clear(); // in case we have pending modifyTexture calls we'll need to execute them now if (!modifyTextureCalls.isEmpty()) { Renderer renderer = display.getRenderer(); for (int i=0; i<modifyTextureCalls.size(); i++) { modifyTextureCalls.get(i).execute(renderer); } modifyTextureCalls.clear(); } }
/** * Returns true when the given string is from format: #ffff and false when #ffffffff. * * @param color the color string * @return true or false */ private boolean isShortMode(final String color) { return ColorValidator.isShortMode(color) || ColorValidator.isShortModeWithoutAlpha(color); }
/** * set only the color alpha. * * @param newColorAlpha new alpha value */ @Override public void setColorAlpha(final float newColorAlpha) { color.setAlpha(newColorAlpha); colorAlphaChanged = true; }
public void prepare() { maxX = calcMaxX(curve); for (Point p : curve) { p.x = p.x / maxX; } }
/** * Do we need to know the size of the parent element to calculate this value? * * @return {@code true} if the size of this value can be calculated without knowing about the parent. */ public boolean isIndependentFromParent() { return type.isIndependent(); }
/** * Create a color from an encoded int value alpha + R + G + B. * * @param color color value */ public Color(final int color) { this.alpha = (color >> 24) & 0xFF; this.red = (color >> 16) & 0xFF; this.green = (color >> 8) & 0xFF; this.blue = (color) & 0xFF; this.colorString = fromRGBA(red, green, blue, alpha); }
public ColorValueParser() { setNoResult(); }
private void saveColorAlpha() { colorAlpha = NiftyRenderEngineImpl.this.color.getAlpha(); colorAlphaChanged = NiftyRenderEngineImpl.this.colorAlphaChanged; }
private void restoreAlpha() { NiftyRenderEngineImpl.this.color.setAlpha(colorAlpha); NiftyRenderEngineImpl.this.colorAlphaChanged = colorAlphaChanged; }
private void addVertex(final float x, final float y, final float tx, final float ty, final Color c) { vertexPosBuffer.put(x); vertexPosBuffer.put(getHeight() - y); vertexTexCoordBuffer.put(tx); vertexTexCoordBuffer.put(ty); vertexColorBuffer.put(c.getRed()); vertexColorBuffer.put(c.getGreen()); vertexColorBuffer.put(c.getBlue()); vertexColorBuffer.put(c.getAlpha()); } }