I am trying to follow this tutorial on LibGDX:
but whenever I put the code into the program, i get a whole bunch of errors
here is my code:
package com.me.main;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
public class Game implements ApplicationListener {
public PerspectiveCamera cam;
public ModelBatch modelBatch;
public Model model;
public ModelInstance instance;
@Override
public void create() {
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(10f, 10f, 10f);
cam.lookAt(0,0,0);
cam.near = 1f;
cam.far = 300f;
cam.update();
ModelBuilder modelBuilder = new ModelBuilder();
model = modelBuilder.createBox(5f, 5f, 5f,
new Material(ColorAttribute.createDiffuse(Color.GREEN)),
Usage.Position | Usage.Normal);
instance = new ModelInstance(model);
}
@Override
public void dispose() {
model.dispose();modelBatch.dispose();
model.dispose();
@Override
public void render() {
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
modelBatch.begin(cam);
modelBatch.render(instance);
modelBatch.end();
}
@Override
public void resize(int width, int height) {
}
@Override
public void pause() {
}
@Override
public void resume() {
}
}
and the error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ModelBatch cannot be resolved to a type
Model cannot be resolved to a type
ModelInstance cannot be resolved to a type
ModelBuilder cannot be resolved to a type
ModelBuilder cannot be resolved to a type
Model cannot be resolved to a type
Material cannot be resolved to a type
ColorAttribute cannot be resolved
ModelInstance cannot be resolved to a type
ModelInstance cannot be resolved to a type
Model cannot be resolved to a type
Model cannot be resolved to a type
ModelBatch cannot be resolved to a type
Model cannot be resolved to a type
Syntax error, insert "}" to complete MethodBody
ModelBatch cannot be resolved to a type
ModelBatch cannot be resolved to a type
ModelInstance cannot be resolved to a type
ModelBatch cannot be resolved to a type
at com.me.main.Game.<init>(Game.java:12)
at com.me.main.Main.main(Main.java:14)