Wednesday, 15 June 2011

java - ShapeRenderer produces pixelated shapes using LibGDX -



java - ShapeRenderer produces pixelated shapes using LibGDX -

when utilize shaperenderer, comes out pixelated. if draw shape in photoshop same dimensions, it's smooth , clean-looking.

my method follows:

package com.me.actors; import com.badlogic.gdx.gdx; import com.badlogic.gdx.graphics.color; import com.badlogic.gdx.graphics.texture; import com.badlogic.gdx.graphics.g2d.sprite; import com.badlogic.gdx.graphics.g2d.spritebatch; import com.badlogic.gdx.graphics.glutils.shaperenderer; import com.badlogic.gdx.graphics.glutils.shaperenderer.shapetype; import com.badlogic.gdx.scenes.scene2d.actor; public class bub_actors extends actor { private shaperenderer shapes; private texture text; private sprite sprite; public bub_actors(){ shapes = new shaperenderer(); text = new texture(gdx.files.internal("data/circle.png")); sprite = new sprite(); sprite.setregion(text); } @override public void draw(spritebatch batch, float parentalpha) { batch.draw(sprite, 200, 200, 64, 64); shapes.begin(shapetype.filledcircle); shapes.filledcircle(50, 50, 32); shapes.setcolor(color.black); shapes.end(); } }

here's image of output:

any ideas why happens? possible create shaperenderer image (so don't have create spritebatch of different-colored circles...).

the difference anti-aliasing photoshop applies image generates. if zoom in on edges of 2 circles, you'll see anti-aliased 1 has semi-black pixels around edge, shaperenderer generated circle shows pixels exclusively on or off.

the libgdx shaperenderer designed beingness quick , simple way debugging shapes on screen, not back upwards anti-aliasing. easiest way consistent anti-aliased rendering utilize texture. (its possible opengl shader.)

that said, not have create different sprites render different colored circles. utilize white circle transparent background, , render color. (assuming want variety of solid-colored circles).

java libgdx

No comments:

Post a Comment