I am using ShapeRenderer in libgdx to draw my only character to get rid of texture in my game. But I am not getting quality results. Circle edges are distorted. I tried with high resolution and also by reducing size of character but result was same.
I go through This answer , it is not applicable on ShapeRenderer.
Is there anyway I can apply any filter or anti-aliasing to make it look good?
Is it worth to draw using ShapeRenderer to get rid of a high resolution texture? I am able to induce 3d like effect by drawing lots of rectangle, circle, lines, curves etc. would it optimize the speed and fps of my game?
Code:
package com.test.com;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
public class shapeRenderer implements ApplicationListener {
public OrthographicCamera camera;
int w,h;
ShapeRenderer sr;
@Override
public void create() {
//Device width and height
w=Gdx.graphics.getWidth();
h=Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false, w, h); // it is same as camera .setToOrtho(false);
camera.update();
sr= new ShapeRenderer();
Gdx.graphics.setContinuousRendering(false);
}
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void render() {
Gdx.gl.glClearColor(107/255f, 107/255f,107/255f, 1);
//Gdx.gl.glClearColor(190/255f, 190/255f,190/255f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.update();
float x1=w/3;
float y1=h/3;
float cc=w/2;
sr.begin(ShapeType.Filled);
sr.setColor(290/255f, 190/255f,190/255f, 1);
sr.rect(x1,y1, cc,cc);
sr.setColor(107/255f, 107/255f,207/255f, 1);
cc=cc/2;
sr.triangle(x1, y1, x1+cc, y1, x1, y1+cc);
sr.setColor(290/255f, 290/255f,290/255f, 1);
sr.circle(x1+cc,y1+cc, (cc*(2^1/2))/2);
sr.end();
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
}