gpt4 book ai didi

java - 无法在angengine中显示SVG

转载 作者:行者123 更新时间:2023-12-01 15:05:42 25 4
gpt4 key购买 nike

我正在尝试使用 andengine 将 SVG 渲染到屏幕上,但不幸的是它没有被显示。另外,我在运行项目时没有遇到任何异常或错误,因此我发现调试非常困难。

我看过this post但我猜 BlackPawnTextureBuilder 在 GLES2 上不可用。

我在下面添加了部分代码,

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);
}

我是否忘记了代码中的某些内容?预先感谢您的帮助。

最佳答案

我终于成功了。

似乎当我使用 GLES2 时,我必须在加载纹理Atlas 之前包含以下行。

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

现在我的 onCreateResources 看起来像这样,

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();
}

关于java - 无法在angengine中显示SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12987976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com