Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9eb3199 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Making a graceful fallback for missing textures.

Change-Id: Ib628d8344ab9bdd5f82c61a599c42a4c7ca3052e
parent f835ca02
Loading
Loading
Loading
Loading
−8.22 KiB
Loading image diff...
−2.73 KiB
Loading image diff...
+8 −6
Original line number Diff line number Diff line
@@ -111,8 +111,8 @@ public class SceneManager extends SceneGraphBase {
        if (sSceneManager == null) {
            return null;
        }
        if (sSceneManager.sDefaultCube != null) {
            sSceneManager.sDefault2D = getDefault(true);
        if (sSceneManager.sDefaultCube == null) {
            sSceneManager.sDefaultCube = getDefault(true);
        }
        return sSceneManager.sDefaultCube;
    }
@@ -156,6 +156,9 @@ public class SceneManager extends SceneGraphBase {

    public static Allocation loadCubemap(String name, RenderScriptGL rs, Resources res) {
        Bitmap b = loadBitmap(name, res);
        if (b == null) {
            return null;
        }
        return Allocation.createCubemapFromBitmap(rs, b,
                                                  MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
                                                  Allocation.USAGE_GRAPHICS_TEXTURE);
@@ -163,6 +166,9 @@ public class SceneManager extends SceneGraphBase {

    public static Allocation loadTexture2D(String name, RenderScriptGL rs, Resources res) {
        Bitmap b = loadBitmap(name, res);
        if (b == null) {
            return null;
        }
        return Allocation.createFromBitmap(rs, b,
                                           Allocation.MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
                                           Allocation.USAGE_GRAPHICS_TEXTURE);
@@ -336,10 +342,6 @@ public class SceneManager extends SceneGraphBase {
        mRenderLoop.set_gVertexParamsScript(mVertexParamsScript);
        mRenderLoop.set_gCullScript(mCullScript);

        Allocation checker = Allocation.createFromBitmapResource(mRS, mRes, R.drawable.checker,
                                                         MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
                                                         Allocation.USAGE_GRAPHICS_TEXTURE);
        mRenderLoop.set_gTGrid(checker);
        mRenderLoop.set_gPFSBackground(ProgramStore.BLEND_NONE_DEPTH_TEST(mRS));
    }

+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public class Texture2D extends TextureBase {
    }

    public void setTexture(Allocation tex) {
        mData.texture = tex;
        mData.texture = tex != null ? tex : SceneManager.getDefaultTex2D();
        if (mField != null) {
            mField.set_texture(0, mData.texture, true);
        }
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class TextureCube extends TextureBase {
    }

    public void setTexture(Allocation tex) {
        mData.texture = tex;
        mData.texture = tex != null ? tex : SceneManager.getDefaultTexCube();
        if (mField != null) {
            mField.set_texture(0, mData.texture, true);
        }
Loading