i made a test case.
if gl2=false, you can see the color of a box changes a bit, while with gl2=true, color doesn't change.
package abc.def;
import com.threed.jpct.*;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLSurfaceView;
import android.os.Bundle; import android.app.Activity;
import java.lang.reflect.Field;
public class Sim extends Activity {
static GLSurfaceView GLview; static MyRenderer renderer;
static FrameBuffer fb;
static World world=new World();
static Camera cam=world.getCamera();
static Object3D box=Primitives.getBox(5,1),gnd=Primitives.getPlane(1,500);
static float yaw;
static SimpleVector vec=new SimpleVector();
static Light sun;
static Texture tex=new Texture(1,1,new RGBColor(200,200,200));
static boolean gl2=false;
void init() { sun=new Light(world); sun.setAttenuation(-1f);
sun.setDiscardDistance(-1f); vec.set(0,2000,10000);
sun.setPosition(vec); TextureManager.getInstance().addTexture("tex",tex);
box.setTexture("tex"); box.build();
world.addObject(box); box.setSpecularLighting(true);
gnd.build(); world.addObject(gnd);
vec.set(0,50,0); gnd.setOrigin(vec); gnd.rotateX((float)Math.PI/2);
}
protected void onCreate(Bundle a) {
super.onCreate(a); renderer=new MyRenderer();
GLview=new GLSurfaceView(getApplication());
if (gl2) GLview.setEGLContextClientVersion(2); else
GLview.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl,EGLDisplay display) {
int[] attributes=new int[]{EGL10.EGL_DEPTH_SIZE,16,EGL10.EGL_NONE};
EGLConfig[] configs=new EGLConfig[1]; int[] result=new int[1];
egl.eglChooseConfig(display,attributes,configs,1,result);
return configs[0]; } } );
GLview.setRenderer(renderer); setContentView(GLview); }
@Override
protected void onPause() { super.onPause(); GLview.onPause(); }
@Override
protected void onResume() { super.onResume(); GLview.onResume(); }
@Override
protected void onStop() { super.onStop(); }
class MyRenderer implements GLSurfaceView.Renderer {
public void onSurfaceCreated(GL10 g,EGLConfig c) {}
public void onSurfaceChanged(GL10 g,int w,int h) {
if (gl2) fb=new FrameBuffer(w,h);
else fb=new FrameBuffer(g,w,h);
init(); }
public void onDrawFrame(GL10 g) {
float a=0.01f; yaw-=a; cam.rotateY(a);
vec.set(50*(float)Math.sin(yaw),10f,50*(float)Math.cos(yaw));
box.setOrigin(vec);
fb.clear(); world.renderScene(fb);
world.draw(fb); fb.display(); } }
}