I've tried to push all that i can image, but the problem goes on.
When i load a .3ds file with the picture texture, WW's maps can be pasted corectly after the box/model goes out of sight. But i can no longer see the model again. It is covered by the WW's map layer--I do not know the reason now.
Is there some differences between drawing a box and a Primitive box? Some gl coordinate or texture transforms?
Or is it about FBO/VBO? Actually, i have no more idea now.
// puts opengl in the correct state for this layer
protected void beginDraw(DrawContext dc) {
GL2 gl = (GL2) dc.getGL();
// gl.glPushAttrib(GL2.GL_TEXTURE_BIT | GL2.GL_ENABLE_BIT
// | GL2.GL_CURRENT_BIT | GL2.GL_TRANSFORM_BIT);
gl.glPushAttrib(GL2.GL_ALL_ATTRIB_BITS);
// if (!dc.isPickingMode()) {
// gl.glEnable(GL.GL_BLEND);
// gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
// }
gl.glMatrixMode(GL2.GL_MODELVIEW);//|GL2.GL_PROJECTION|GL2.GL_TEXTURE);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(GL2.GL_TEXTURE);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixPushEXT(GL2.GL_MODELVIEW);
gl.glMatrixPushEXT(GL2.GL_PROJECTION);
gl.glMatrixPushEXT(GL2.GL_TEXTURE);
// inject gl if neccessary
if (this.lastGL != gl) {
Util.injectExternalGL(canvas, gl);
this.lastGL = gl;
}
}
/**
* Called by WorldWind to refresh this layer.
*/
@Override
protected void doRender(DrawContext dc) {
this.beginDraw(dc);
// get the eye point of WW, to set the camera in jPCT
// so that jpct's camera go with ww's eye point
Vec4 eyeLoc = dc.getView().getEyePoint();
this.world.getCamera().setPosition(ww2jpct(eyeLoc));
this.world.getCamera().lookAt(new SimpleVector(0, 0, 0));
// save current gl settings before change it
dc.getView().pushReferenceCenter(dc, eyeLoc);
// jPCT draw its world with the given gl
this.repaint();
// force jPCT to draw on WW's gl.
Util.forceDraw(canvas);
// restore last gl settings
dc.getView().popReferenceCenter(dc);
this.endDraw(dc);
}
// resets opengl state
protected void endDraw(DrawContext dc) {
GL2 gl = (GL2) dc.getGL();
gl.glMatrixPopEXT(GL2.GL_TEXTURE);
gl.glMatrixPopEXT(GL2.GL_PROJECTION);
gl.glMatrixPopEXT(GL2.GL_MODELVIEW);
gl.glMatrixMode(GL2.GL_TEXTURE);
gl.glPopMatrix();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPopMatrix();
gl.glMatrixMode(GL2.GL_MODELVIEW);//|GL2.GL_PROJECTION|GL2.GL_TEXTURE);
gl.glPopMatrix();
gl.glPopAttrib();
}