我一直在互联网上拼命寻找解决方案......但我没有比功能更进一步glDrawArrays
。我不知道如何使用它,或者它为什么不工作......我想渲染我使用 ObjLoader 加载的模型的多边形线(或顶点线)。相反,它一直向我显示白色边框。
我正在使用 libgdx 1.0.0。
这是我的代码:
public class Teapot extends ApplicationAdapter {
ModelBatch batch;
ModelInstance m;
Camera cam;
CameraInputController camController;
Environment environment;
@Override
public void create () {
batch = new ModelBatch();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(0, 0, 5f);
cam.lookAt(0,0,0);
cam.position.add(0, 2, 0);
cam.near = 1f;
cam.far = 100f;
cam.update();
camController = new CameraInputController(cam);
Gdx.input.setInputProcessor(camController);
Model model = new ObjLoader().loadModel(Gdx.files.internal("teapot.obj"), true);
m = new ModelInstance(model);
}
@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);
Gdx.gl.glDrawArrays(GL20.GL_TRIANGLES, 0, 3);
batch.begin(cam);
batch.render(m);
batch.end();
}
}
我teapot.obj
正在使用:http ://groups.csail.mit.edu/graphics/classes/6.837/F03/models/teapot.obj