Im getting a perfect aspect radio of the "green scuare" (see attached image), but still can't see the scuare to be 640x400 pixels in the screen.
Please help!
This is my code:
@Override
public void onSurfaceChanged(GL10 gl, int w, int h) {
// -------------------------------------------------------
// Setup 2D View's
// -------------------------------------------------------
// draw's the background grid as reference (you can discard this from the code)
framel.newImageView((graphics.newImage("xtemppatron.png", ImageFormat.ARGB4444)).getBitmap(), 0, 000);
// -------------------------------------------------------
// Setup OpenGL objects
// -------------------------------------------------------
if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer(gl, w, h);
if (master == null) {
world = new World();
world.setAmbientLight(20, 20, 20);
// Place camera according with device screen
cam = world.getCamera();
float YFOV = (float) (2 * Math.atan(cam.getFOV()/2 * h / w)); // <<---OK
cam.setYFovAngle(YFOV);
float z = (float) (0.5 * h / Math.tan(YFOV/2));
cam.setPosition(0, 0, -z);
cam.lookAt(SimpleVector.ORIGIN);
// custom class to print logs to lower left corner on my screen (you can discard this and use Logger)
//debug("w= " + w + " h= " + h + " FOV= " + (float) ((2 * Math.atan(cam.getFOV()/2) *180f) / Math.PI) + " YFOV= " + (float) ((YFOV *180f) / Math.PI) + " CameraZ= " + z);
Logger.log("w= " + w + " h= " + h + " FOV= " + (float) ((2 * Math.atan(cam.getFOV()/2) *180f) / Math.PI) + " YFOV= " + (float) ((YFOV *180f) / Math.PI) + " CameraZ= " + z);
sun = new Light(world);
sun.setIntensity(2250, 2250, 2250);
sv.set(0, 0,0);
sun.setPosition(sv);
SimpleVector v1 = SimpleVector.create(-320, -200, 0);
SimpleVector v2 = SimpleVector.create(320, -200, 0);
SimpleVector v3 = SimpleVector.create(320, 200, 0);
SimpleVector v4 = SimpleVector.create(-320, 200, 0);
SimpleVector v5 = SimpleVector.create(-320, -200, 0);
SimpleVector[] vec = new SimpleVector[] { v1,v2,v3,v4,v5 };
Polyline line1 = new Polyline(vec, RGBColor.GREEN);
world.addPolyline(line1);
MemoryHelper.compact();
if (master == null) {
master = ActivityCarpa.this;
}
}
}