Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void bloomCircle(double x, double y, double width, int blurRadius, Color color, boolean cache) {
- GlStateManager.pushAttrib();
- GlStateManager.pushMatrix();
- GlStateManager.alphaFunc(516, 0.01f);
- double height = width;
- height = Math.max(0, height);
- width = Math.max(0, width);
- width += blurRadius * 2;
- height += blurRadius * 2;
- x -= blurRadius;
- y -= blurRadius;
- final float _X = (float) (x - 0.25f);
- final float _Y = (float) (y + 0.25f);
- final int identifier = (int) (width * height + width + color.hashCode() * blurRadius + blurRadius);
- GL11.glEnable(3553);
- GL11.glDisable(2884);
- GL11.glEnable(3008);
- GL11.glEnable(3042);
- if (shadowCache.containsKey(identifier) && cache) {
- final int texId = shadowCache.get(identifier);
- GlStateManager.bindTexture(texId);
- }
- else {
- final BufferedImage original = new BufferedImage((int) width, (int) height, 2);
- final Graphics g = original.getGraphics();
- g.setColor(color);
- for (int i=0; i < 4; i++) {
- g.fillArc(blurRadius, blurRadius, (int) (width - blurRadius * 2), (int) (height - blurRadius * 2), i*90, i*90 + 90);
- }
- g.dispose();
- final GaussianFilter op = new GaussianFilter((float)blurRadius);
- final BufferedImage blurred = op.filter(original, null);
- final int texId = TextureUtil.uploadTextureImageAllocate(TextureUtil.glGenTextures(), blurred, true, false);
- shadowCache.put(identifier, texId);
- }
- GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- GL11.glBegin(7);
- GL11.glTexCoord2f(0.0f, 0.0f);
- GL11.glVertex2d(_X, _Y);
- GL11.glTexCoord2f(0.0f, 1.0f);
- GL11.glVertex2d(_X, _Y + height);
- GL11.glTexCoord2f(1.0f, 1.0f);
- GL11.glVertex2d(_X + width, _Y + height);
- GL11.glTexCoord2f(1.0f, 0.0f);
- GL11.glVertex2d(_X + width, _Y);
- GL11.glEnd();
- GL11.glDisable(3553);
- GL11.glEnable(2884);
- GL11.glDisable(3008);
- GL11.glDisable(3042);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement