简体   繁体   中英

LibGDX - Scaled texture is repeating with Clamp to Edge

I am using the following texture

质地

It is being displayed only partially and it gets repeated when I used the following code:

                    float scale = (float)( (float)Gdx.graphics.getWidth() / (float)(tex.getWidth()));
                    w = Gdx.graphics.getWidth();
                    h = scale * tex.getHeight();

                    float x = 0.0f;
                    float y = Gdx.graphics.getWidth() - h * splashTimer;

                    Sprite s = new Sprite(tex);
                    //s.setOriginCenter();


                    //  s.setScale(scale);
                    //s.setOriginCenter();
                    //  s.setOriginCenter();
                    //s.setSize(s.getWidth() * scale, s.getHeight() * scale);
                    //s.setOriginCenter();
                    s.setScale(0.1f);//1.0f + (1.0f - scale));

                    s.setOrigin(0, 0);
                    s.setPosition(x, y);

                    batch.begin();
                    batch.draw(s,0,0,Gdx.graphics.getWidth(), scale * s.getHeight());
                //  s.draw(batch);
                    batch.end();

It gets chopped and repeated in Android and looks like this:

在此处输入图片说明

Orange isn't even drawn. Why is this happening?

Apparently this happened because I was using mipmaps. I disabled the use of mipmaps and now it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM