I trying to learn LibGDX, I install all the software listed here with a new Eclipse 4.3 on a fresh formatted mac OS X Maverick.
Everything goes smooth, after a reboot, I download, and execute the gdx-setup.jar, fill the form, and import into Eclipse.
No error, no warning, when I try to run the desktop. (Right click the desktop project, Run As -> Java Application).
I got this error
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.diesel.bugs.DieselBugs.create(DieselBugs.java:21)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic.jpg (Local)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:134)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:218)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
I found a lot of similar issue here, I try them all without any good result... Last night I found this, very cool I have the latest Java 1.8, a mac, and Eclipse fit perfectly...
But no success, I try with Java 1.6 and 1.7, Always the same error (No file found, I kept Java 1.7)
I begin to do some debug, here my only modification of the original code generated by the importation.
package com.diesel.bugs;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class DieselBugs extends ApplicationAdapter {
SpriteBatch batch;
Texture imgExternal,imgLocal;
@Override
public void create () {
batch = new SpriteBatch();
String pathLocal = Gdx.files.getLocalStoragePath();
String pathExternal = Gdx.files.getExternalStoragePath();
Boolean isExternal = Gdx.files.isExternalStorageAvailable();
Boolean isLocal = Gdx.files.isLocalStorageAvailable();
imgExternal = new Texture(Gdx.files.external("/Desktop/badlogic.jpg"));
imgLocal = new Texture(Gdx.files.local("badlogic.jpg"));
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(imgExternal, 0, 0);
batch.end();
}
}
The weird thing is pathLocal is equal to "". Is it normal for Gdx.files.getLocalStoragePath() to return nothing (empty string)?
Also the
imgExternal = new Texture(Gdx.files.external("/Desktop/badlogic.jpg"));
Works great. only the local one gives the error, also isLocal, and isExternal return true.
And I try a lots of combinations, like /assets/data/badlogic.jpg
, /assets/badlogic.jpg
, /data/badlogic.jpg
, data/badlogic.jpg
, and badlogic.jpg
.
The image badlogic.jpg is there and I put it in multiple places to be sure.
And now the reason why I'm here for help is I just try all the same step on a PC and everything works great.
What is wrong with my new mac and it's setting?