BTW, i post my " render class implements Renderer " for you :
public class Renderer implements GLSurfaceView.Renderer {
private final Context context;
private int program;
private int aPositionLocation;
private int uMatrixLocation;
private final float[] projectionMatrix = new float[16];
private final float[] modelMatrix = new float[16];
public int flag1;
public int flag2;
public int model_index;
private FrameBuffer fb = null;
private World world = null;
private RGBColor back = new RGBColor(100, 100, 150);
private boolean stop = false;
private Light sun = null;
private Camera cam;
private long ticks = 0;
private Model alita = null;
public static Context con;
private Resources res=null;
public static int stat=0;
public static List<String> animations=null;
private Object3D cube = null;
public Renderer(Context context) {
flag1 = 0;
flag2 = 1;
model_index = 0 ;
this.context = context;
Model.context = context;
}
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
ARNativeActivity.nativeSurfaceCreated();
glClearColor(0.0f,0.0f,0.0f,0.0f);
}
private int sub_w;
private int sub_h;
public void onSurfaceChanged(GL10 unused, int width, int height) {
ARNativeActivity.nativeSurfaceChanged(width, height);
glViewport(0, 0,width, height);
sub_w = width;
sub_h = height;
if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer(unused, width, height);
world = new World();
world.setAmbientLight(20, 20, 20);
sun = new Light(world);
sun.setIntensity(250, 250, 250);
Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(context.getResources().getDrawable(R.drawable.icon)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);
cube = Primitives.getCube(50);
cube.calcTextureWrapSpherical();
cube.setTexture("texture");
cube.strip();
cube.build();
world.addObject(cube);
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(cube.getTransformedCenter());
SimpleVector sv = new SimpleVector();
sv.set(cube.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
MemoryHelper.compact();
}
public void onDrawFrame(GL10 unused) {
ARNativeActivity.nativeDrawFrame();
// try {
if (fb != null) {
fb.clear();
world.renderScene(fb);
world.draw(fb);
fb.display();
Logger.log("Drawing thread running!", Logger.MESSAGE);
}
}