New to droid. Working on a super cool 3D OpenGl game.
I get a different screen resolution depending upon the orientation of the G1. I cant remember exactly, but it is something like 840x480 when horizontal and 359x580 when vertical. Is this right? Or, is there something I can do to get the high resolution when vertical?
Some code:
Using java Syntax Highlighting
- public class LavaBall extends Activity implements SensorListener{
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- this.requestWindowFeature(getWindow().FEATURE_NO_TITLE);
- mView = new OpenGLRenderer(this);
- setContentView(mView);
- }
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
... and
Using java Syntax Highlighting
- public class OpenGLRenderer extends GLSurfaceView implements Renderer {
- private Context context;
- private int swidth;
- private int sheight;
- public OpenGLRenderer (Context context)
- {
- super(context);
- //Set this as Renderer
- this.setRenderer(this);
- this.context = context;
- }
- public void onSurfaceCreated(GL10 gl, EGLConfig config)
- {
- // Load up the textures we will use in this project
- loadTextures(gl);
- // Create the lights
- createLights(gl);
- // Do the one time gl initialization stuff
- glInit(gl);
- // Initialize all game objects
- loadObjects(gl);
- }
- public void onSurfaceChanged(GL10 gl, int width, int height)
- {
- swidth = width;
- sheight = height;
- // Setup the projection matrix
- setStandardProjection2(gl);
- }
- public void glInit(GL10 gl)
- {
- // Set the background color to black ( rgba ).
- gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
- // Enable Smooth Shading, default not really needed.
- gl.glShadeModel(GL10.GL_SMOOTH);
- // Depth buffer setup.
- gl.glClearDepthf(1.0f);
- // Enables depth testing.
- gl.glEnable(GL10.GL_DEPTH_TEST);
- // The type of depth testing to do.
- gl.glDepthFunc(GL10.GL_LEQUAL);
- // Really nice perspective calculations.
- gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
- }
- public void setStandardProjection2(GL10 gl)
- {
- // Sets the current view port to the new size.
- gl.glViewport(0, 0, swidth, sheight);
- // Select the projection matrix
- gl.glMatrixMode(GL10.GL_PROJECTION);
- // Reset the projection matrix
- gl.glLoadIdentity();
- float gheight = 2;
- float z=16;
- float near=4;
- float far=z+z-near;
- float height = (gheight*near)/z;
- //float height = (gheight*near)/(2*((z-near)/2+near));
- float ratio = (float)swidth/(float)sheight;
- float width = height*ratio;
- // Create the frustum view
- gl.glFrustumf(-width, width, -height, height, near, far);
- // Look at the origin
- GLU.gluLookAt(gl, 0, 0, 16, 0, 0, 0, 0, 1, 0);
- }
- }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
The widths and heights I get are not the same resolutions for the two orientations. I don't get it. Any ideas?
Thanks


