【发布时间】:2014-02-14 16:13:59
【问题描述】:
所以我有两个独立的程序,但是我在一个程序上加载图像时遇到了问题。
在第一个中,我将一个图像作为纹理加载到 mainGameScreen.java 中,大小为 800x480 像素。
Texture img1;
img1= new Texture(Gdx.files.internal("bg1.png"));
加载完全没有问题
所以第一个问题是为什么一个加载而另一个不加载,即使第一个只是第二个的横向版本。
在我的第二个程序中,我有一个 480x800 的图像。但是我在 Images.java 中加载它。
public class Images{
public static Texture img2;
public static void load(){
img2 = new Texture (Gdx.files.internal("bg2.PNG"))
它会引发错误Texture width and height must be a power of 2
但是,如果我将图像的大小更改为 512x512,那么它不会引发任何错误,但是当我渲染它时,我会得到一个带有静态颜色的空白屏幕。
然后在我的 MyRenderer.java 文件中,我有一个批次,我将它绘制到我的批次中。
public class MyRenderer{
OrthographicCamera camera;
public MyRenderer(){
camera = new OrthographicCamera();
camera.position.set(0, 0, 0);
public void update;
camera.update();
batch.SetProjectionMatrix(camera.combined)
batch.begin();
batch.draw(Images.img2, 0, 0);
batch.end ();
【问题讨论】:
-
您在两个程序中都使用 OpenGL ES 2.0 吗? OpenGL ES 2.0 似乎不再需要“二的幂”纹理,OpenGL Es 1.x 需要。所以只需比较您的 2 个程序的 OpenGL 版本。
-
@Springrbua 谢谢,我回家后试试
标签: java android textures libgdx