title: Android OpenGL ES ortho strange aspect ratio
body: <p>I'm quite new to OpenGL ES and I'm trying to draw some textured quads. I want to keep it 2D so I decided to use orthographic projection. What I really want is to draw a plane that takes the same relative amount of screen space on every device regardless the screen resolution. </p>
  
  <p>The problem I encounter is the setup of the orthographic projection. The aspect ratio just isn't correct. A square is drawn as a rectangle in the height. This is my code so far:</p>
  
  <p>The Renderer:</p>
  
  <pre><code>// automatically looped by android
  public void onDrawFrame(GL10 gl) {
      // clear screen and buffer
      gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 
  
      // Draw elements
      for (GameObject object : level.getGameObjects()) {
          gl.glScalef(0.2f, 0.2f, 0.0f);
          object.draw(gl);
          gl.glLoadIdentity();
      }
  }
  
  public void onSurfaceChanged(GL10 gl, int width, int height) {
      gl.glViewport(0, 0, width, height);
      gl.glOrthof(0f, 480f, 0f, 800f, -1f, 1f);
  
  }
  
  public void onSurfaceCreated(GL10 gl, EGLConfig config) {
      // Load all textures
      for (GameObject object : level.getGameObjects()) {
          object.bindTexture(gl);
      }
  
      // Initialize game canvas
      gl.glEnable(GL10.GL_TEXTURE_2D); // Enable Texture Mapping
      gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black background
  
      // enable texture transparency
      gl.glEnable(GL10.GL_BLEND);
      gl.glBlendFunc(GL10.GL_SRC_ALPHA,   GL10.GL_ONE_MINUS_SRC_ALPHA);               
  }   
  </code></pre>
  
  <p>The draw method is exactly the same as in this tutorial: <a href="http://obviam.net/index.php/texture-mapping-opengl-android-displaying-images-using-opengl-and-squares/" rel="nofollow">http://obviam.net/index.php/texture-mapping-opengl-android-displaying-images-using-opengl-and-squares/</a></p>
  
  <p>Kind regards,
  Daan  </p>