Isaac Bhasme
Isaac Bhasme

Reputation: 146

Unable to display SVG in angengine

I am trying to render a SVG to the screen using andengine, but unfortunately it is not being displayed. Also, I am not getting any exceptions or errors while running the project, thus I'm finding it very hard to debug.

I've had a look at this post but I guess BlackPawnTextureBuilder is not available on GLES2.

I've included part of my code below,

public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception
{
BuildableBitmapTextureAtlas buildableBitmapTextureAtlas = new BuildableBitmapTextureAtlas(this.getTextureManager(), 2048, 2048, TextureOptions.BILINEAR);
logoSplashITextureRegion = SVGBitmapTextureAtlasTextureRegionFactory.createFromAsset(buildableBitmapTextureAtlas, this, "gfx/BrickRed.svg", 80, 40);
buildableBitmapTextureAtlas.load();
pOnCreateResourcesCallback.onCreateResourcesFinished();
}

public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception
{
logoSplashScene = new Scene();
logoSplashSprite = new Sprite(0, 0, logoSplashITextureRegion,mEngine.getVertexBufferObjectManager())
{
@Override
protected void preDraw(GLState pGLState, Camera pCamera)
{
    super.preDraw(pGLState, pCamera);
    pGLState.enableDither();
}
};
logoSplashSprite.setPosition((CAMERA_WIDTH - logoSplashSprite.getWidth()) * 0.5f, (CAMERA_HEIGHT - logoSplashSprite.getHeight()) * 0.5f);
logoSplashScene.attachChild(logoSplashSprite);
pOnCreateSceneCallback.onCreateSceneFinished(BrickActivity.logoSplashScene);
}

Am I forgetting something in the code? Thanks in advance for you help.

Upvotes: 0

Views: 475

Answers (1)

Isaac Bhasme
Isaac Bhasme

Reputation: 146

I finally managed to make it work.

It seems like as I'm using GLES2 I had to include the following line just before I load my textureAtlas.

buildableBitmapTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));

Now my onCreateResources looks like this,

try
{
buildableBitmapTextureAtlas = new BuildableBitmapTextureAtlas(textureManager, 2048, 2048, TextureOptions.BILINEAR);
SVG redBrick = SVGParser.parseSVGFromAsset(assertManager, "gfx/BrickRed.svg");
iTextureRegion = SVGBitmapTextureAtlasTextureRegionFactory.createFromSVG(buildableBitmapTextureAtlas, redBrick, 80, 40);
buildableBitmapTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));
buildableBitmapTextureAtlas.load();
} catch (TextureAtlasBuilderException e)
{
e.printStackTrace();
}

Upvotes: 1

Related Questions